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

Username:   Password: 
 RegisterRegister   
 Drawing Pad!!!! (this is just an executable)
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
xHoly-Divinity




PostPosted: Wed Jan 12, 2005 6:10 pm   Post subject: Drawing Pad!!!! (this is just an executable)

Hey check this out, it took me about 3 hours to make its only about 350 lines so its not that bad. Plz gimme some feedback (P.S. there are a lot of glitches, ones I have not gotten around to fixing yet)
Sponsor
Sponsor
Sponsor
sponsor
xHoly-Divinity




PostPosted: Wed Jan 12, 2005 6:14 pm   Post subject: (No subject)

Sorry, file didn't attatch properly
xHoly-Divinity




PostPosted: Wed Jan 12, 2005 6:16 pm   Post subject: (No subject)

Why does attatch not work!!!??? I click on 'Add an Attatchment' then browse, and attatch. Then I klick 'submit.'
xHoly-Divinity




PostPosted: Wed Jan 12, 2005 6:18 pm   Post subject: (No subject)

screw it, herez the code.

code:

put ""
put "Welcome to Ivan Drawing Pad", skip, skip
put "Note some features:"
put "  1) Click on the tool that you wish to use"
put "  2) When you are done with the tool, press 'End' and select a new tool"
put "  3) Select a colour on the bottom of the screen"
put "  4) You can only use the fill bucket in other colours"
put "  5) No, there is NOT an undo button. I am a programmer, not a genius"
put "  6) Are there glitches? Of course! Nothing is perfect and I haven't the time to     fix them"
put "  8) Enjoy", skip, skip
put "Creator: Ivan Cajic"
put "Course: TIK 20O"
put "Teacher: Mr. Jone"
put "Date: January 12, 2005"
var continue : string (1)
locatexy (10, 10)
put "Press any key to continue"
locatexy (220, 20)
getch (continue)
cls
var x2, y2, button2, xx2, yy2, button3, x, y, button : int
Draw.ThickLine (20, 100, 20, 350, 5, black)
Draw.ThickLine (20, 350, 70, 350, 5, black)
Draw.ThickLine (70, 350, 70, 100, 5, black)
Draw.ThickLine (20, 100, 70, 100, 5, black)
drawfill (30, 340, 23, black)

proc pencil (x, y : int)
    drawfillbox (25, 346, 41, 325, 103)
    drawfillbox (30 + x, 340 + y, 36 + x, 345 + y, 90)
    drawbox (30 + x, 340 + y, 36 + x, 345 + y, black)
    drawfillbox (30 + x, 340 + y, 36 + x, 330 + y, yellow)
    drawbox (30 + x, 340 + y, 36 + x, 330 + y, black)
    drawline (30 + x, 330 + y, 33 + x, 325 + y, black)
    drawline (36 + x, 330 + y, 33 + x, 325 + y, black)
    drawfill (34 + x, 328 + y, 43, black)
    Draw.ThickLine (32 + x, 326 + y, 34 + x, 326 + y, 2, black)
end pencil

proc bucket
    drawfillbox (45, 325, 64, 346, 103)
    drawline (50, 335, 58, 340, black)
    drawline (58, 340, 64, 332, black)
    drawline (64, 332, 56, 326, black)
    drawline (56, 326, 50, 335, black)
    drawfill (60, 330, 3, black)
    drawarc (52, 330, 4, 10, 40, 180, black)
    drawarc (50, 330, 2, 10, 10, 190, black)
    drawfill (53, 338, black, black)
    Draw.ThickLine (54, 330, 61, 334, 3, black)
    drawline (51, 332, 60, 338, black)
end bucket

proc brush
    drawfillbox (25, 315, 41, 294, 103)
    drawarc (32, 305, 3, 11, 0, 185, black)
    drawfillbox (27, 307, 37, 303, 6)
    drawbox (27, 307, 37, 303, black)
    drawfillbox (27, 302, 37, 296, white)
    drawbox (27, 302, 37, 296, black)
    drawline (29, 296, 29, 301, black)
    drawline (32, 296, 32, 300, black)
    drawline (35, 296, 35, 300, black)
    drawfill (32, 313, 6, black)
    drawline (35, 307, 29, 307, 6)
end brush

proc erase
    drawfillbox (45, 315, 64, 294, 103)
    drawfillbox (47, 295, 58, 299, 92)
    drawbox (47, 295, 58, 299, black)
    drawline (47, 299, 53, 308, black)
    drawline (53, 308, 62, 308, black)
    drawline (58, 299, 62, 308, black)
    drawline (62, 308, 62, 302, black)
    drawline (62, 302, 58, 295, black)
    drawfill (53, 303, 93, black)
    drawfill (60, 301, 93, black)
end erase

proc can
    drawfillbox (25, 284, 41, 263, 103)
    drawline (40, 268, 33, 278, black)
    drawline (40, 268, 34, 264, black)
    drawline (33, 278, 27, 274, black)
    drawline (27, 274, 34, 264, black)
    drawfillarc (30, 276, 4, 5, 30, 290, white)
    drawarc (30, 276, 4, 5, 30, 290, black)
    drawfill (34, 270, brightblue, black)
    Draw.ThickLine (26, 280, 30, 279, 2, black)
    drawdot (39, 282, black)
    drawdot (37, 280, black)
    drawdot (35, 278, black)
    drawdot (35, 282, black)
    drawdot (35, 278, black)
    drawdot (39, 278, black)
end can

proc line
    drawfillbox (45, 284, 64, 263, 103)
    Draw.ThickLine (47, 266, 62, 281, 2, black)
end line

proc oval
    drawfillbox (25, 253, 41, 232, 103)
    drawoval (33, 242, 7, 7, black)
    drawoval (33, 241, 7, 7, black)
end oval

proc square
    drawfillbox (45, 253, 64, 232, 103)
    drawbox (48, 250, 61, 235, black)
    drawbox (47, 249, 60, 236, black)
end square

square
oval
line
can
erase
brush
pencil (0, 0)
bucket
var xx, yy : int
var col : int := 2
var a, b : int := 10
drawfillbox (25, 200, 64, 220, 103)
Draw.Text ("End", 30, 210, defFontID, black)
drawbox (25, 5, 525, 40, black)
drawbox (85, 55, maxx - 15, maxy - 15, black)
drawfill (1, 1, grey, black)
colourback (grey)
put "Press 'c' to clear and 'q' to quit"
drawbox (85, 55, maxx - 15, maxy - 15, black)
for i : 0 .. 15
    a := a + 30
    drawfillbox (a, b, a + 20, b + 20, i)
    drawbox (a, b, a + 20, b + 20, black)
end for

loop
    var chars : array char of boolean
    Input.KeyDown (chars)
    if chars ('c') then
        drawfillbox (85 + 1, 55 + 1, maxx - 16, maxy - 16, white)
    elsif chars ('q') then
        return
    end if
    mousewhere (x, y, button)
    if x > 45 and x < 64 and y < 252 and y > 232 and button = 1 then
        var xw, yw, xxw, yyw, b1w, b2w : int := 0
        loop
            mousewhere (xw, yw, b1w)
            if b1w = 1 then
                loop
                    mousewhere (xxw, yyw, b2w)
                    if b2w = 1 and yyw > 65 and xxw > 95 and xxw < maxx - 25 and yyw < maxy - 25 then
                        drawbox (xw, yw, xxw, yyw, black)
                    end if
                    if b2w not= 1 then
                        drawbox (xw, yw, xxw, yyw, black)
                        exit
                    end if
                    if yyw > 65 and xxw > 95 and xxw < maxx - 25 and yyw < maxy - 25 then
                        drawbox (xw, yw, xxw, yyw, white)
                    end if
                end loop
            end if
            exit when xw > 25 and yw > 200 and xw < 64 and yw < 220 and b1w = 1
        end loop
    end if
    if x > 25 and x < 41 and y < 252 and y > 232 and button = 1 then
        var xa, ya, xxa, yya, b1a, b2a : int
        loop
            mousewhere (xa, ya, b1a)
            if b1a = 1 and ya > 65 and xa > 95 and xa < maxx - 25 and ya < maxy - 25 then
                mousewhere (xa, ya, b1a)
                drawdot (xa, ya, black)
                loop
                    mousewhere (xxa, yya, b2a)
                    if b2a = 1 and yya > 65 and xxa > 95 and xxa < maxx - 25 and yya < maxy - 25 then
                        drawoval (xa, ya, xxa - xa, yya - ya, black)
                    end if
                    if b2a not= 1 then
                        drawoval (xa, ya, xxa - xa, yya - ya, black)
                        exit
                    end if
                    if yya > 65 and xxa > 95 and xxa < maxx - 25 and yya < maxy - 25 then
                        drawoval (xa, ya, xxa - xa, yya - ya, white)
                    end if
                end loop
            end if
            exit when xa > 25 and ya > 200 and xa < 64 and ya < 220 and b1a = 1
        end loop
    end if
    if x > 45 and x < 64 and y > 263 and y < 284 and button = 1 then
        var xe, ye, btnNumber, btnUpDown, buttons : int
        var nx, ny : int
        loop
            Mouse.ButtonWait ("down", xe, ye, btnNumber, btnUpDown)
            nx := xe
            ny := ye
            loop
                if nx > 65 and ny > 95 and nx < maxx - 25 and ny < maxy - 25 then
                    Draw.Line (xe, ye, nx, ny, 0)
                end if
                exit when Mouse.ButtonMoved ("up")
                Mouse.Where (nx, ny, buttons)
                if nx > 65 and ny > 95 and nx < maxx - 25 and ny < maxy - 25 then
                    Draw.Line (xe, ye, nx, ny, black)
                end if
            end loop
            if nx > 65 and ny > 95 and nx < maxx - 25 and ny < maxy - 25 then
                Draw.Line (xe, ye, nx, ny, black)
            end if
            exit when xe > 25 and ye > 200 and xe < 64 and ye < 220 and button = 1
        end loop
    end if
    if x < 41 and x > 25 and y < 284 and y > 263 and button = 1 then
        loop
            mousewhere (x, y, button)
            if y > 65 and x > 95 and x < maxx - 25 and y < maxy - 25 and button = 1 then
                for i : 1 .. 3
                    randint (xx, x - 12, x + 12)
                    randint (yy, y - 12, y + 12)
                    drawdot (xx, yy, black)
                end for
                delay (1)
            end if
            exit when x > 25 and y > 200 and x < 64 and y < 220 and button = 1
        end loop
    end if
    if x < 64 and x > 45 and y < 315 and y > 294 and button = 1 then
        loop
            Input.KeyDown (chars)
            if chars ('c') then
                drawfillbox (85 + 1, 55 + 1, maxx - 16, maxy - 16, white)
            end if
            mousewhere (x, y, button)
            if y > 65 and x > 95 and x < maxx - 25 and y < maxy - 25 then
                drawbox (x - 10, y - 10, x + 10, y + 10, black)
                delay (50)
                drawbox (x - 10, y - 10, x + 10, y + 10, white)
            end if
            if y > 65 and x > 95 and x < maxx - 25 and y < maxy - 25 and button = 1 then
                drawfillbox (x - 10, y - 10, x + 10, y + 10, white)
            end if
            exit when x > 25 and y > 200 and x < 64 and y < 220
        end loop
    end if

    if x < 41 and x > 25 and y < 346 and y > 325 and button = 1 then
        loop
            Input.KeyDown (chars)
            if chars ('c') then
                drawfillbox (85 + 1, 55 + 1, maxx - 16, maxy - 16, white)
            end if
            mousewhere (x2, y2, button2)
            if y2 > 65 and x2 > 95 and x2 < maxx - 15 and y2 < maxy - 15 and button2 = 1 then
                delay (30)
                mousewhere (xx2, yy2, button3)
                drawline (x2, y2, xx2, yy2, black)
            end if
            exit when x2 > 25 and y2 > 200 and x2 < 64 and y2 < 220
                and button2 = 1
        end loop
    end if
    if x < 41 and x > 25 and y < 315 and y > 294 and button = 1 then
        loop
            Input.KeyDown (chars)
            if chars ('c') then
                drawfillbox (85 + 1, 55 + 1, maxx - 16, maxy - 16, white)
            end if
            mousewhere (x2, y2, button2)
            if y2 > 65 and x2 > 95 and x2 < maxx - 15 and y2 < maxy - 15 and button2 = 1 then
                delay (30)
                mousewhere (xx2, yy2, button3)
                Draw.ThickLine (x2, y2, xx2, yy2, 3, black)
            end if
            exit when x2 > 25 and y2 > 200 and x2 < 64 and y2 < 220
                and button2 = 1
        end loop
    end if
    if x > 45 and x < 64 and y > 325 and y < 346 and button = 1 then
        loop
            Input.KeyDown (chars)
            if chars ('c') then
                drawfillbox (85 + 1, 55 + 1, maxx - 16, maxy - 16, white)
            end if
            mousewhere (x, y, button)
            if button = 1 and y > 65 and x > 95 and x < maxx - 15 and y < maxy - 15 then
                drawfill (x, y, col, black)
            end if
            if button = 1 then
                if whatdotcolour (x, y) = 0 then
                    col := 0
                elsif whatdotcolour (x, y) = 1 then
                    col := 1
                elsif whatdotcolour (x, y) = 2 then
                    col := 2
                elsif whatdotcolour (x, y) = 3 then
                    col := 3
                elsif whatdotcolour (x, y) = 4 then
                    col := 4
                elsif whatdotcolour (x, y) = 5 then
                    col := 5
                elsif whatdotcolour (x, y) = 6 then
                    col := 6
                elsif whatdotcolour (x, y) = 7 then
                    col := 7
                elsif whatdotcolour (x, y) = 8 then
                    col := 8
                elsif whatdotcolour (x, y) = 9 then
                    col := 9
                elsif whatdotcolour (x, y) = 10 then
                    col := 10
                elsif whatdotcolour (x, y) = 11 then
                    col := 11
                elsif whatdotcolour (x, y) = 12 then
                    col := 12
                elsif whatdotcolour (x, y) = 13 then
                    col := 13
                elsif whatdotcolour (x, y) = 14 then
                    col := 14
                elsif whatdotcolour (x, y) = 15 then
                    col := 15
                end if
            end if
            exit when x > 25 and y > 200 and x < 64 and y < 220
        end loop
    end if
    if button = 1 then
        if whatdotcolour (x, y) = 0 then
            col := 0
        elsif whatdotcolour (x, y) = 1 then
            col := 1
        elsif whatdotcolour (x, y) = 2 then
            col := 2
        elsif whatdotcolour (x, y) = 3 then
            col := 3
        elsif whatdotcolour (x, y) = 4 then
            col := 4
        elsif whatdotcolour (x, y) = 5 then
            col := 5
        elsif whatdotcolour (x, y) = 6 then
            col := 6
        elsif whatdotcolour (x, y) = 7 then
            col := 7
        elsif whatdotcolour (x, y) = 8 then
            col := 8
        elsif whatdotcolour (x, y) = 9 then
            col := 9
        elsif whatdotcolour (x, y) = 10 then
            col := 10
        elsif whatdotcolour (x, y) = 11 then
            col := 11
        elsif whatdotcolour (x, y) = 12 then
            col := 12
        elsif whatdotcolour (x, y) = 13 then
            col := 13
        elsif whatdotcolour (x, y) = 14 then
            col := 14
        elsif whatdotcolour (x, y) = 15 then
            col := 15
        end if
    end if
end loop

[Gandalf]




PostPosted: Wed Jan 12, 2005 6:41 pm   Post subject: (No subject)

Very nice program, nicer than I expected.
As expected thought, there are some bugs:
-You can draw outside the box (bad especially when using the fill tool).
-When you clear the screen and you have something outside the box, that part does not clear.
-Some of the colours don't work.

It would be nice to have a save, and load feature too. An 'undo' would always be nice Smile . Also, if you made the GUI a bit easier to understand, and (if possible) take out the need for the 'end' button.


If you could do all that, you would have an almost perfect program! Very good idea for a program, too.

I didn't really take a good look at the source, either.
Neo




PostPosted: Wed Jan 12, 2005 7:17 pm   Post subject: (No subject)

xHoly-Divinity wrote:
Why does attatch not work!!!??? I click on 'Add an Attatchment' then browse, and attatch. Then I klick 'submit.'


I dont know but could it be because this is the Turing Help section?
Your code could really be shortened, for instance
code:

           if button = 1 then
                if whatdotcolour (x, y) = 0 then
                    col := 0
                elsif whatdotcolour (x, y) = 1 then
                    col := 1
                elsif whatdotcolour (x, y) = 2 then
                    col := 2
                          .............................................
                          .............................................


can become,

code:

if button = 1 then
    for i : 1 .. 15
        if whatdotcolour (x, y) = i then
            col := i
        end if
    end for
end if
MihaiG




PostPosted: Wed Jan 12, 2005 7:18 pm   Post subject: (No subject)

as a little suggestion try this for better borders... this will allow no change outside those parametres



Description The View.ClipSet procedure sets the clipping region to the rectangle specified by (x1, y1) - (x2, y2). If a clipping region already exist, it is replaced by the specified rectangle.
A clipping region is the region in which the output will appear. If the rectangle is specified as the clipping region, any drawing done outside the rectangle will not appear.

To set the initial clipping, or remove the old region and replace it with a new one, use View.ClipSet. To set the clipping region back to the entire screen or window, use View.ClipOff.

These commands only work in "graphics" mode.


View.ClipSet (x1, y1, x2, y2 : int) this will improve because when drawing circles they redraw over borders and you can't see

goo job for saving ... you cant really make saving specif file names but ypu can make save as a default name and make the person change it is i.e


Pic.ScreenSave (x1,y1,x2,y2 : int,filename : string)
[Gandalf]




PostPosted: Wed Jan 12, 2005 7:32 pm   Post subject: (No subject)

Ya, I guess if you really wanted to save something (without changing the code) you could always use the "save" button in the Turing tool bar.

Is it just me, or do colours only work for the fill tool?
Sponsor
Sponsor
Sponsor
sponsor
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  [ 8 Posts ]
Jump to:   


Style:  
Search: