Painting program issue
Author |
Message |
Insectoid
![](http://compsci.ca/v3/uploads/user_avatars/13760332514cbd0ce972eaa.jpg)
|
Posted: Wed Apr 30, 2008 9:57 am Post subject: Painting program issue |
|
|
This is a simple program I am making in class for fun and I would like it to do something I do not know how to make it do.
I would like the 'paintbrush' (a dot) to be outlined in black, but I do not want the outline outlineing the line that I draw. (Say that ten times fast). Any idea how to do this?
code: |
var x : int := 10
var y : int := 10
var num : array char of boolean
var color1 : string (1)
var colornum := 16
procedure pickcolor
setscreen ("nocursor")
getch (color1)
if color1 = '1' then
colornum := 31 %white
elsif color1 = '2' then
colornum := 16 % black
elsif color1 = '3' then
colornum := 12 % red
elsif color1 = '4' then
colornum := 32 % blue
elsif color1 = '5' then
colornum := 48 % green
elsif color1 = '6' then
colornum := 13 % purple
elsif color1 = "7" then
colornum := 44 % yellow
elsif color1 = "8" then
colornum := 28 % grey
end if
end pickcolor
loop
colorback (28)
cls
colorback (white)
put "Press ENTER to choose color"
colorback (white)
put "Color: White Black Red Blue Green Purple Yellow Eraser "
colorback (white)
put " 1 2 3 4 5 6 7 8"
colorback (white)
put "Press TAB for thick line"
Draw.ThickLine (1, 350, 639, 350, 5, black)
x := 10
y := 10
loop
Input.KeyDown (num)
if num (KEY_TAB) then
Draw.FillOval (x, y, 5, 5, colornum)
else
Draw.FillOval (x, y, 2, 2, colornum)
end if
if num (KEY_UP_ARROW) and y < 300 then
y := y + 1
end if
if num (KEY_DOWN_ARROW) and y > 10 then
y := y - 1
end if
if num (KEY_LEFT_ARROW) and x > 10 then
x := x - 1
end if
if num (KEY_RIGHT_ARROW) and x < 630 then
x := x + 1
end if
if num (KEY_ENTER) then
pickcolor
end if
exit when num (KEY_ESC)
delay (10)
end loop
end loop
|
|
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
gitoxa
![](http://compsci.ca/v3/uploads/user_avatars/125344263047f801d546bcb.jpg)
|
Posted: Wed Apr 30, 2008 12:16 pm Post subject: Re: Painting program issue |
|
|
Could you try explaining that again, a little less confusing though.
|
|
|
|
|
![](images/spacer.gif) |
darkangel
![](http://compsci.ca/v3/uploads/user_avatars/144136381845e745672f3dd.gif)
|
Posted: Wed Apr 30, 2008 3:25 pm Post subject: Re: Painting program issue |
|
|
The only way i can think of it is to draw.filloval then draw line segments over top of them to create the outline, but that is far from efficient. But now you got me interested.....
|
|
|
|
|
![](images/spacer.gif) |
Sean
![](http://compsci.ca/v3/uploads/user_avatars/47413941748406f441f83e.png)
|
Posted: Wed Apr 30, 2008 3:29 pm Post subject: RE:Painting program issue |
|
|
Are you only wanting an outline of a dot?
Or something else, confusing to read what you posted.
|
|
|
|
|
![](images/spacer.gif) |
darkangel
![](http://compsci.ca/v3/uploads/user_avatars/144136381845e745672f3dd.gif)
|
Posted: Wed Apr 30, 2008 3:39 pm Post subject: Re: Painting program issue |
|
|
I was assuming that he wanted something like this.
Description: |
|
Filesize: |
32.9 KB |
Viewed: |
70 Time(s) |
![Unnamed #1 Output.bmp](uploads/attachments/thumbs/t_unnamed_1_output_876.bmp)
|
|
|
|
|
|
![](images/spacer.gif) |
Insectoid
![](http://compsci.ca/v3/uploads/user_avatars/13760332514cbd0ce972eaa.jpg)
|
Posted: Wed Apr 30, 2008 6:16 pm Post subject: RE:Painting program issue |
|
|
Er...No, That isn't what I wanted. It's hard to understand because it was difficult to explain.
If you run it, you may notice that you cannot see the 'paintbrush', only the 'paint'. This is because I did not tell it to draw a 'brush'. I want the 'brush' to be a black outline of the 'paint color' that moves around. The only purpose of the outline would be to show you where the brush it. If I just outline it with Draw.Oval, All my lines would be outlined in black. You don't look at your wall and see paintbrushes all over it, do you? (unless the wall is being painted...or you have paintbrush-wallpaper)
Eventually, I will be changing the arrow keys to Mouse.Where so that you can do a proper picture in it, as well as a save command.
|
|
|
|
|
![](images/spacer.gif) |
gitoxa
![](http://compsci.ca/v3/uploads/user_avatars/125344263047f801d546bcb.jpg)
|
Posted: Wed Apr 30, 2008 8:19 pm Post subject: Re: Painting program issue |
|
|
What about using Pic.New and Pic.Draw? Save the picture before drawing the first cursor, and just load it the picture again after every time you move the cursor. Something like the below, although it needs fine-tuning.
Note, I somewhat changed the idea of the 'tab' button. When held down, you start drawing.
code: | View.Update
PicId := Pic.New(9, 9, maxx, maxy)
loop
Input.KeyDown (num)
if num (KEY_TAB) then
Pic.Free(PicId)
PicId := Pic.New(9, 9, maxx, maxy)
cls
Pic.Draw (PicId, 9, 9, picCopy)
Draw.FillOval (x, y, 3, 3, colornum)
View.Update
else
cls
Pic.Draw(PicId, 9, 9, picCopy)
Draw.FillOval (x, y, 3, 3, colornum)
Draw.Oval (x, y, 3, 3, black)
View.Update
end if
...
|
I'm positive there's a better way, but nothing comes to mind at the moment.
|
|
|
|
|
![](images/spacer.gif) |
Insectoid
![](http://compsci.ca/v3/uploads/user_avatars/13760332514cbd0ce972eaa.jpg)
|
Posted: Thu May 01, 2008 7:40 am Post subject: RE:Painting program issue |
|
|
That probably wouldn't work, as it would still save the picture of the outline, would it not? Also, it seams to me that it would be very laggy.
I like you tab Idea, I wanted to try it but could only get it to go the other way (press button to not draw). I actually usd the tab button in my newest version, posted now.
Turing: |
var x : int := 10
var y : int := 10
var num : array char of boolean
var color1 : string (1)
var colornum := 16
var backcolor : string (1)
var backnum : int
procedure pickcolor
setscreen ("nocursor")
getch (color1 )
if color1 = '1' then
colornum := 31 %white
elsif color1 = '2' then
colornum := 16 % black
elsif color1 = '3' then
colornum := 12 % red
elsif color1 = '4' then
colornum := 32 % blue
elsif color1 = '5' then
colornum := 48 % green
elsif color1 = '6' then
colornum := 13 % purple
elsif color1 = "7" then
colornum := 44 % yellow
elsif color1 = "8" then
colornum := backnum % grey
end if
end pickcolor
loop
cls
put "Choose your Background color"
put "Color: White Black Red Blue Green Purple Yellow Grey (default) "
put " 1 2 3 4 5 6 7 8"
getch (backcolor )
if backcolor = '1' then backnum := 31
elsif backcolor = '2' then backnum := 16
elsif backcolor = '3' then backnum := 12
elsif backcolor = '4' then backnum := 32
elsif backcolor = '5' then backnum := 48
elsif backcolor = '6' then backnum := 13
elsif backcolor = '7' then backnum := 28
else backnum := 28
end if
colorback (backnum )
cls
colorback (white)
put "Press ENTER to choose color"
colorback (white)
put "Color: White Black Red Blue Green Purple Yellow Eraser "
colorback (white)
put " 1 2 3 4 5 6 7 8"
colorback (white)
put "Press TAB for thick line"
Draw.ThickLine (1, 334, 639, 334, 5, black)
x := 10
y := 10
loop
Input.KeyDown (num )
if num (KEY_TAB ) then
Draw.FillOval (x, y, 5, 5, colornum )
else
Draw.FillOval (x, y, 2, 2, colornum )
end if
if num (KEY_UP_ARROW) and y < 331 then
y := y + 1
end if
if num (KEY_DOWN_ARROW) and y > 10 then
y := y - 1
end if
if num (KEY_LEFT_ARROW) and x > 10 then
x := x - 1
end if
if num (KEY_RIGHT_ARROW) and x < 630 then
x := x + 1
end if
if num (KEY_ENTER ) then
pickcolor
end if
exit when num (KEY_ESC)
delay (10)
end loop
end loop
|
|
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Insectoid
![](http://compsci.ca/v3/uploads/user_avatars/13760332514cbd0ce972eaa.jpg)
|
Posted: Thu May 01, 2008 7:44 am Post subject: RE:Painting program issue |
|
|
Opps! seems I had 'tab' in the old version too!
I think I'll use your idea, though with a different key (have I used spacebar yet? (key 31)
EDIT: I see now how you did it, but still, on crappy school computers, T believe it would lagg.
|
|
|
|
|
![](images/spacer.gif) |
Insectoid
![](http://compsci.ca/v3/uploads/user_avatars/13760332514cbd0ce972eaa.jpg)
|
Posted: Thu May 01, 2008 8:31 am Post subject: RE:Painting program issue |
|
|
Okay, new problem.
I created a new 'tool' for the paint program that allows the user to draw a circle/oval, but I can't make the oval smaller. This is because, say, your drawing a blue oval inside a blue oval. I need a way to, instead of drawing thecircle smaller, drawing the background color overtop in a circular shape.
code: |
procedure circle
loop
Input.KeyDown (num2)
Draw.FillOval (x, y, circlex, circley, colornum)
if num2 (KEY_UP_ARROW) then
circley := circley + 1
end if
if num2 (KEY_DOWN_ARROW) then
circley := circley - 1
end if
if num2 (KEY_RIGHT_ARROW) then
circlex := circlex + 1
end if
if num2 (KEY_LEFT_ARROW) then
circlex := circlex - 1
end if
delay (10)
end loop
end circle
|
|
|
|
|
|
![](images/spacer.gif) |
Insectoid
![](http://compsci.ca/v3/uploads/user_avatars/13760332514cbd0ce972eaa.jpg)
|
Posted: Thu May 01, 2008 8:51 am Post subject: RE:Painting program issue |
|
|
Update!
Problem half solved. It now leaves scattered dots around the screen when shrinking the circle (I know why, but not how to fix it)
Seeing as my instruction section of the display is getting pretty large, I would like to have a seperate window to hold text (things like 'press 'B' for circle)
How would I do this?
Note-I am thinking of using this for my final project and therefore it has to be flawless. and huge.
|
|
|
|
|
![](images/spacer.gif) |
|
|