mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-03 08:34:33 +00:00
Draw breakout rects differently
This commit is contained in:
parent
0f6e1bac73
commit
d40c7ed1d9
1 changed files with 14 additions and 3 deletions
|
@ -7,6 +7,7 @@ program = { render }
|
||||||
|
|
||||||
render = \state ->
|
render = \state ->
|
||||||
div0 = \numerator, denominator -> (numerator / denominator) |> Result.withDefault 0
|
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 }
|
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 ->
|
blocks = List.map (List.range 0 (numRows * numCols)) \index ->
|
||||||
{ col: index, row: (index // 5 |> Result.withDefault 0) }
|
{ col: index, row: (index // 5 |> Result.withDefault 0) }
|
||||||
|
|
||||||
blockWidth = 100
|
blockWidth = 50
|
||||||
blockHeight = 50
|
blockHeight = 20
|
||||||
|
|
||||||
List.map blocks \{ row, col } ->
|
List.map blocks \{ row, col } ->
|
||||||
left = Num.toF32 (col * blockWidth)
|
left = Num.toF32 (col * blockWidth)
|
||||||
top = Num.toF32 (row * blockHeight)
|
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 }
|
Rect { left, top, width: blockWidth, height: blockHeight, color }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue