Skip to content

Commit

Permalink
色の配列を用意して、ランダムに色を変える
Browse files Browse the repository at this point in the history
  • Loading branch information
nobu09 committed Dec 10, 2023
1 parent b1e6e9f commit c8ee5a1
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions programs/tree.rb
Expand Up @@ -2,6 +2,7 @@ def setup
$xSlide = 10
$ySlide = 10
$split = 60
$colors = ["green", "mediumaquamarine", "lightgreen", "turquoise", "limegreen"]

createCanvas($xSlide * $split, $ySlide * $split)
end
Expand All @@ -21,6 +22,7 @@ def draw
xAdjust = 0

for xCount in 0..yIndex
fill($colors[rand(0..$colors.length-1)])
triangle($xSlide * (xIndex + xAdjust), $ySlide * yIndex, $xSlide * (xIndex + xAdjust - 0.5), $ySlide * (yIndex + 1), $xSlide * (xIndex + xAdjust + 0.5), $ySlide * (yIndex + 1))
xAdjust += 1
end
Expand All @@ -39,6 +41,7 @@ def draw
xAdjust = 0

for xCount in 0...yIndex
fill($colors[rand(0..$colors.length-1)])
triangle($xSlide * (xIndex + xAdjust), $ySlide * yIndex, $xSlide * (xIndex + xAdjust ++ 0.5), $ySlide * (yIndex + 1), $xSlide *(xIndex + xAdjust + 1), $ySlide * yIndex)
xAdjust += 1
end
Expand Down

0 comments on commit c8ee5a1

Please sign in to comment.