Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Nik Nyby
committed
Apr 19, 2010
1 parent
95a5b01
commit 8a65d26
Showing
5 changed files
with
51 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
module Rectangle ( | ||
Rectangle(..), | ||
boxAroundRect, | ||
vertexRect, | ||
) where | ||
import Graphics.UI.GLUT | ||
|
||
data Rectangle = | ||
Rectangle | ||
{ | ||
rectX :: GLdouble, | ||
rectY :: GLdouble, | ||
rectWidth :: GLdouble, | ||
rectHeight :: GLdouble | ||
} deriving (Show, Eq) | ||
|
||
-- return a list of four vertices for a rectangle, given position and size | ||
vertexRect :: Rectangle -> [Vertex2 GLdouble] | ||
vertexRect (Rectangle x y width height) = | ||
[(Vertex2 (x-w) (y+h)) | ||
, (Vertex2 (x-w) (y-h)) | ||
, (Vertex2 (x+w) (y-h)) | ||
, (Vertex2 (x+w) (y+h))] | ||
where | ||
w = width / 2 | ||
h = height / 2 | ||
|
||
boxAroundRect :: Rectangle -> GLdouble -> Rectangle | ||
boxAroundRect r i = r { | ||
rectWidth = rectWidth r + i, | ||
rectHeight = rectHeight r + i | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters