PDA

View Full Version : Line Test



peter
21-02-2014, 01:45
Hi,

Canvas_Line test.
I am missing thickness for the line. But on the other hand, I think it won't much used.


Anyhow, here are some canvas - lines.


Uses "ui"
#INCLUDE "api.inc"


DWord hwnd, hdc
hwnd = Canvas_Window("api_app",xMid(640),yMid(480),640,480)
Canvas_Attach(hwnd,0,%TRUE)
hdc = Canvas_GetDC()
Canvas_Font "arial",16, %CANVAS_FONTSTYLE_BOLD


Long dir, x, y, love, col, j, fx
Single wz, r
love = LoadImage "bmp/jeses.bmp",2


While IsWindow(hwnd) And KeyDown(27)=0
Canvas_Clear 0
col = Rgb(Rnd(64,255),Rnd(64,255),Rnd(64,255))
For j=0 To 39
Canvas_Line((0,j*12), (640,480-j*12), col)
Canvas_Line((j*16,0), (640-j*16,480), col)
Next
DrawText 256,10,"NO JOKE!",&HFFFFFF
If dir=0 Then x +=1
If dir=1 Then x -=1
If x=380 Then dir=1
If x=0 Then dir=0
DrawImage love, x+Sin(r)*10,176+Cos(r)*8,256,128,fx

wz +=.1
If wz >=2 Then
wz=0
fx +=1
If fx=2 Then fx=0
End If

r +=.1
If r >=360 Then r=0
Canvas_Redraw
Sleep 10
Wend
FreeImages
Canvas_Window End

Petr Schreiber
22-02-2014, 22:57
Hi Peter,

thickness can be controlled via Canvas_Width parameter, as documented.
The value is in pixels.


Petr

peter
23-02-2014, 17:26
Thanks Petr.

Do you like my Ufo-Impulsion ?


Uses "ui","math"
#INCLUDE "api.inc"


Openwindow 640, 480


Long i, x, y, h, w
Single a


h = 640/2
w = 480/2


While IsWindow(hwnd) And KeyDown(27)=0
Canvas_Clear 0
For i=0 To 360 Step 8
DrawPoint(w+Sin(DegToRad(i+a))*60,h+Cos(DegToRad(i+a))*60,2, &HFFFFFF)
DrawPoint(w+Cos(DegToRad(i+a))*60,(h-120)+Sin(DegToRad(i+a))*60,2, &HFFFFFF)
DrawPoint(w+120+Cos(DegToRad(a-i))*60,h+Sin(DegToRad(a+i))*60,2, &HFFFFFF)
DrawPoint((w-120)+Sin(DegToRad(a-i))*60,(h-120)+Cos(DegToRad(a+i))*60,2, &HFFFFFF)
Next


a +=1
If a >=360 Then a =-a

Canvas_Redraw
Sleep 10
Wend


Canvas_Window End hwnd

Petr Schreiber
23-02-2014, 19:48
Yes,

runs great on Windows 8 :)


Petr