Draw a sphere: Difference between revisions
m
now resizeable
m (now resizeable) |
|||
Line 2,649:
=={{header|Phix}}==
{{trans|Go}} (Go gets credit for the dot/normalize/drawSphere routines, but this draws on screen rather than to png file)
Sphere will resize to match the window.
<lang Phix>--
-- demo\rosetta\Draw_a_sphere.exw
Line 2,668 ⟶ 2,669:
end function
procedure drawSphere(integer
integer r = floor((min(width,height)-20)/2)
integer cx = floor(width/2)
integer cy = floor(height/2)
integer lum
for x=-r to r do
Line 2,677 ⟶ 2,681:
lum = and_bits(#FF,255*(power(iff(s<0?0:s),k)+amb)/(1+amb))
lum += lum*#100+lum*#10000
cdCanvasPixel(cddbuffer, x+
end if
end for
Line 2,684 ⟶ 2,688:
function redraw_cb(Ihandle /*ih*/, integer /*posx*/, integer /*posy*/)
integer {width, height} = IupGetIntInt(canvas, "DRAWSIZE")
cdCanvasActivate(cddbuffer)
cdCanvasClear(cddbuffer)
drawSphere(
cdCanvasFlush(cddbuffer)
return IUP_DEFAULT
|