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

Username:   Password: 
 RegisterRegister   
 PaintBrush Program
Index -> Programming, Turing -> Turing Submissions
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
nis




PostPosted: Sun Apr 06, 2003 11:12 pm   Post subject: PaintBrush Program

This is one of my first programs on turing and was made in the 16 bit so it can be improved but besides that it is pretty cool.

code:
var x, y, button : int
var size : int := 5
var col : int := 7

process menu

    loop
        drawbox (0, 280, 120, 310, 7)
        locate (11, 6)
        put "Clear"
        drawbox (0, 310, 120, 340, 7)
        locate (8, 2)
        put "Sizes (above) "
        drawbox (0, 0, maxx, maxy, 7)
        drawbox (0, 0, 120, maxy, 7)
        drawfillbox (1, 0, 119, 20, 7) %Black
        drawfillbox (1, 20, 119, 40, 15) %Dark Grey
        drawfillbox (1, 40, 119, 60, 8) %Grey
        drawfillbox (1, 60, 119, 80, 0) %White
        drawfillbox (1, 80, 119, 100, 1) %Blue
        drawfillbox (1, 100, 119, 120, 2) %Green
        drawfillbox (1, 120, 119, 140, 4) %Red
        drawfillbox (1, 140, 119, 160, 5) %purple
        drawfillbox (1, 160, 119, 180, 9) %light Blue
        drawfillbox (1, 180, 119, 200, 10) %light Green
        drawfillbox (1, 200, 119, 220, 12) %light Red
        drawfillbox (1, 220, 119, 240, 35) %light Purple
        drawfillbox (1, 240, 119, 260, 14) %Yellow
        drawfillbox (1, 260, 119, 280, 13) %Pink
        drawfilloval (5, maxy - 55, 2, 2, 7)
        drawfilloval (25, maxy - 55, 5, 5, 7)
        drawfilloval (50, maxy - 55, 10, 10, 7)
        drawfilloval (90, maxy - 55, 20, 20, 7)
        loop
            drawfillbox (0, maxy - 30, 120, maxy, col)

            Mouse.Where (x, y, button)
            if x > 0 and x < 120 and y < 20 and y > 0 and button = 1 then

                col := 7
            end if
            if x > 0 and x < 120 and y < 40 and y > 20 and
                    button = 1 then
                col := 15
            end if
            if x > 0 and x < 120 and y < 60 and y > 40 and
                    button = 1 then
                col := 8
            end if
            if x > 0 and x < 120 and y < 80 and y > 60 and
                    button = 1 then
                col := 0
            end if
            if x > 0 and x < 120 and y < 100 and y > 80 and
                    button = 1 then
                col := 1
            end if
            if x > 0 and x < 120 and y < 120 and y > 100 and
                    button = 1 then
                col := 2
            end if
            if x > 0 and x < 120 and y < 140 and y > 120 and
                    button = 1 then
                col := 4
            end if
            if x > 0 and x < 120 and y < 160 and y > 140 and
                    button = 1 then
                col := 5
            end if
            if x > 0 and x < 120 and y < 180 and y > 160 and
                    button = 1 then
                col := 9
            end if
            if x > 0 and x < 120 and y < 200 and y > 180 and
                    button = 1 then
                col := 10
            end if
            if x > 0 and x < 120 and y < 220 and y > 200 and
                    button = 1 then
                col := 12
            end if
            if x > 0 and x < 120 and y < 240 and y > 220 and
                    button = 1 then
                col := 35
            end if
            if x > 0 and x < 120 and y < 260 and y > 240 and
                    button = 1 then
                col := 14
            end if
            if x > 0 and x < 120 and y < 280 and y > 260 and
                    button = 1 then
                col := 13
            end if
            if x > 0 and x < 120 and y < 310 and y > 280 and
                    button = 1 then
                delay (100)
                cls

            end if
            if x > 0 and x < 120 and y < 340 and y > 310 and
                    button = 1 then
            end if
            if x < 7 and x > 3 and y < maxy - 53 and y > maxy - 57 and
                    button = 1 then
                size := 2
            end if
            if x < 30 and x > 20 and y < maxy - 50 and y > maxy - 60 and
                    button = 1 then
                size := 5
            end if
            if x < 60 and x > 40 and y < maxy - 45 and y > maxy - 65 and
                    button = 1 then
                size := 10
            end if
            if x < 110 and x > 70 and y < maxy - 35 and y > maxy - 75 and
                    button = 1 then
                size := 20
            end if
            exit when x < 120
        end loop
    end loop
end menu

process draw
    delay (100)
    loop
        if x > 120 + size and y > 0 and x < maxx and y < maxy then
            if button = 1 then
                drawfilloval (x, y, size, size, col)
            end if
        end if

    end loop
end draw

setscreen ("nocursor, noecho")
setscreen ("graphics : 900 ; 420")
fork menu
fork draw
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Sun Apr 06, 2003 11:30 pm   Post subject: (No subject)

thats preaty cool. If you ever deside to take it further (and you should) check out some of our paint programs coded in turing. (Picture 2 code and another one really good one)

as for the brush itself, you should fix it so that i dont get blanks if I move my mouse really fast Wink You can do that by taking two points and drawing a line using circles.

+10Bits though, some nice stuff for your first program
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Homer_simpson




PostPosted: Sun Apr 13, 2003 11:33 am   Post subject: (No subject)

it's good but it would be better if u could save your picture after your done.

code:
var picID : int
picID := Pic.New (x1, y1, x2, y2)
Pic.Save (picID, "filename.bmp")
Pic.Free (picID)


use these 4 simple lines and u can save your picture
FwuffyTheBunny




PostPosted: Mon Apr 14, 2003 11:51 am   Post subject: (No subject)

Hey i like the paintbrush program, but with the little brush work on getting it to be a line instead of a small oveal, that way it waont create just dots.
Viper




PostPosted: Mon Nov 22, 2004 1:45 pm   Post subject: (No subject)

for some reason this reminds me of mario paint lol Very Happy Very Happy
Display posts from previous:   
   Index -> Programming, Turing -> Turing Submissions
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 5 Posts ]
Jump to:   


Style:  
Search: