{-# LANGUAGE BangPatterns #-}
module Graphics.Gloss.Data.Point.Arithmetic
(
Point
, (+)
, (-)
, (*)
, negate
) where
import Prelude (Float)
import qualified Prelude as P
import Graphics.Gloss.Rendering (Point)
infixl 6 +, -
infixl 7 *
(+) :: Point -> Point -> Point
(Float
x1, Float
y1) + :: Point -> Point -> Point
+ (Float
x2, Float
y2) =
let
!x :: Float
x = Float
x1 Float -> Float -> Float
forall a. Num a => a -> a -> a
P.+ Float
x2
!y :: Float
y = Float
y1 Float -> Float -> Float
forall a. Num a => a -> a -> a
P.+ Float
y2
in (Float
x, Float
y)
(-) :: Point -> Point -> Point
(Float
x1, Float
y1) - :: Point -> Point -> Point
- (Float
x2, Float
y2) =
let
!x :: Float
x = Float
x1 Float -> Float -> Float
forall a. Num a => a -> a -> a
P.- Float
x2
!y :: Float
y = Float
y1 Float -> Float -> Float
forall a. Num a => a -> a -> a
P.- Float
y2
in (Float
x, Float
y)
negate :: Point -> Point
negate :: Point -> Point
negate (Float
x, Float
y) =
let
!x' :: Float
x' = Float -> Float
forall a. Num a => a -> a
P.negate Float
x
!y' :: Float
y' = Float -> Float
forall a. Num a => a -> a
P.negate Float
y
in (Float
x', Float
y')
(*) :: Float -> Point -> Point
* :: Float -> Point -> Point
(*) Float
s (Float
x, Float
y) =
let
!x' :: Float
x' = Float
s Float -> Float -> Float
forall a. Num a => a -> a -> a
P.* Float
x
!y' :: Float
y' = Float
s Float -> Float -> Float
forall a. Num a => a -> a -> a
P.* Float
y
in (Float
x', Float
y')