Results 1 to 2 of 2

Thread: canvas example :)

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1

    canvas example :)

    hello all.

    what the purpose do I have with canvas module ?

    my example I do it first time and wonder why I can use it if there are only a few commands for canvas module? Or I am understanding something wrong. it`s display beautiful things but like 2d pixel world

    [code=thinbasic]'' lydias canvas tb example

    uses "UI"

    ' -- ID numbers of controls
    Begin Const
    %cCanvasDB = %WM_USER + 500
    %btnClose
    %btnManipul

    %tAnimationTimer
    End Const

    dim smilegefix(225) as integer = 16711935,16711935,16711935,16711935,16766464,16766464,16766464,16760064,16760064,16711935,16711935,16711935,16711935,16711935,16711935,16711935,16711935,16766464,16766464,16766464,16766464,16766464,16766464,16760064,16760064,16755968,16711935,16711935,16711935,16711935,16711935,16766464,16766464,16772864,16772864,16772864,16766464,16766464,0,16760064,16755968,16753920,16711935,16711935,16711935,16711935,16766464,16772864,0,0,16772864,16772864,16766464,16766464,0,16760064,16755968,16711935,16711935,16711935,16766464,16766464,16772864,0,0,16772864,16772864,16766464,16766464,16760064,0,16755968,16751616,16711935,16711935,16766464,16766464,16772864,16772864,16772864,16772864,16772864,16766464,16766464,16760064,0,16755968,16751616,16711935,16711935,16766464,16766464,16766464,16772864,16772864,16772864,16766464,16766464,16760064,16760064,0,16753920,16751616,16711935,16711935,16760064,16766464,16766464,16766464,16766464,16766464,16766464,16766464,16760064,16760064,0,16753920,16751616,16711935,16711935,16760064,16760064,16760064,0,0,16766464,16760064,16760064,16760064,16755968,0,16751616,16751616,16711935,16711935,16711935,16760064,16760064,0,0,16760064,16760064,16760064,16755968,0,16753920,16751616,16711935,16711935,16711935,16711935,16755968,16755968,16760064,16760064,16760064,16755968,16755968,0,16753920,16751616,16751616,16711935,16711935,16711935,16711935,16711935,16753920,16755968,16755968,16755968,16753920,16753920,16751616,16751616,16751616,16711935,16711935,16711935,16711935,16711935,16711935,16711935,16711935,16751616,16751616,16751616,16751616,16751616,16711935,16711935,16711935,16711935,16711935,16711935,16711935,16711935,16711935,16711935,16711935,16711935,16711935,16711935,16711935,16711935,16711935,16711935,16711935,16711935,16711935,16711935,16711935,16711935,16711935,16711935,16711935,16711935,16711935,16711935,16711935,16711935,16711935,16711935,16711935,16711935
    dim n, k,z,x,y as integer

    ' -- Create dialog here
    FUNCTION TBMAIN()
    LOCAL hDlg AS DWORD

    DIALOG New 0, "lydias Canvas example in double buffermode",-1,-1, 296, 186, _
    %WS_POPUP Or %WS_VISIBLE Or _
    %WS_CLIPCHILDREN Or %WS_CAPTION OR _
    %WS_SYSMENU Or %WS_MINIMIZEBOX, 0 To hDlg

    ' -- Place controls here
    dim cx, cy as long
    dialog pixels hDlg, 200, 200 to units cx, cy
    CONTROL ADD CANVAS, hDlg, %cCanvasDB, "", -55+cx+65, 32, cx,cy
    CONTROL ADD LABEL, hDlg, -1, "Double cigarette buffer"+$CRLF+"(draws all at once, no flicker and braindamage at all)", 5+cx+5, 5, cx, 40

    CONTROL ADD BUTTON, hDlg, %btnClose, "Click to close", 10+cx, 44+cy, cx-6, 14, CALL btnCloseProc
    CONTROL ADD BUTTON, hDlg, %btnManipul, "don't manipulate me", -120+cx, -50+cy, cx-8, 18, CALL btnManipulate

    DIALOG SHOW MODAL hDlg, CALL dlgProc

    END FUNCTION

    ' -- Callback for dialog
    CALLBACK FUNCTION dlgProc()

    ' -- Test for messages
    SELECT CASE CBMSG

    CASE %WM_INITDIALOG
    ' -- Put code to be executed after dialog creation here
    DIALOG SET TIMER CBHNDL, %tAnimationTimer, 10, %NULL

    CASE %WM_TIMER
    DIM tx, ty as long

    Canvas_Attach(cbhndl, %cCanvasDB, %true)
    DrawGraphics()
    Canvas_Redraw ' -- Needs this to sync

    CASE %WM_CLOSE
    ' -- Put code to be executed before dialog end here

    END SELECT

    END FUNCTION

    ' -- Callback for close button
    CALLBACK FUNCTION btnCloseProc()

    IF CBMSG = %WM_COMMAND THEN
    IF CBCTLMSG = %BN_CLICKED THEN
    ' -- Closes the dialog
    DIALOG END CBHNDL
    END IF
    END IF

    END FUNCTION

    CALLBACK FUNCTION btnManipulate()
    IF CBMSG = %WM_COMMAND THEN
    IF CBCTLMSG = %BN_CLICKED THEN
    dim a,b,c as integer
    a = 100
    b = 200
    c= a*b-19999
    msgbox 0, "earth quake st. andreas ground"
    msgbox 0, "result: " + c
    END IF
    END IF

    END FUNCTION

    Type PolyPoint
    x as single
    x1 as single
    y as single
    y1 as single
    count as single
    End Type

    dim pp as PolyPoint

    Type PolyArray
    xy(500) as PolyPoint

    'pa.count = 4 '---Indicate you need 4 vertex
    'pa.xy(1).x = x1 '---X1
    'pa.xy(1).y = y1-150 '---Y1
    'pa.xy(2).x = x1+150 '---X2
    'pa.xy(2).y = y1 '---Y2
    'pa.xy(3).x = x1 '---X3
    'pa.xy(3).y = y1+150 '---Y3
    'pa.xy(4).x = x1-150 '---X4
    'pa.xy(4).y = y1 '---Y4

    End Type

    dim pa As PolyArray

    Canvas_setpos (step x+50,y+40)
    Canvas_Polygon pa, rgb(0,50,255), RGB(5,128,255),%Canvas_FillStyle_Solid


    SUB DrawGraphics()
    DIM tx, ty AS LONG


    tx = 100+cos(gettickcount/100)*10
    ty = 100+sin(gettickcount/100)*10

    canvas_COLOR rgb(128, 255, 0), RGB(0, 0, 0)
    Canvas_Clear(rgb(0,0,0))
    Canvas_Box(tx-50,ty-50,tx,ty, 0, rgb(255, 0, 0), rgb(255,128,0),%Canvas_FillStyle_DiagonalCrossedLines )
    canvas_print "Ciao maria "+STR$(rnd(1,256))
    canvas_Color( 10,180)
    canvas_print " a tutti fatale fame !"+STR$(rnd(1,256))

    for x as integer =1 to 40
    for y as integer = 1 to 55
    z=rnd(1,2)
    Canvas_Line ((10,10), (160, 160), rgb(55,255,0))
    Canvas_Line ((0,0), (200, 200), rgb(255,0,0))
    Canvas_Line ((200,0), (0, 200), rgb(255,0,0))

    Canvas_Line ((x+10,y+10), (10+z, smilegefix(225)), rgb(0,50,255))
    Canvas_SetPixel x+50,y+50, rgb(120,50,255)
    ''Canvas_BitmapGetFileInfo

    next
    next

    END SUB[/code]

    I saw some example and tried this one for myself. "canvas_polygon pa" doesn`t work cause I have to check UDT handling again !

    bye, lydia
    Attached Images Attached Images
    hasta la vida

Similar Threads

  1. Replies: 6
    Last Post: 16-06-2010, 06:40

Members who have read this thread: 0

There are no members to list at the moment.

Posting Permissions

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