Computer Science Canada

Paint Program Question

Author:  uberwalla [ Wed Dec 13, 2006 4:42 pm ]
Post subject:  Paint Program Question

ok so im making a paint program and im having a few problems.

here is the code:
Turing:

View.Set ("offscreenonly;nobuttonbar")
var keys : array char of boolean
var x, y, x2, y2, b, pic : int
var select : int := 1
loop
    Input.KeyDown (keys)

    if keys ('1') then
        select := 1
    elsif keys ('2') then
        select := 2
    elsif keys ('3') then
        select := 3
    elsif keys ('4') then
        select := 4
    end if

    if select = 1 then
        %%%%Rectangle Begins%%%%
        mousewhere (x, y, b)
        if b = 1 then
            pic := Pic.New (0, 0, maxx, maxy)
            loop
                mousewhere (x2, y2, b)
                Pic.Draw (pic, 0, 0, picCopy)
                drawbox (x, y, x2, y2, black)
                exit when b not= 1
                View.Update
            end loop
            Pic.Free (pic)
        end if
        View.Update

    elsif select = 2 then
        %%%%Line Begins%%%%
        mousewhere (x, y, b)
        if b = 1 then
            pic := Pic.New (0, 0, maxx, maxy)
            loop
                mousewhere (x2, y2, b)
                Pic.Draw (pic, 0, 0, picCopy)
                drawline (x, y, x2, y2, black)
                exit when b not= 1
                View.Update
            end loop
            Pic.Free (pic)
        end if
        View.Update

    elsif select = 3 then
        %%%%Cicle Begins%%%%
        mousewhere (x, y, b)
        if b = 1 then
            pic := Pic.New (0, 0, maxx, maxy)
            loop
                mousewhere (x2, y2, b)
                Pic.Draw (pic, 0, 0, picCopy)
                drawoval (x, y, x2, y2, black)
                exit when b not= 1
                View.Update
            end loop
            Pic.Free (pic)
        end if
        View.Update

    elsif select = 4 then
        %%%%Pencil Begins%%%%
        Mouse.Where (x2, y2, b)
        if b = 1 then
            drawdot (x, y, black)
            drawline (x, y, x2, y2, black)
        end if
        x := x2
        y := y2
    end if
end loop


the problem is that the pencil does not draw the stuff. it does if you put it in its own program. and it works if u draw with it then press the 'x' (close) for the window. Confused

any suggestions?

also i was wondering if there is a way in turing to use the mouse scroll button. not pressing it but actually scrolling. so if u scroll fowards it could move a variable up and if u scroll back then decrease it. possible?

thx in advance.

Author:  McKenzie [ Wed Dec 13, 2006 8:54 pm ]
Post subject: 

Because you are drawing offscreenonly your pencil will not show up until you View.Update. I would suggest a re-organization of your code as well to reduce the redundancy. Stop by and see me some time soon (if you are from Massey.)

Mouse wheel, out of luck.

Author:  Wing_Wing [ Thu Dec 14, 2006 8:43 pm ]
Post subject: 

Oww seeing that the previous post was from my compsci teacher at school... o_0 ... you have View.Updates for your other tools but not your pencil... o_0

Author:  uberwalla [ Thu Dec 14, 2006 9:08 pm ]
Post subject: 

i just didnt find it was necessary. i tried it with and without and it didnt make a big diff.

Author:  Hackmaster [ Thu Dec 14, 2006 9:18 pm ]
Post subject: 

you also have another, much easier option.

GUI!!!

GUI has an object that you can create called a canvas. it is ridiculasly easy to use... I'm not sure what commands you have to use, but Turing Help has the syntax. also, you can use buttons, and clean up the appearence in general.

Author:  uberwalla [ Thu Dec 14, 2006 9:22 pm ]
Post subject: 

o i know man Razz never said this was finished or what not Smile

this is just my testing of the tools themselves then i will polish it up after. right now im trying to make a eye dropper and spray paint tool.

Author:  Hackmaster [ Fri Dec 15, 2006 7:35 pm ]
Post subject: 

Well, I'm just saying, it is SOOOO much easier to use a canvas here. seriously. you can do spraypaint, and all sorts of fun things. bigger brush sizes, different line segments, and of course, you can have color buttons that change the color of your drawing at any time, really, really easy.

if you don't know how, I cuold tell you, or I suppose you could look it up. there are lots of tuts and help subjects on them, I think.

Author:  McKenzie [ Sat Dec 16, 2006 9:36 pm ]
Post subject: 

There is a good chance uberwalla is not looking for a "really really easy" solution. Chances are he wants to really really understand what he's doing. My experience with students who use GUI before they have a solid grasp of the basics is that they tend not to get a real solid grasp of the basics.

Author:  uberwalla [ Sat Dec 16, 2006 10:28 pm ]
Post subject: 

lol you guys are funny...

i know what gui is and im sure i could use it... but as i said before i am just making my tools work so far then im going to incorperate them in GUI or whatever style I decide to use. i always go one sstep at a time. Smile

Author:  ericfourfour [ Sat Dec 16, 2006 10:36 pm ]
Post subject: 

Don't use Holt Software's GUI for Turing. It is so slow. Sad

Make your own. It will give you experience in many concepts (mainly OOP). Smile


: