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

Username:   Password: 
 RegisterRegister   
 Yet another Paint Program...
Index -> Programming, Turing -> Turing Submissions
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Reality Check




PostPosted: Wed Jun 07, 2006 11:18 pm   Post subject: Yet another Paint Program...

I'm sorry to disturb you guys with another paint program (I've seen a lot of them here). Anyways, I was suppose to do a game for my ISU and while playing around one thing led to another and I got my teacher to let me do paint. I seen some of the other paints and their pretty good but I noticed most were slow. SO FAR, mine runs very smooth with no real problems. I have an idea of all the tools I will have and no how I'm making them: Fill, pencil (done), paint (almost done), eraser, spray drawcircle, drawstar (and all the other draw stuff), line segment tool, POSSIBLE move tool (have it working just a little buggy), MAYBE magnify tool (no idea how but I'll think about it), and any other things I can think of. I have most of my interface done and I will make the menu bar nicer. I will also include sizes for the brush tool and such. Give me any suggestions before I go further...

Now, I have but one question, I'd like to be able to 'preview' the shape before they draw it as in MS paint. If I simply draw and cls until they let go then their whole drawing will disappear.



ISU Paint.rar
 Description:

Download
 Filename:  ISU Paint.rar
 Filesize:  101.96 KB
 Downloaded:  204 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
Reality Check




PostPosted: Thu Jun 08, 2006 2:30 pm   Post subject: (No subject)

Sorry to double post but my whole thing is due Monday. I'm certain I can finish in time as I could probably write in a day (I already know exactly how each tool will be made) but I want to make sure everything A OK before I continue...and get the critique of awsome programmers.
Reality Check




PostPosted: Sat Jun 10, 2006 7:00 am   Post subject: (No subject)

14 people downloaded it and know one has given feedback yet...let me know if it does not work.
upthescale




PostPosted: Sat Jun 10, 2006 8:42 am   Post subject: (No subject)

Good job, less than 100 lines is pretty sweet, but one thing...

AVOID PROCESSES!!!!



Here is how you can make your code better WITHOUT processes, it is the same thing, just dude you dont need a Process, you can put everything in one loop, that is all you need one loop...One loop, One loop!

code:

%Header Information:
%Programmer's Name: Arian Karbasi
%Date: May 19,2006
%Program Name: mouse.t
%Teacher: Ms. Wong
%Description: mouse stuff
setscreen ("graphics:1012;660")
var x, y, b, x2, y2, d1, d2 : int
var tool : int := 1
var clr : int := black
var pic : int := Pic.FileNew ("Background 4 ISU.jpg")
var pic1 : int := Pic.FileNew ("pencil tool.jpg")
var pic2 : int := Pic.FileNew ("paint fill.bmp")
var colr : int := 16
Pic.Draw (pic, 1, 1, 0)
drawfillbox (200, 620, 900, 50, white)
drawfillbox (50, 600, 150, 250, white)
Pic.Draw (pic1, 60, 550, 0)
Pic.Draw (pic2, 112, 562, 0)
drawbox (66, 580, 86, 560, brightblue)
drawbox (110, 580, 130, 560, black)
drawbox (110, 140, 150, 100, black)
for x1 : 15 .. 90 by 10
    for y1 : 50 .. 200 by 10
        Draw.FillBox (x1, y1, x1 + 10, y1 + 10, colr)
        Draw.Box (x1, y1, x1 + 10, y1 + 10, black)
        colr += 1
    end for
end for
Draw.Box (109, 141, 151, 99, black)
loop
    Mouse.Where (x, y, b)
    if tool = 1 then
        if b = 1 and x > 199 and x < 901 and y > 49 and y < 621 then
            drawline (x, y, x2, y2, clr)
            x2 := x
            y2 := y
        elsif b = 0 then
            buttonwait ("down", x2, y2, d1, d2)
        end if
    end if
    if tool = 2 then
        if b = 1 and x > 199 and x < 901 and y > 49 and y < 621 then
            drawfilloval (x, y, 10, 10, clr)
        end if
    end if
    if b = 1 and x > 14 and x < 96 and y > 49 and y < 211 then
        clr := View.WhatDotColour (x, y)
    end if
    Draw.FillBox (110, 140, 150, 100, clr)
    if x > 65 and x < 87 and y > 559 and y < 581 and b = 1 then
        drawbox (66, 580, 86, 560, brightblue)
        tool := 1
    elsif tool not= 1 then
        drawbox (66, 580, 86, 560, black)
    end if
    if x > 109 and x < 131 and y > 559 and y < 581 and b = 1 then
        drawbox (110, 580, 130, 560, brightblue)
        tool := 2
    elsif tool not= 2 then
        drawbox (110, 580, 130, 560, black)
    end if
end loop


It is the same thing, just without processes.

Good job.


Quote:
14 people downloaded it and know one has given feedback yet...let me know if it does not work.


Dont' you just hate that? lol
Reality Check




PostPosted: Sat Jun 10, 2006 10:58 am   Post subject: (No subject)

Thanks man. I plan to have many tools and this is just 2. I'll give you guys an update after I'm done my 4th or 5th tool. I just perfected the paint tool and I have 5 different sizes, the specified size is highlighted when you click it (like the tool is) and I made sure the circle doesn't go out of the canvas. I've also added an option at the beginning to specify canvas size. One quick question though, isn't it slower if I have a whole bunch of if's in one big loop?
upthescale




PostPosted: Sat Jun 10, 2006 11:09 am   Post subject: (No subject)

be sure to check out my paint i just made in half hour, it is my ferst one

it is in te application sction
Mr. T




PostPosted: Sat Jun 10, 2006 1:39 pm   Post subject: (No subject)

upthescale wrote:
Good job, less than 100 lines is pretty sweet, but one thing...

AVOID PROCESSES!!!!



Here is how you can make your code better WITHOUT processes, it is the same thing, just dude you dont need a Process, you can put everything in one loop, that is all you need one loop...One loop, One loop!

You start off well with the whole avoiding processes bit, but you end on a weak note. It's not good form to just stick everything in one loop. It is important to learn how to use procedures and functions in order to make your code less linear.
upthescale




PostPosted: Sat Jun 10, 2006 1:55 pm   Post subject: (No subject)

well i know that, but maybes hes a newbie and he hasnt been taughth them yet so i didnt wanan get into that, but yes procedures arenice,

wait i use procedures,
code:

procedure hey
put"hey"
end hey

loop
hey
end loop


but why can't u just go

code:

loop
locate(1,1)
put"heY"
end loop

?? same thing just without a procedure
Sponsor
Sponsor
Sponsor
sponsor
TheOneTrueGod




PostPosted: Sat Jun 10, 2006 2:33 pm   Post subject: (No subject)

Er, those two actually do something different, but either way, for something as simple as that, you wouldn't use procedures. That example is a good way to show that procedures exist, how to declare them, etc, but other than that, you wouldn't use them.

What you would use them for is to reduce redundancy. For example, if you wanted to draw a triangle:

code:

drawline(100,100,200,100,black)
drawline(100,100,150,150,black)
drawline(100,100,150,150,black)


And then you wanted to draw another one to the right of that, its a waste of time to write it out again, especially if you, say, wanted to draw 5 of them. This is where procedures + parameters come into handy.
Reality Check




PostPosted: Sat Jun 10, 2006 7:17 pm   Post subject: (No subject)

I know exacly why procedures are used for. I'm almost positive I don't need them for what I'm doing since I'm doing nothing redundant. Putting everything in one big loop seems bad to me for some reason...so what can I do avoid processes (as people say) and not put it into one big loop.
[Gandalf]




PostPosted: Sat Jun 10, 2006 7:46 pm   Post subject: (No subject)

The thing is, you are wrong. Without even looking at your code I can tell that instead of using processes in this situation you could be using procedures. Then call those procedures from your not-so-big-anymore-loop. Procedures are organizing tools as well as optimization tools.
Reality Check




PostPosted: Sat Jun 10, 2006 8:03 pm   Post subject: (No subject)

Wow, just put everything in procedure...everything seems to be running a bit more smoothly! I can now move my mouse fast and still have the draw look like paint instead of individual circles!
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  [ 12 Posts ]
Jump to:   


Style:  
Search: