Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
76
Task/Draw-a-cuboid/Phix/draw-a-cuboid.phix
Normal file
76
Task/Draw-a-cuboid/Phix/draw-a-cuboid.phix
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
include ..\arwen\arwen.ew
|
||||
include ..\arwen\axtra.ew
|
||||
|
||||
constant main = create(Window, "Draw Cuboid", 0, 0, 20, 20, 625, 690, 0),
|
||||
mainDC = getPrivateDC(main),
|
||||
backDC = c_func(xCreateCompatibleDC, {NULL}), -- the background
|
||||
viewDC = c_func(xCreateCompatibleDC, {NULL}), -- with animation
|
||||
grey = #909090
|
||||
|
||||
constant MainTimer = createTimer()
|
||||
|
||||
integer dw = 0, dh = 0 -- client area width and height
|
||||
atom bmBack, bmView
|
||||
integer bmX = 0, bmY = 0 -- actual size of the bitmaps
|
||||
|
||||
-- arrays: 3D coordinates of vertices
|
||||
sequence x = {-2.0, +2.0, +2.0, -2.0, -2.0, +2.0, +2.0, -2.0},
|
||||
y = {-1.5, -1.5, +1.5, +1.5, -1.5, -1.5, +1.5, +1.5},
|
||||
z = {-1.0, -1.0, -1.0, -1.0, +1.0, +1.0, +1.0, +1.0},
|
||||
Segment = {1,2, 2,3, 3,4, 4,1, 5,6, 6,7, 7,8, 8,5, 1,5, 2,6, 3,7, 4,8}
|
||||
|
||||
constant Size=50.0, Sz=0.008, Sx=-0.013 -- drawing size and tumbling speeds
|
||||
|
||||
function mainHandler(integer id, integer msg, atom wParam, object lParam)
|
||||
atom farthest
|
||||
integer v1, v2, farv, c
|
||||
if msg=WM_SIZE then
|
||||
{{},{},dw,dh} = getClientRect(main)
|
||||
if dw>bmX or dh>bmY then
|
||||
-- we need bigger bitmaps
|
||||
bmBack = c_func(xCreateCompatibleBitmap, {mainDC, dw, dh})
|
||||
{} = deleteObject(selectObject(backDC,bmBack))
|
||||
-- clear the background
|
||||
setPenColor(grey)
|
||||
setPenBkColor(grey)
|
||||
drawRectangleh(backDC, True, 0, 0, dw, dh)
|
||||
bmView = c_func(xCreateCompatibleBitmap, {mainDC, dw, dh})
|
||||
{} = deleteObject(selectObject(viewDC,bmView))
|
||||
{bmX,bmY} = {dw,dh}
|
||||
end if
|
||||
elsif msg=WM_PAINT then
|
||||
-- start with a fresh copy of the background
|
||||
void = c_func(xBitBlt,{viewDC,0,0,dw,dh,backDC,0,0,SRCCOPY})
|
||||
farthest = 0.0 -- find the farthest vertex
|
||||
for i=1 to 8 do
|
||||
if z[i]>farthest then farthest = z[i] farv = i end if
|
||||
end for
|
||||
for v=1 to 2*12 by 2 do -- for all the vertices...
|
||||
v1 = Segment[v] -- get vertex number
|
||||
v2 = Segment[v+1]
|
||||
c = Red; setPenStyle(Solid)
|
||||
if v1=farv or v2=farv then c=Blue; setPenStyle(Dash) end if
|
||||
drawLinesh(viewDC,{c,{x[v1]*Size+dw/2, y[v1]*Size+dh/2,
|
||||
x[v2]*Size+dw/2, y[v2]*Size+dh/2}})
|
||||
end for
|
||||
void = c_func(xBitBlt,{mainDC,0,0,dw,dh,viewDC,0,0,SRCCOPY})
|
||||
elsif msg=WM_TIMER then
|
||||
for i=1 to 8 do
|
||||
x[i] = x[i]+y[i]*Sz -- rotate vertices in X-Y plane
|
||||
y[i] = y[i]-x[i]*Sz
|
||||
y[i] = y[i]+z[i]*Sx -- rotate vertices in Y-Z plane
|
||||
z[i] = z[i]-y[i]*Sx
|
||||
end for
|
||||
repaintWindow(main)
|
||||
elsif msg=WM_SHOWWINDOW then
|
||||
startTimer(MainTimer,main,33)
|
||||
elsif msg=WM_CHAR
|
||||
and wParam=VK_ESCAPE then
|
||||
closeWindow(main)
|
||||
if id or object(lParam) then end if -- suppress warnings
|
||||
end if
|
||||
return 0
|
||||
end function
|
||||
setHandler({main},routine_id("mainHandler"))
|
||||
|
||||
WinMain(main, SW_NORMAL)
|
||||
Loading…
Add table
Add a link
Reference in a new issue