peter
18-11-2013, 16:03
Hi,
A little bit fun with Canvas.
Do not punish me, I am a newcomer to ThinBasic.
At first: Sun Wheel, second Color Plasma.
Uses "ui", "math"
DWord hdc
hdc=Canvas_Window("ThinBasic",0,0,1024,768)
Canvas_Attach(hdc,0,%TRUE)
Canvas_Font("arial",16,%CANVAS_FONTSTYLE_BOLD)
Long width, height, vcolor, i, ii
width = 512
height= 384
Sub VecColor(r As Long, g As Long, b As Long)
vColor = r+g*256+b*65536
End Sub
Sub vec(x As Single, y As Single, z As Single)
Single ps: Long sx, sy
If z > 0 Then Return
If z = 0 Then z = -0.01
ps = (1/z)*100
sx = x * ps + width
sy = y * ps + height
Canvas_SetPixel sx,sy, vColor
End Sub
Single a, d, r
a=1: d=1
While IsWindow(hdc)
Canvas_Clear 0
For i=1 To 1000
ii = i
VecColor 255,255,255
vec(Cos(DegToRad(ii*r))*10,Sin(DegToRad(ii*r))*10, -ii/a)
Next
Canvas_Redraw
If a <=20 And d=1 Then
a +=.1
Else
d=2
End If
If a >=.5 And d=2 Then
a -=.1
Else
d=1
End If
r +=.1
If r >=360 Then r =-r
Wend
Canvas_Window End
Uses "ui"
DWord hdc
hdc=Canvas_Window("ThinBasic",0,0,300,310)
Canvas_Attach(hdc,0,%TRUE)
Canvas_Font("verdana",16,%CANVAS_FONTSTYLE_BOLD)
Long m1,m2,m4,m11,m22,y,x,r,g,b
For y=0 To 399
m11= m11+1
m1 = m1 +9
m2 = m1
m22= m11
For x=0 To 399
m4 = m4 +19
m2 = m2 +15
m22= m22+1
r = Abs(Sin(m1/100)+Sin(m2/100)+Sin((m1+m4)/600))*(255/2)
g = Abs(Sin((m22)/50) + Sin(m11/100))*250
b = Abs(Sin(x*y/100000)*200)
Canvas_SetPixel(x,y, Rgb(r,g,b))
Next
Next
While IsWindow(hdc)
If GetAsyncKeyState(27) Then Exit While
Canvas_Redraw
Wend
Canvas_Window End
Sub SetText(x,y As Long, txt As String, bcolor,fcolor As Long)
Canvas_Color(bcolor,fcolor)
Canvas_SetPos(x, y)
Canvas_Print(txt)
End Sub
A little bit fun with Canvas.
Do not punish me, I am a newcomer to ThinBasic.
At first: Sun Wheel, second Color Plasma.
Uses "ui", "math"
DWord hdc
hdc=Canvas_Window("ThinBasic",0,0,1024,768)
Canvas_Attach(hdc,0,%TRUE)
Canvas_Font("arial",16,%CANVAS_FONTSTYLE_BOLD)
Long width, height, vcolor, i, ii
width = 512
height= 384
Sub VecColor(r As Long, g As Long, b As Long)
vColor = r+g*256+b*65536
End Sub
Sub vec(x As Single, y As Single, z As Single)
Single ps: Long sx, sy
If z > 0 Then Return
If z = 0 Then z = -0.01
ps = (1/z)*100
sx = x * ps + width
sy = y * ps + height
Canvas_SetPixel sx,sy, vColor
End Sub
Single a, d, r
a=1: d=1
While IsWindow(hdc)
Canvas_Clear 0
For i=1 To 1000
ii = i
VecColor 255,255,255
vec(Cos(DegToRad(ii*r))*10,Sin(DegToRad(ii*r))*10, -ii/a)
Next
Canvas_Redraw
If a <=20 And d=1 Then
a +=.1
Else
d=2
End If
If a >=.5 And d=2 Then
a -=.1
Else
d=1
End If
r +=.1
If r >=360 Then r =-r
Wend
Canvas_Window End
Uses "ui"
DWord hdc
hdc=Canvas_Window("ThinBasic",0,0,300,310)
Canvas_Attach(hdc,0,%TRUE)
Canvas_Font("verdana",16,%CANVAS_FONTSTYLE_BOLD)
Long m1,m2,m4,m11,m22,y,x,r,g,b
For y=0 To 399
m11= m11+1
m1 = m1 +9
m2 = m1
m22= m11
For x=0 To 399
m4 = m4 +19
m2 = m2 +15
m22= m22+1
r = Abs(Sin(m1/100)+Sin(m2/100)+Sin((m1+m4)/600))*(255/2)
g = Abs(Sin((m22)/50) + Sin(m11/100))*250
b = Abs(Sin(x*y/100000)*200)
Canvas_SetPixel(x,y, Rgb(r,g,b))
Next
Next
While IsWindow(hdc)
If GetAsyncKeyState(27) Then Exit While
Canvas_Redraw
Wend
Canvas_Window End
Sub SetText(x,y As Long, txt As String, bcolor,fcolor As Long)
Canvas_Color(bcolor,fcolor)
Canvas_SetPos(x, y)
Canvas_Print(txt)
End Sub