ok zoomer

This commit is contained in:
aliasless 2020-01-30 08:30:10 -08:00
parent eabfd8e143
commit 68091e1ff1
4 changed files with 17 additions and 6 deletions

BIN
app/.Main.hs.swp Normal file

Binary file not shown.

View File

@ -31,11 +31,12 @@ toPicture figure@(Compound figures) = G.pictures $ map toPicture' figures ++ [ce
mirror XY = G.scale (-1) (-1)
color Positive = G.color G.blue
color Negative = G.color G.red
color Negative = G.color G.black
centroid' = let dx = getX $ centroid figure
dy = getY $ centroid figure
in G.translate dx dy . G.color G.red $ G.circleSolid 5
in G.pictures [ G.translate dx dy . G.color G.red . G.scale 10 10 $ cross
, G.scale 1000 1000 . G.color G.white $ cross ]
where getX (Location x _) = realToFrac x
getY (Location _ y) = realToFrac y
@ -55,3 +56,7 @@ rectangle w h = G.polygon [(0, 0), (w, 0), (w, h), (0, h)]
semicircle :: Float -> G.Picture
semicircle r = G.arcSolid 0 180 r
cross :: G.Picture
cross = G.pictures $ [ G.line [ (-1, 0), (1, 0) ]
, G.line [ (0, -1), (0, 1) ] ]

BIN
src/.Lib.hs.swp Normal file

Binary file not shown.

View File

@ -70,7 +70,13 @@ instance Centroid Figure where
yb' NS = yb
yb' S = xb
centroid :: Compound -> Location
centroid (Compound figures) = Location (dist xb) (dist yb)
where dist f = (sum $ map (\figure -> area figure * f figure) figures)
/ (sum $ map area figures)
dist f (Compound figures) = (sum $ map (\figure -> area figure * f figure) figures)
/ (sum $ map area figures)
instance Centroid Compound where
area (Compound figures) = sum $ map area figures
xb = dist xb
yb = dist yb
centroid :: Centroid a => a -> Location
centroid figure = Location (xb figure) (yb figure)