Looks great
Using this instead of Canvas_Circle:
... results in faster animation.Canvas_SetPixel(180+dx*2+Sin(m)*wAmp+1,120+cx*2,col)
Petr
Hi,
A little bit mirage.
Uses "ui" Declare Function GetPixel Lib "gdi32" Alias "GetPixel" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long Declare Function SetPixelV Lib "gdi32" Alias "SetPixelV" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal crColor As Long) As Long DWord hdc,hwin Long dx,cx,col Long buf(128,128) Single wAmp,wFreq,x,m wAmp=6:wfreq=.3 hwin=Canvas_Window("Canvas Test",1,1,640,480) Canvas_Attach(hwin,0,%TRUE) hdc=Canvas_GetDC() Canvas_Clear(Rgb(0,0,255)) Canvas_Font("georgia",24,%CANVAS_FONTSTYLE_BOLD) Canvas_BitmapRender("angel.bmp",0,0,128,128) For cx=1 To 128 For dx=1 To 128 buf(dx,cx)=GetPixel(hdc,dx,cx) Next Next While Not GetAsyncKeyState(27) Canvas_Clear(Rgb(0,0,0)) x -= .5 m = x For cx=1 To 128 m += wfreq For dx=1 To 128 col=buf(dx,cx) 'SetPixelV(hdc,180+dx*2+Sin(m)*wAmp+1,120+cx*2,col) Canvas_Circle(180+dx*2+Sin(m)*wAmp+1,120+cx*2,2,col) Next Next Canvas_Color(Rgb(255,255,255),0) Canvas_SetPos(160,10) Canvas_Print("MIRAGE ANGEL") Canvas_Redraw Wend Canvas_Window End
Looks great
Using this instead of Canvas_Circle:
... results in faster animation.Canvas_SetPixel(180+dx*2+Sin(m)*wAmp+1,120+cx*2,col)
Petr
Last edited by Petr Schreiber; 13-10-2012 at 09:35.
Learn 3D graphics with ThinBASIC, learn TBGL!
Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB
Thank you Petr,
There is a misterious thing here.
The help says:
nColor = Canvas_GetPixel(X1, Y1)
But here is it an unknown keyword, error code 18
I have no clue what this means!
http://www.thinbasic.com/community/p...d=361#note2265
Sorry peter, my mistake.
I wrongly internally called that keyword Canvas_Pixel instead of Canvas_GetPixel
Fix is already done but will be present in next thinBasic release.
If you want, you can use Canvas_Pixel but later it will be changed.
Sorry.
Eros
www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000
Thank you Eros,
Good to know that it is funktionale keyword.
I have some problems with the mouse handling. I found nothing over it.
I need Mousebuttons and mouse positions.
I am missing some Mathematics routines: ArcCos, ArcSin, Atan2 and so on.
And division by zero isn't intercepted here!
By the way, If I click on the windows (X-BOX) then I get an memory leak.
The application is still running in the background.
What I am doing wrong?
Regarding missing native math functions, please check MATH module
Than uses some of the additional math functions inside Math module:USES "MATH"
http://www.thinbasic.com/public/prod...tml?arccos.htm
On problem on exit, maybe the loop should be governed by a
orWhile IsWindow(hwin) ... Wend
While Not GetAsyncKeyState(27) and IsWindow(hwin) ... Wend
Basic Division by zero should be trapped. Have you an example?
www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000
Thank you Eros,
IsWindow(hwin) is okay.
Math is okay, need to try it yet.
Divison by zero was in an own ArcCos routine.
Function ArcCos( x as single) as single
Return Atn(-x / Sqr(-x*x+1))+2*Atn(1)
End Function
But isn't now necessary anymore!
What about the mouse?
Last edited by peter; 13-10-2012 at 19:08.
Handling mouse move over Canvas at the moment is not handled directly by thinBasic.
You need to create a standard window with a canvas control and that do the job inside window callback.
There are examples in thinBasic sample script installation and here in forum
http://www.thinbasic.com/community/s...t=canvas+mouse
http://www.thinbasic.com/community/s...t=click+figure
I will see what I can add for the future.
What mouse handling do you need to have?
www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000
Hi Eros,
I need all Mouse Button, the middle button isn't that important.
Further I need the x-postion of mouse and the y-position of mouse
I did a little experiment, but is not satisfying for me. I will try some other tricks.
Here is TBGL Circle Demo for CANVAS.Function xMouse() As Long Dim mRect As POINTAPI Win_GetCursorPos (mRect) Return mRect.x End Function Function yMouse() As Long Dim mRect As POINTAPI Win_GetCursorPos (mRect) Return mRect.y End Function
Uses "ui" DWord hdc,hwin hwin=Canvas_Window("Canvas Circle",1,1,640,480) Canvas_Attach(hwin,0,%TRUE) hdc=Canvas_GetDC() Canvas_Font("georgia",24,%CANVAS_FONTSTYLE_BOLD) Randomize() Long mx,my,c Dim cx(120),cy(120),cd(120) As Single Dim c1(120),c2(120),c3(120) As Byte For c=1 To 60 cx(c)=400 cy(c)=300 cd(c)=Rnd(1,8) c1(c)=Rgb(Rnd(64,255),Rnd(64,255),Rnd(32,255)) c2(c)=Rgb(Rnd(64,255),Rnd(64,255),Rnd(32,255)) c3(c)=Rgb(Rnd(64,255),Rnd(64,255),Rnd(32,255)) Next While IsWindow(hwin) Canvas_Clear(0) For c=1 To 60 If cd(c)=1 Then cx(c)=cx(c)+2 bound() ElseIf cd(c)=2 Then cx(c)=cx(c)-2 bound() ElseIf cd(c)=3 Then cy(c)=cy(c)-2 bound() ElseIf cd(c)=4 Then cy(c)=cy(c)+2 bound() ElseIf cd(c)=5 Then cy(c)=cy(c)-2 cx(c)=cx(c)-2 bound() ElseIf cd(c)=6 Then cy(c)=cy(c)-2 cx(c)=cx(c)+2 bound() ElseIf cd(c)=7 Then cy(c)=cy(c)+2 cx(c)=cx(c)-2 bound() ElseIf cd(c)=8 Then cy(c)=cy(c)+2 cx(c)=cx(c)+2 bound() End If Next circles() Canvas_Redraw If GetAsyncKeyState(27) Then Exit While Wend Canvas_Window End Sub circles() For c=1 To 60 Canvas_Circle(cx(c),cy(c),40,0,Rgb(c1(c),c2(c),c3(c))) Next End Sub Sub bound() Dim i As DWord For i=1 To 60 If cx(i) <=40 Then cd(i) = Rnd(1,8) cx(i) =40 End If If cx(i) >=600 Then cd(i) = Rnd(1,8) cx(i) =600 End If If cy(i) >=440 Then cd(i) = Rnd(1,8) cy(i) =440 End If If cy(i) <=40 Then cd(i) = Rnd(1,8) cy(i) =40 End If Next End Sub Function Key(xkey As Word) As Word Return GetAsyncKeyState(xkey) End Function
petr,
I forgot I already developed something. Check command:
lClick = Canvas_Window Click [hWnd] TO X, Y
Help can be found here: http://www.thinbasic.com/public/prod...ndow_click.htm
See if it can help.
www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000
Bookmarks