Draw breakout rects differently

This commit is contained in:
Richard Feldman 2022-04-08 10:56:56 -04:00
parent 0f6e1bac73
commit d40c7ed1d9
No known key found for this signature in database
GPG key ID: 7E4127D1E4241798

View file

@ -7,6 +7,7 @@ program = { render }
render = \state ->
div0 = \numerator, denominator -> (numerator / denominator) |> Result.withDefault 0
intDiv0 = \numerator, denominator -> (numerator // denominator) |> Result.withDefault 0
rgba = \r, g, b, a -> { r: div0 r 255, g: div0 g 255, b: div0 b 255, a }
@ -18,12 +19,22 @@ render = \state ->
blocks = List.map (List.range 0 (numRows * numCols)) \index ->
{ col: index, row: (index // 5 |> Result.withDefault 0) }
blockWidth = 100
blockHeight = 50
blockWidth = 50
blockHeight = 20
List.map blocks \{ row, col } ->
left = Num.toF32 (col * blockWidth)
top = Num.toF32 (row * blockHeight)
color = rgba 10 20 30 1 # TODO different colors for each block!
red =
250 // col
|> Result.withDefault 0
|> Num.toF32
green =
250 // row
|> Result.withDefault 0
|> Num.toF32
color = rgba red 120 green 1
Rect { left, top, width: blockWidth, height: blockHeight, color }