Skip to content

Commit

Permalink
Redo mixColors to use sum of squares, and fix normalisation
Browse files Browse the repository at this point in the history
  • Loading branch information
benl23x5 committed May 11, 2015
1 parent c64cd5e commit 19ace9f
Show file tree
Hide file tree
Showing 7 changed files with 171 additions and 71 deletions.
35 changes: 25 additions & 10 deletions Main.hs
Original file line number Diff line number Diff line change
@@ -1,15 +1,30 @@
module Main where

import Graphics.Gloss

main
= display
(InWindow "Colors" (800, 800) (5, 5))
(greyN 0.4)
(Pictures
[ Translate
(200 * cos (2 * pi * (fromIntegral n) / 12))
(200 * sin (2 * pi * (fromIntegral n) / 12))
$ Color (withAlpha 0.8 c) $ circleSolid 100
| n <- [0 .. length colors]
| c <- colors ])
colors
= [ red
, orange
, yellow
, chartreuse
, green
, aquamarine
, cyan
, azure
, blue
, mixColors 0.8 0.2 blue magenta -- violet
, magenta
, rose
]

renderInt :: Int -> Picture
renderInt = scale 0.2 0.2 . text . show

main :: IO ()
main = simulate (InWindow "Nice Window" (200, 200) (800, 200))
white
30
[0..]
(renderInt . head)
(\_ _ -> tail)
4 changes: 2 additions & 2 deletions gloss-algorithms/gloss-algorithms.cabal
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Name: gloss-algorithms
Version: 1.9.3.1
Version: 1.9.4.1
License: MIT
License-file: LICENSE
Author: Ben Lippmeier
Expand All @@ -25,7 +25,7 @@ Library
base == 4.8.*,
ghc-prim == 0.4.*,
containers == 0.5.*,
gloss == 1.9.3.*
gloss == 1.9.4.*

ghc-options:
-O2 -Wall
Expand Down
75 changes: 43 additions & 32 deletions gloss-examples/gloss-examples.cabal
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Name: gloss-examples
Version: 1.9.3.1
Version: 1.9.4.1
License: MIT
License-file: LICENSE
Author: Ben Lippmeier
Expand Down Expand Up @@ -32,7 +32,7 @@ Executable gloss-bitmap
base == 4.8.*,
bytestring == 0.10.*,
bmp == 1.2.*,
gloss == 1.9.3.*
gloss == 1.9.4.*
Main-is: Main.hs
hs-source-dirs: picture/Bitmap
ghc-options: -threaded -O2
Expand All @@ -41,7 +41,7 @@ Executable gloss-bitmap
Executable gloss-boids
Build-depends:
base == 4.8.*,
gloss == 1.9.3.*
gloss == 1.9.4.*
Main-is: Main.hs
other-modules: KDTree2d Vec2
hs-source-dirs: picture/Boids
Expand All @@ -51,17 +51,28 @@ Executable gloss-boids
Executable gloss-clock
Build-depends:
base == 4.8.*,
gloss == 1.9.3.*
gloss == 1.9.4.*
Main-is: Main.hs
hs-source-dirs: picture/Clock
ghc-options: -threaded -O2


Executable gloss-color
Build-depends:
base == 4.8.*,
vector == 0.10.*,
gloss == 1.9.4.*
Main-is: Main.hs
hs-source-dirs: picture/Color
ghc-options: -threaded -O2
extensions: ParallelListComp


Executable gloss-conway
Build-depends:
base == 4.8.*,
vector == 0.10.*,
gloss == 1.9.3.*
gloss == 1.9.4.*
Main-is: Main.hs
other-modules: Cell World
hs-source-dirs: picture/Conway
Expand All @@ -71,7 +82,7 @@ Executable gloss-conway
Executable gloss-draw
Build-depends:
base == 4.8.*,
gloss == 1.9.3.*
gloss == 1.9.4.*
Main-is: Main.hs
hs-source-dirs: picture/Draw
ghc-options: -threaded -O2
Expand All @@ -80,7 +91,7 @@ Executable gloss-draw
Executable gloss-easy
Build-depends:
base == 4.8.*,
gloss == 1.9.3.*
gloss == 1.9.4.*
Main-is: Main.hs
hs-source-dirs: picture/Easy
ghc-options: -threaded -O2
Expand All @@ -90,7 +101,7 @@ Executable gloss-eden
Build-depends:
base == 4.8.*,
random == 1.1.*,
gloss == 1.9.3.*
gloss == 1.9.4.*
Main-is: Main.hs
other-modules: Cell Community World
hs-source-dirs: picture/Eden
Expand All @@ -100,7 +111,7 @@ Executable gloss-eden
Executable gloss-flake
Build-depends:
base == 4.8.*,
gloss == 1.9.3.*
gloss == 1.9.4.*
Main-is: Main.hs
hs-source-dirs: picture/Flake
ghc-options: -threaded -O2
Expand All @@ -109,7 +120,7 @@ Executable gloss-flake
Executable gloss-gameevent
Build-depends:
base == 4.8.*,
gloss == 1.9.3.*
gloss == 1.9.4.*
Main-is: Main.hs
hs-source-dirs: picture/GameEvent
ghc-options: -threaded -O2
Expand All @@ -118,7 +129,7 @@ Executable gloss-gameevent
Executable gloss-hello
Build-depends:
base == 4.8.*,
gloss == 1.9.3.*
gloss == 1.9.4.*
Main-is: Main.hs
hs-source-dirs: picture/Hello
ghc-options: -threaded -O2
Expand All @@ -127,7 +138,7 @@ Executable gloss-hello
Executable gloss-lifespan
Build-depends:
base == 4.8.*,
gloss == 1.9.3.*,
gloss == 1.9.4.*,
random == 1.1.*
Main-is: Main.hs
other-modules: Cell Community World
Expand All @@ -138,7 +149,7 @@ Executable gloss-lifespan
Executable gloss-machina
Build-depends:
base == 4.8.*,
gloss == 1.9.3.*
gloss == 1.9.4.*
Main-is: Main.hs
hs-source-dirs: picture/Machina
ghc-options: -threaded -O2
Expand All @@ -147,8 +158,8 @@ Executable gloss-machina
Executable gloss-occlusion
Build-depends:
base == 4.8.*,
gloss == 1.9.3.*,
gloss-algorithms == 1.9.3.*
gloss == 1.9.4.*,
gloss-algorithms == 1.9.4.*
Main-is: Main.hs
other-modules: Cell World State Data
hs-source-dirs: picture/Occlusion
Expand All @@ -160,7 +171,7 @@ Executable gloss-styrene
base == 4.8.*,
ghc-prim == 0.4.*,
containers == 0.5.*,
gloss == 1.9.3.*
gloss == 1.9.4.*
Main-is: Main.hs
other-modules: Actor Advance Collide Config Contact QuadTree World
hs-source-dirs: picture/Styrene
Expand All @@ -170,7 +181,7 @@ Executable gloss-styrene
Executable gloss-tree
Build-depends:
base == 4.8.*,
gloss == 1.9.3.*
gloss == 1.9.4.*
Main-is: Main.hs
hs-source-dirs: picture/Tree
ghc-options: -threaded -O2
Expand All @@ -180,7 +191,7 @@ Executable gloss-visibility
Build-depends:
base == 4.8.*,
vector == 0.10.*,
gloss == 1.9.3.*
gloss == 1.9.4.*
Main-is: Main.hs
other-modules: Draw Interface State World Geometry.Randomish Geometry.Segment
hs-source-dirs: picture/Visibility
Expand All @@ -190,7 +201,7 @@ Executable gloss-visibility
Executable gloss-zen
Build-depends:
base == 4.8.*,
gloss == 1.9.3.*
gloss == 1.9.4.*
Main-is: Main.hs
hs-source-dirs: picture/Zen
ghc-options: -threaded -O2
Expand All @@ -199,8 +210,8 @@ Executable gloss-zen
Executable gloss-crystal
Build-depends:
base == 4.8.*,
gloss == 1.9.3.*,
gloss-raster == 1.9.3.*
gloss == 1.9.4.*,
gloss-raster == 1.9.4.*
Main-is: Main.hs
hs-source-dirs: raster/Crystal

Expand All @@ -223,8 +234,8 @@ Executable gloss-crystal
Executable gloss-ray
Build-depends:
base == 4.8.*,
gloss == 1.9.3.*,
gloss-raster == 1.9.3.*
gloss == 1.9.4.*,
gloss-raster == 1.9.4.*
Main-is: Main.hs
other-modules: Light Object Trace Vec3 World
hs-source-dirs: raster/Ray
Expand All @@ -242,8 +253,8 @@ Executable gloss-ray
Executable gloss-pulse
Build-depends:
base == 4.8.*,
gloss == 1.9.3.*,
gloss-raster == 1.9.3.*
gloss == 1.9.4.*,
gloss-raster == 1.9.4.*
Main-is: Main.hs
hs-source-dirs: raster/Pulse
ghc-options:
Expand All @@ -262,8 +273,8 @@ Executable gloss-wave
base == 4.8.*,
ghc-prim == 0.4.*,
vector == 0.10.*,
gloss == 1.9.3.*,
gloss-raster == 1.9.3.*
gloss == 1.9.4.*,
gloss-raster == 1.9.4.*
Main-is: Main.hs
hs-source-dirs: raster/Wave
ghc-options:
Expand All @@ -285,7 +296,7 @@ Executable gloss-fluid
repa == 3.4.*,
repa-io == 3.4.*,
repa-algorithms == 3.4.*,
gloss == 1.9.3.*
gloss == 1.9.4.*
Main-is: Main.hs
other-modules:
Args Config FieldElt Model UserEvent
Expand Down Expand Up @@ -313,7 +324,7 @@ Executable gloss-snow
Build-depends:
base == 4.8.*,
repa == 3.4.*,
gloss == 1.9.3.*
gloss == 1.9.4.*
Main-is: Main.hs
hs-source-dirs: raster/Snow
ghc-options:
Expand All @@ -331,7 +342,7 @@ Executable gloss-mandel
Build-depends:
base == 4.8.*,
repa == 3.4.*,
gloss == 1.9.3.*
gloss == 1.9.4.*
Main-is: Main.hs
other-modules: Solver
hs-source-dirs: raster/Mandel
Expand All @@ -355,7 +366,7 @@ Executable gloss-graph
Build-depends:
base == 4.8.*,
containers == 0.5.*,
gloss == 1.9.3.*
gloss == 1.9.4.*
Main-is: Main.hs
hs-source-dirs: picture/Graph
ghc-options:
Expand All @@ -366,7 +377,7 @@ Executable gloss-render
Build-depends:
base == 4.8.*,
containers == 0.5.*,
gloss == 1.9.3.*,
gloss == 1.9.4.*,
gloss-rendering == 1.9.3.*,
GLFW-b
Main-is: Main.hs
Expand Down
31 changes: 31 additions & 0 deletions gloss-examples/picture/Color/Main.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

-- Draw a color wheel.
import Graphics.Gloss

main
= display
(InWindow "Colors" (800, 800) (5, 5))
(greyN 0.4)
(Pictures
[ Translate
(200 * cos (2 * pi * (fromIntegral n) / 12))
(200 * sin (2 * pi * (fromIntegral n) / 12))
$ Color (withAlpha 0.8 c) $ circleSolid 100
| n <- [0 .. length colors]
| c <- colors ])
colors
= [ red
, orange
, yellow
, chartreuse
, green
, aquamarine
, cyan
, azure
, blue
, violet
, magenta
, rose
]


4 changes: 2 additions & 2 deletions gloss-raster/gloss-raster.cabal
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Name: gloss-raster
Version: 1.9.3.1
Version: 1.9.4.1
License: MIT
License-file: LICENSE
Author: Ben Lippmeier
Expand Down Expand Up @@ -32,7 +32,7 @@ Library
ghc-prim == 0.4.*,
containers == 0.5.*,
repa == 3.4.*,
gloss == 1.9.3.*,
gloss == 1.9.4.*,
gloss-rendering == 1.9.3.*

ghc-options:
Expand Down
Loading

0 comments on commit 19ace9f

Please sign in to comment.