Skip to content

Commit

Permalink
while から for 文に変更した
Browse files Browse the repository at this point in the history
  • Loading branch information
nobu09 committed Dec 4, 2023
1 parent 9170ef1 commit 32e6d22
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions programs/tree.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
def setup
$xSlide = 80
$ySlide = Math::sqrt(($xSlide)**2 - ($xSlide / 2)**2)
$ySlide = (Math::sqrt(($xSlide)**2 - ($xSlide / 2)**2)).ceil
$split = 9

createCanvas($xSlide * $split, $ySlide * $split)
Expand All @@ -9,20 +9,19 @@ def setup
def draw
noLoop
noStroke
fill('#000000')

x = 0
while x < width
for xIndex in 0..width
y = 0
index = 0
while y < height
if index.even?
fill("black")

for yIndex in 0..height
if yIndex.even?
triangle(x, y + $ySlide, x + $xSlide / 2, y, x + $xSlide, y + $ySlide)
else
triangle(x, y, x + $xSlide, y, x + $xSlide / 2, y + $ySlide)
end
y += $ySlide
index += 1
end
x += $xSlide
end
Expand Down

0 comments on commit 32e6d22

Please sign in to comment.