From: <kr_...@us...> - 2003-07-02 17:48:06
|
Update of /cvsroot/htoolkit/port/src/Port In directory sc8-pr-cvs1:/tmp/cvs-serv32391/src/Port Modified Files: Types.hs Log Message: The Vector data type was not used and now it is removed Index: Types.hs =================================================================== RCS file: /cvsroot/htoolkit/port/src/Port/Types.hs,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** Types.hs 8 Jun 2003 19:42:15 -0000 1.20 --- Types.hs 2 Jul 2003 17:48:03 -0000 1.21 *************** *** 4,11 **** ----------------------------------------------------------------------------------------- {-| Module : Types ! Copyright : (c) Krasimir Angelov & Daan Leijen 2003 License : BSD-style ! Maintainer : ka2...@ya... da...@cs... Stability : provisional Portability : portable --- 4,11 ---- ----------------------------------------------------------------------------------------- {-| Module : Types ! Copyright : (c) Krasimir Angelov 2003 License : BSD-style ! Maintainer : ka2...@ya... Stability : provisional Portability : portable *************** *** 19,35 **** -- ** Points ! Point(..), pt, pointFromVec, pointMove, pointMoveBySize, pointAdd, pointSub, pointScale -- ** Sizes , Size(..), sz, sizeEncloses, maxSize, addh, addv, sizeDistance - -- ** Vectors - , Vector(..), vc, vecNegate, vecOrtogonal, vecFromPoint, vecAdd, vecSub, vecScale, vecDistance - -- ** Rectangles , Rect(..), topLeft, topRight, bottomLeft, bottomRight , rect, rectAt, rectSize, rectOfSize, rectIsEmpty ! , pointInRect, rectMoveTo, pointToRect, centralPoint, centralRect, rectStretchTo ! , rectMove, disjointRects, rectsDiff, rectUnion, rectSect -- * Render --- 19,32 ---- -- ** Points ! Point(..), pt, pointMove, pointAdd, pointSub, pointScale -- ** Sizes , Size(..), sz, sizeEncloses, maxSize, addh, addv, sizeDistance -- ** Rectangles , Rect(..), topLeft, topRight, bottomLeft, bottomRight , rect, rectAt, rectSize, rectOfSize, rectIsEmpty ! , pointInRect, rectMove, rectMoveTo, pointToRect, centralPoint, centralRect, rectStretchTo ! , disjointRects, rectsDiff, rectUnion, rectSect -- * Render *************** *** 168,181 **** pt x y = Point x y ! pointFromVec :: Vector -> Point ! pointFromVec (Vector x y) ! = Point x y ! ! pointMove :: Vector -> Point -> Point ! pointMove (Vector dx dy) (Point x y) ! = Point (x+dx) (y+dy) ! ! pointMoveBySize :: Size -> Point -> Point ! pointMoveBySize (Size w h) (Point x y) = Point (x + w) (y + h) pointAdd :: Point -> Point -> Point --- 165,170 ---- pt x y = Point x y ! pointMove :: Size -> Point -> Point ! pointMove (Size w h) (Point x y) = Point (x + w) (y + h) pointAdd :: Point -> Point -> Point *************** *** 246,286 **** {----------------------------------------------------------------------------------------- - Vector - -----------------------------------------------------------------------------------------} - -- | A vector with an x and y delta. - data Vector = Vector - { vx :: !Int -- ^ delta-x component of a vector - , vy :: !Int -- ^ delta-y component of a vector - } - deriving (Eq,Show,Read) - - -- | Short function to construct a vector. - vc :: Int -> Int -> Vector - vc dx dy = Vector dx dy - - vecNegate :: Vector -> Vector - vecNegate (Vector x y) - = Vector (-x) (-y) - - vecOrtogonal :: Vector -> Vector - vecOrtogonal (Vector x y) = (Vector y (-x)) - - vecFromPoint :: Point -> Vector - vecFromPoint (Point x y) - = Vector x y - - vecAdd :: Vector -> Vector -> Vector - vecAdd (Vector x1 y1) (Vector x2 y2) = Vector (x1+x2) (y1+y2) - - vecSub :: Vector -> Vector -> Vector - vecSub (Vector x1 y1) (Vector x2 y2) = Vector (x1-x2) (y1-y2) - - vecScale :: Int -> Vector -> Vector - vecScale v (Vector x y) = Vector (v*x) (v*y) - - vecDistance :: Point -> Point -> Vector - vecDistance (Point x1 y1) (Point x2 y2) = Vector (x2-x1) (y2-y1) - - {----------------------------------------------------------------------------------------- Rectangle -----------------------------------------------------------------------------------------} --- 235,238 ---- *************** *** 298,305 **** deriving (Eq,Show) ! topLeft, topRight, bottomLeft, bottomRight :: Rect -> Point ! topLeft (Rect l t r b) = Point l t ! topRight (Rect l t r b) = Point r t ! bottomLeft (Rect l t r b) = Point l b bottomRight (Rect l t r b) = Point r b --- 250,267 ---- deriving (Eq,Show) ! -- | The top left corner of the rectangle ! topLeft :: Rect -> Point ! topLeft (Rect l t r b) = Point l t ! ! -- | The top right corner of the rectangle ! topRight :: Rect -> Point ! topRight (Rect l t r b) = Point r t ! ! -- | The bottom left corner of the rectangle ! bottomLeft :: Rect -> Point ! bottomLeft (Rect l t r b) = Point l b ! ! -- | The bottom right corner of the rectangle ! bottomRight :: Rect -> Point bottomRight (Rect l t r b) = Point r b *************** *** 330,333 **** --- 292,299 ---- pointInRect :: Point -> Rect -> Bool pointInRect (Point x y) (Rect l t r b) = x >= l && x <= r && y >= t && y <= b + + rectMove :: Size -> Rect -> Rect + rectMove (Size w h) (Rect l t r b) + = Rect (l+w) (t+h) (r+w) (b+h) rectMoveTo :: Point -> Rect -> Rect *************** *** 357,364 **** rectStretchTo (Size w h) (Rect l t r b) = Rect l t (l+w) (t+h) - - rectMove :: Vector -> Rect -> Rect - rectMove (Vector x y) (Rect x0 y0 x1 y1) - = Rect (x0+x) (y0+y) (x1+x) (y1+y) disjointRects :: Rect -> Rect -> Bool --- 323,326 ---- |