Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Paint Program... cannot draw continuous line
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
eskalion




PostPosted: Thu Dec 11, 2008 11:14 am   Post subject: Paint Program... cannot draw continuous line

Here is my code for my Paint Program.

code:

setscreen ("graphics:max;max")

proc paint
    var x, y, button : int
    var xrdi, yrdi : int
    var xrdi2, yrdi2 : int

    var clrbr : int

    var keys : array char of boolean

    xrdi := 2
    yrdi := 3

    xrdi2 := 10
    yrdi2 := 10

    clrbr := 7

    loop
        if xrdi <= 0 then
            xrdi := 2
            yrdi := 3
        end if
       
            drawfilloval (20, 20, xrdi, yrdi, clrbr)
        Input.KeyDown (keys)

        if keys (KEY_UP_ARROW) then
            xrdi := xrdi + 4
            yrdi := yrdi + 4
            drawfilloval (20, 20, xrdi, yrdi, clrbr)
            delay (500)
        end if

        if keys (KEY_DOWN_ARROW) then
            drawfilloval (20, 20, xrdi, yrdi, white)
            xrdi := xrdi - 4
            yrdi := yrdi - 4
            drawfilloval (20, 20, xrdi, yrdi, clrbr)
            delay (500)
        end if

        if keys (KEY_DELETE) then
            delay (500)
            cls
        end if

        if keys (KEY_ENTER) then
            delay (500)
            exit
        end if

        Mouse.Where (x, y, button)
        Mouse.ButtonChoose ("multibutton")

        if button = 1 then
            drawfilloval (x, y, xrdi, yrdi, clrbr)
        end if

        if button = 10 then
            if clrbr <= 16 then
                clrbr := clrbr + 1
                drawfilloval (20, 20, xrdi, yrdi, clrbr)
                delay (500)
            else
                clrbr := 7
                drawfilloval (20, 20, xrdi, yrdi, clrbr)
                delay (500)
            end if
        end if


        if button = 100 then
            drawfilloval (x, y, xrdi2, yrdi2, white)
        end if

    end loop
end paint

put "TEST PAINT PROGRAM FOR E-CARD PROJECT"
put "Left Mouse Button - Draw"
put "Right Mouse Button - Erase"
put "Middle Mouse Button - Change Colour"
put "Up Arrow on Keyboard - Increase Brush Size"
put "Down Arrow on Keyboard - Decrase Brush Size"
put "Delete Key - Clears Screen"
put "Enter Key - Exits Program"
put ""
put "Note: Circle in bottom left corner tells you your brush size and colour."

delay (5000)
cls

paint



When I run the program and draw with the mouse too fast, there are blank spaces between the drawfillovals. I can't draw a continous "line" if I move my mouse too fast. Is there anyway to fix this?
Sponsor
Sponsor
Sponsor
sponsor
Insectoid




PostPosted: Thu Dec 11, 2008 2:03 pm   Post subject: RE:Paint Program... cannot draw continuous line

You should have it draw lines between the current coordinates and the past coordinates, rather than just a dot.

code:

Draw.Line (mouseX, mouseY, lastMouseX, lastMouseY, color)


this can be changed to Draw.ThickLine if you want.
eskalion




PostPosted: Thu Dec 11, 2008 10:01 pm   Post subject: Re: Paint Program... cannot draw continuous line

Wow! Thanks... It worked... sweet.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: