Results 1 to 2 of 2

Thread: Canvas Fun

  1. #1
    Member
    Join Date
    Sep 2008
    Location
    Germany
    Posts
    406
    Rep Power
    50

    Canvas Fun

    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
    

  2. #2
    Member
    Join Date
    Sep 2008
    Location
    Germany
    Posts
    406
    Rep Power
    50
    Is okay, I found it.
    Last edited by peter; 18-11-2013 at 22:57.

Similar Threads

  1. moving canvas box
    By largo_winch in forum UI (User Interface)
    Replies: 4
    Last Post: 19-12-2011, 18:34
  2. math Art using the Canvas
    By zak in forum UI (User Interface)
    Replies: 5
    Last Post: 25-07-2011, 17:18
  3. Replies: 6
    Last Post: 16-06-2010, 06:40
  4. canvas example :)
    By lydia_sp in forum UI (User Interface)
    Replies: 1
    Last Post: 16-09-2009, 17:19

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •