PDA

View Full Version : Api Update



peter
22-02-2014, 02:37
Hello,

once again api.inc
open a canvas_window is easier now.

we have now:
OpenWindow( width, height )
Drawline( x1, y1, x2, y2, color )

examples:


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

OpenWindow 640, 480
Canvas_Font "arial",14, %CANVAS_FONTSTYLE_NORMAL

Single angle, cx, cy, r, na
Long i, x, y
angle=1 : cx=320 : cy=240 : r=50

Canvas_Clear 0
Canvas_Redraw

For i=0 To 20100
r=Sin(angle/100) * 200
na=((r*2*Pi)/3600) * angle
x =(Cos(na / r)*r)+cx
y =(Sin(na / r)*r)+cy
DrawPoint x,y, 4, Rgb 255,255,150
DrawPoint x,y, 2, Rgb 255,255,255
angle += .5
Next
DrawText 256,0,"Easter Flower", &HFFFFFF
Canvas_Redraw

While IsWindow(hwnd) And KeyDown(27)=0
Sleep 10
Wend
Canvas_Window End hwnd




Uses "ui"
#INCLUDE "api.inc"

OpenWindow 220, 200
Canvas_Font "arial",16, %CANVAS_FONTSTYLE_NORMAL
Randomize

Long i
Canvas_Clear &HF0C0C0
canvas_redraw

For i=1 To 12
DrawLine 10,i*15,220,i*15, Rnd(255,16777215)
Next

Canvas_Redraw
While IsWindow(hwnd) And KeyDown(27)=0
Sleep 10
Wend
Canvas_Window End hwnd

peter
22-02-2014, 02:40
Nice Mandelbrot.



Uses "ui"
#INCLUDE "api.inc"

OpenWindow 400, 300

Single cRe,cIm,newRe,newIm,oldRe,oldIm,z,moveX,moveY
Long iMax,x,y,i,a

cRe = -0.8 : cIm = 0.27015 : z=1
iMax=256

For x=0 To 400
For y=0 To 300
newRe = 1.8 * (x-400*.5) / (.5*z*400) + moveX
newIm = (y-300*.5) / (.5*z*300) + moveY
For i=0 To iMax
oldRe = newRe
oldIm = newIm
newRe = oldRe * oldRe - oldIm * oldIm +cRe
newIm = 2 * oldRe * oldIm + cIm
If((newRe * newRe + newIm * newIm) >5) Then Exit For
Next
Canvas_SetPixel x, y, i*45 + i*256 + (i*45)*65536
Next
Next
Canvas_Redraw

While IsWindow(hwnd) And KeyDown(27)=0
Sleep 10
Wend
Canvas_Window End hwnd