Reputation: 13
I am new to Haskell and I'm trying to change the position of a drawn path.
let redPath = Path[Point 420 750, Point 420 550] red Solid
drawPicture 10 [redPath, movePictureObject (Vector 100 100)
redPath]
The functions movePictureObject and movePoint should change every point of the path with a given vector (100,100).
movePoint :: Point -> Vector -> Point
movePoint (Point x y) (Vector xv yv)
= Point (x + xv) (y + yv)
movePictureObject :: Vector -> PictureObject ->PictureObject
movePictureObject vec (Path points colour lineStyle)
= Path map (movePoint (points vec)) red Solid
I am not sure of how to use the map function properly, I have read several posts here and watched other tutorials.
Thank you.
Upvotes: 0
Views: 230
Reputation: 34411
My crystal ball tells me, that you just need (map movePoint (points vec))
instead of map (movePoint (points vec))
in the last line.
Upvotes: 1