PDA

View Full Version : Api Update



peter
19-02-2014, 16:18
Hi,


New api.inc.


New elements are:


GetR(color)
GetG(color)
GetB(color)


Music and Sound are now also possible.


Examples:


Uses "ui"
#INCLUDE "api.inc"


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


Dim ic1,ic2 As Long
Dim c, k As DWord
Dim r,g,b As Byte

ic1 = LoadIcon "icon/bild3.ico"
ic2 = LoadIcon "icon/shoot.ico"


While IsWindow(hwnd) And Keydown(%VK_ESCAPE)=0
DrawIcon hdc,ic1,0,0,640,480,0
DrawIcon hdc,ic2,256,300,128,128,0

c = Canvas_GetPixel 320,384
r = GetR(c)
g = GetG(c)
b = GetB(c)
Canvas_Ellipse 200,200,80+200,60+200, Rgb(r,g,b),-1

DrawText 10,72,"Color c Components",Rgb(255,255,255)
DrawText 10,10,"RED " & r, Rgb(255,255,255)
DrawText 10,26,"GREEN " & g, Rgb(255,255,255)
DrawText 10,42,"BLUE " & b, Rgb(255,255,255)

k = Canvas_GetPixel 320,360
r = GetR(k)
g = GetG(k)
b = GetB(k)
Canvas_Ellipse 380,200,80+380,60+200, Rgb(r,g,b),-1

DrawText 300,72,"Color k Components",Rgb(255,255,255)
DrawText 300,10,"RED " & r, Rgb(255,255,255)
DrawText 300,26,"GREEN " & g, Rgb(255,255,255)
DrawText 300,42,"BLUE " & b, Rgb(255,255,255)

Canvas_Redraw
Sleep 10

Wend
Canvas_Window End




Uses "ui"
#INCLUDE "api.inc"
#INCLUDE "bass.inc"


DWord hdc, hwnd
hwnd=Canvas_Window("Music",100,100,640,480)
Canvas_Attach(hwnd,0,%TRUE)
Canvas_Font("verdana",16,%CANVAS_FONTSTYLE_BOLD)


Canvas_Clear(Rgb(0,0,255))
InitBass()


Long music = LoadMusic("music/g.mod")
PlayMusic(music)


DrawText 176,100,"Playing Skogens Djur",&hFFFFFF


Canvas_Redraw
Canvas_WaitKey
FreeBass
Canvas_Window End hwnd