2013-03-06 17:24:17 +00:00
|
|
|
|
|
|
|
module Graphics.Collage where
|
|
|
|
|
|
|
|
import Either
|
2013-03-12 07:48:11 +00:00
|
|
|
import Graphics.LineStyle as LS
|
2013-03-15 17:56:07 +00:00
|
|
|
import Graphics.Geometry
|
2013-03-15 17:58:59 +00:00
|
|
|
import Native.Graphics.Matrix as Matrix
|
2013-03-06 17:24:17 +00:00
|
|
|
|
2013-03-15 17:56:07 +00:00
|
|
|
type Form = { transform : Matrix, form : BasicForm }
|
2013-03-06 17:24:17 +00:00
|
|
|
|
|
|
|
data FillStyle
|
|
|
|
= NoFill
|
|
|
|
| Solid Color
|
|
|
|
| Texture String
|
|
|
|
| Gradient Gradient
|
|
|
|
|
|
|
|
data BasicForm
|
2013-03-16 08:11:15 +00:00
|
|
|
= FPath LineStyle Path
|
2013-03-06 17:24:17 +00:00
|
|
|
| FShape (Either LineStyle FillStyle) Shape
|
|
|
|
| FImage Int Int (Int,Int) String
|
|
|
|
| FElement Element
|
|
|
|
| FGroup [Form]
|
|
|
|
|
2013-03-16 20:00:59 +00:00
|
|
|
ident = Matrix.identity
|
|
|
|
|
|
|
|
fill style shape = Form ident (FShape (Right style) shape)
|
2013-03-06 17:24:17 +00:00
|
|
|
|
|
|
|
filled : Color -> Shape -> Form
|
|
|
|
filled color shape = fill (Solid color) shape
|
|
|
|
|
|
|
|
textured : String -> Shape -> Form
|
|
|
|
textured src shape = fill (Texture src) shape
|
|
|
|
|
|
|
|
gradient : Gradient -> Shape -> Form
|
|
|
|
gradient grad shape = fill (Gradient grad) shape
|
|
|
|
|
2013-03-16 08:11:15 +00:00
|
|
|
outline : LineStyle -> Shape -> Form
|
2013-03-16 20:00:59 +00:00
|
|
|
outline style shape = Form ident (FShape (Left style) shape)
|
2013-03-06 17:24:17 +00:00
|
|
|
|
2013-03-16 20:00:59 +00:00
|
|
|
trace : LineStyle -> Path -> Form
|
|
|
|
trace style path = Form ident (FPath style path)
|
2013-03-16 08:11:15 +00:00
|
|
|
|
|
|
|
sprite : Int -> Int -> (Int,Int) -> String -> Form
|
2013-03-16 20:00:59 +00:00
|
|
|
sprite w h pos src = Form ident (FImage w h pos src)
|
2013-03-16 08:11:15 +00:00
|
|
|
|
|
|
|
toForm : Element -> Form
|
2013-03-16 20:00:59 +00:00
|
|
|
toForm e = Form ident (FElement e)
|
2013-03-06 17:24:17 +00:00
|
|
|
|
2013-03-16 20:00:59 +00:00
|
|
|
group fs = Form ident (FGroup fs)
|
2013-03-06 17:24:17 +00:00
|
|
|
|
2013-03-16 08:11:15 +00:00
|
|
|
rotate t f = { form = f.form, transform = Matrix.rotate t f.transform }
|
|
|
|
scale s f = { form = f.form, transform = Matrix.scale s s f.transform }
|
|
|
|
scaleX s f = { form = f.form, transform = Matrix.scale s 1 f.transform }
|
|
|
|
scaleY s f = { form = f.form, transform = Matrix.scale 1 s f.transform }
|
|
|
|
move x y f = { form = f.form, transform = Matrix.move x y f.transform }
|
|
|
|
moveX x f = { form = f.form, transform = Matrix.move x 0 f.transform }
|
|
|
|
moveY y f = { form = f.form, transform = Matrix.move 0 y f.transform }
|
2013-03-06 17:24:17 +00:00
|
|
|
|
2013-03-16 08:11:15 +00:00
|
|
|
transform u v w x y z f =
|
|
|
|
{ form = f.form, transform = Matrix.matrix u v w x y z f.transform }
|