Skip to content

Commit

Permalink
rgb -> hsl
Browse files Browse the repository at this point in the history
  • Loading branch information
noahzgordon committed Jun 25, 2019
1 parent 776e7ae commit 6a3732e
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 42 deletions.
61 changes: 28 additions & 33 deletions elm.js
Expand Up @@ -8111,6 +8111,27 @@ var author$project$Sutcliffe$Model$spawnGroups = function (lines) {
},
triples);
};
var avh4$elm_color$Color$hsla = F4(
function (hue, sat, light, alpha) {
var _n0 = _Utils_Tuple3(hue, sat, light);
var h = _n0.a;
var s = _n0.b;
var l = _n0.c;
var m2 = (l <= 0.5) ? (l * (s + 1)) : ((l + s) - (l * s));
var m1 = (l * 2) - m2;
var hueToRgb = function (h__) {
var h_ = (h__ < 0) ? (h__ + 1) : ((h__ > 1) ? (h__ - 1) : h__);
return ((h_ * 6) < 1) ? (m1 + (((m2 - m1) * h_) * 6)) : (((h_ * 2) < 1) ? m2 : (((h_ * 3) < 2) ? (m1 + (((m2 - m1) * ((2 / 3) - h_)) * 6)) : m1));
};
var b = hueToRgb(h - (1 / 3));
var g = hueToRgb(h);
var r = hueToRgb(h + (1 / 3));
return A4(avh4$elm_color$Color$RgbaSpace, r, g, b, alpha);
});
var avh4$elm_color$Color$hsl = F3(
function (h, s, l) {
return A4(avh4$elm_color$Color$hsla, h, s, l, 1.0);
});
var author$project$Sutcliffe$Model$init = function (flags) {
var centerPoint = ianmackenzie$elm_geometry$Point2d$fromCoordinates(
_Utils_Tuple2((flags.window.width - 200) / 2, flags.window.height / 2));
Expand All @@ -8135,7 +8156,7 @@ var author$project$Sutcliffe$Model$init = function (flags) {
return {
finished: _List_Nil,
growing: {
color: A4(avh4$elm_color$Color$rgba, 0.5, 0.5, 0.5, 0.5),
color: A3(avh4$elm_color$Color$hsl, 0.5, 0.5, 0.5),
groups: author$project$Sutcliffe$Model$spawnGroups(initialStruts),
pentNum: 0
},
Expand Down Expand Up @@ -8280,31 +8301,6 @@ var elm$core$List$all = F2(
A2(elm$core$Basics$composeL, elm$core$Basics$not, isOkay),
list);
});
var elm$random$Random$map4 = F5(
function (func, _n0, _n1, _n2, _n3) {
var genA = _n0.a;
var genB = _n1.a;
var genC = _n2.a;
var genD = _n3.a;
return elm$random$Random$Generator(
function (seed0) {
var _n4 = genA(seed0);
var a = _n4.a;
var seed1 = _n4.b;
var _n5 = genB(seed1);
var b = _n5.a;
var seed2 = _n5.b;
var _n6 = genC(seed2);
var c = _n6.a;
var seed3 = _n6.b;
var _n7 = genD(seed3);
var d = _n7.a;
var seed4 = _n7.b;
return _Utils_Tuple2(
A4(func, a, b, c, d),
seed4);
});
});
var author$project$Sutcliffe$Update$tick = F2(
function (time, model) {
var newModel = _Utils_update(
Expand Down Expand Up @@ -8352,13 +8348,12 @@ var author$project$Sutcliffe$Update$tick = F2(
growingSides)) {
var seed0 = elm$random$Random$initialSeed(
elm$time$Time$posixToMillis(time));
var colorGen = A5(
elm$random$Random$map4,
avh4$elm_color$Color$rgba,
A2(elm$random$Random$float, 0.3, 0.8),
A2(elm$random$Random$float, 0.3, 0.8),
A2(elm$random$Random$float, 0.3, 0.8),
A2(elm$random$Random$float, 0.4, 0.9));
var colorGen = A4(
elm$random$Random$map3,
avh4$elm_color$Color$hsl,
A2(elm$random$Random$float, 0, 1),
A2(elm$random$Random$float, 0.5, 1),
A2(elm$random$Random$float, 0.4, 0.6));
var _n2 = A2(elm$random$Random$step, colorGen, seed0);
var newColor = _n2.a;
var seed1 = _n2.b;
Expand Down
5 changes: 4 additions & 1 deletion elm.json
Expand Up @@ -19,11 +19,14 @@
"elm-community/typed-svg": "5.0.1",
"ianmackenzie/elm-geometry": "1.2.1",
"ianmackenzie/elm-geometry-svg": "1.0.2",
"mdgriffith/elm-ui": "1.1.0"
"mdgriffith/elm-ui": "1.1.0",
"noahzgordon/elm-color-extra": "1.0.2"
},
"indirect": {
"elm/regex": "1.0.0",
"elm/url": "1.0.0",
"elm/virtual-dom": "1.0.2",
"fredcy/elm-parseint": "2.0.1",
"ianmackenzie/elm-float-extra": "1.0.1",
"ianmackenzie/elm-interval": "1.0.1",
"ianmackenzie/elm-triangular-mesh": "1.0.2"
Expand Down
4 changes: 2 additions & 2 deletions src/Sutcliffe/Model.elm
Expand Up @@ -3,7 +3,7 @@ module Sutcliffe.Model exposing (Embellishment, Line, Model, Pent, Phase(..), St
import Arc2d
import Axis2d as Axis
import Circle2d as Circle
import Color exposing (Color, rgba)
import Color exposing (Color, hsl)
import Direction2d as Direction
import LineSegment2d as LineSegment exposing (LineSegment2d)
import List.Extra as List
Expand Down Expand Up @@ -95,7 +95,7 @@ init flags =
, strutLength = 10
, growing =
{ groups = spawnGroups initialStruts
, color = rgba 0.5 0.5 0.5 0.5
, color = hsl 0.5 0.5 0.5
, pentNum = 0
}
, finished = []
Expand Down
11 changes: 5 additions & 6 deletions src/Sutcliffe/Update.elm
@@ -1,6 +1,6 @@
module Sutcliffe.Update exposing (Modifier, modify, tick)

import Color exposing (rgba)
import Color exposing (hsl)
import Direction2d as Direction
import LineSegment2d as LineSegment
import List.Extra as List
Expand Down Expand Up @@ -53,11 +53,10 @@ tick time model =
Random.initialSeed (Time.posixToMillis time)

colorGen =
Random.map4 rgba
(Random.float 0.3 0.8)
(Random.float 0.3 0.8)
(Random.float 0.3 0.8)
(Random.float 0.4 0.9)
Random.map3 hsl
(Random.float 0 1)
(Random.float 0.5 1)
(Random.float 0.4 0.6)

( newColor, seed1 ) =
Random.step colorGen seed0
Expand Down

0 comments on commit 6a3732e

Please sign in to comment.