Greyscale bars/Display: Difference between revisions

Content added Content deleted
Line 698: Line 698:
</pre>
</pre>
And here's another clever and shorter solution:
And here's another clever and shorter solution:
<lang futurebasic>
<lang futurebasic>void local fn BuildWindow
CGRect r = {0,0,640,400}
void local fn BuildWindow
long i, j, bars = 8
'~'1
CGFloat gray, delta, y = 0.0, w = 80
CGRect r = {0,0,640,400}
long i, j, bars = 8
window 1, @"Grayscale Bars", r
CGFloat gray, delta, y = 0.0, w = 80

pen -1
window 1, @"Grayscale Bars", r
for j = 1 to 4

delta = 1.0/(bars-1)
pen -1
if ( j mod 2 ) then gray = 0.0 else gray = 1.0 : delta = -delta
for j = 1 to 4
r = fn CGRectMake( 0, y, w, 100 )
delta = 1.0/(bars-1)
for i = 1 to bars
if ( j mod 2 ) then gray = 0.0 else gray = 1.0 : delta = -delta
rect fill r, fn ColorWithWhite( gray, 1.0 )
r = fn CGRectMake( 0, y, w, 100 )
r.origin.x += w
for i = 1 to bars
rect fill r, fn ColorWithWhite( gray, 1.0 )
gray += delta
next
r.origin.x += w
bars = bars << 1
gray += delta
y += 100 : w = w/2
next
next
bars = bars << 1
y += 100 : w = w/2
next
end fn
end fn


fn BuildWindow
fn BuildWindow


HandleEvents
HandleEvents</lang>
</lang>


=={{header|Gambas}}==
=={{header|Gambas}}==