Greyscale bars/Display: Difference between revisions

Line 697:
[See accompanying screenshot.]
</pre>
And here's another clever and shorter solution:
<lang futurebasic>
void local fn BuildWindow
'~'1
CGRect r = {0,0,640,400}
long i, j, bars = 8
CGFloat gray, delta, y = 0.0, w = 80
 
window 1, @"Grayscale Bars", r
 
pen -1
for j = 1 to 4
delta = 1.0/(bars-1)
if ( j mod 2 ) then gray = 0.0 else gray = 1.0 : delta = -delta
r = fn CGRectMake( 0, y, w, 100 )
for i = 1 to bars
rect fill r, fn ColorWithWhite( gray, 1.0 )
r.origin.x += w
gray += delta
next
bars = bars << 1
y += 100 : w = w/2
next
end fn
 
fn BuildWindow
 
HandleEvents
</lang>
 
=={{header|Gambas}}==
717

edits