paint code

Discuss stuff not about Indigo.
Post Reply
5 posts • Page 1 of 1
User avatar
eman7613
Posts: 597
Joined: Sat Sep 16, 2006 2:52 pm

paint code

Post by eman7613 » Sun Nov 05, 2006 7:12 pm

Code: Select all

for (int k = 0; k < lineCount; k++)
	{
		gBuffer.setColor(colorArray[k]);
		gBuffer.drawLine(startX[k]-59,startY[k],endX[k]-59,endY[k]);
	}
for (int k = 0; k < drawRectLineCount; k++)
		{
			switch (drawRectType[k])
			{
				case 1:
					gBuffer.setColor(drawRectColorArray[k]);
					gBuffer.fillRect(drawRectStartX[k]-59,drawRectStartY[k],drawRectEndX[k],drawRectEndY[k]);
				break;
				case 2:
					gBuffer.setColor(drawRectColorArray[k]);
					gBuffer.fillOval(drawRectStartX[k]-59,drawRectStartY[k],drawRectEndX[k],drawRectEndY[k]);
				break;
				case 3:
					gBuffer.setColor(drawRectColorArray[k]);
					gBuffer.drawRect(drawRectStartX[k]-59,drawRectStartY[k],drawRectEndX[k],drawRectEndY[k]);
				break;
				case 4:
					gBuffer.setColor(drawRectColorArray[k]);
					gBuffer.drawOval(drawRectStartX[k]-59,drawRectStartY[k],drawRectEndX[k],drawRectEndY[k]);
				break;
				case 5:
					gBuffer.setColor(drawRectColorArray[k]);
					gBuffer.drawRoundRect(drawRectStartX[k]-59,drawRectStartY[k],drawRectEndX[k],drawRectEndY[k],10,10);
				break;
				case 6:
					gBuffer.setColor(drawRectColorArray[k]);
					gBuffer.fillRoundRect(drawRectStartX[k]-59,drawRectStartY[k],drawRectEndX[k],drawRectEndY[k],10,10);
				break;
			}
		}
stuff stuff stuff
g.drawImage(virtualMem,59,0,this);
When i use an erasor or any other various bursh, anything that gets drawn in the "lineCount" loop cant be drawn over. it always shows up above everyhing else
Yes i know, my spelling sucks

User avatar
dogfin
Posts: 48
Joined: Wed Sep 13, 2006 1:28 pm
Location: Washington State - USA

Post by dogfin » Sun Nov 05, 2006 8:04 pm

So, I feel like a jerk. Here I'm like "Boo ya! I'm teh l337 hax0r" and I cant find jack on brushes or erasing in java. Um, if you could give me some more code or a hint, I can try again. But, sorry for being clueless. :oops: erm...Later then.


dogfin -
Image

User avatar
eman7613
Posts: 597
Joined: Sat Sep 16, 2006 2:52 pm

Post by eman7613 » Mon Nov 06, 2006 5:29 am

hahah, thats ok, you made that thing that stops indigo, way better then me!

you can downlaod the sorce & images here http://www.angelfire.com/crazy/java_aps/Paint.zip

feel free to tinker with it ;p

EDIT: ok weirdness, for some reason angelfire wants you to copy and paste the link into your browser
Yes i know, my spelling sucks

User avatar
dogfin
Posts: 48
Joined: Wed Sep 13, 2006 1:28 pm
Location: Washington State - USA

Post by dogfin » Mon Nov 06, 2006 6:50 am

Alright, I've been over your code, and I've got to be picky first :D

Code: Select all

g.drawString("Mouse is at...
didnt' work for me, it endlessly drew over the top of itself into a blob, I used this instead:

Code: Select all

showStatus("Mouse is at (" + xCoord + "," + yCoord + ")");
Also, I'm in Linux which has case sensative filenames (your BG.JPG's).

Anyway, my solution to your problem is this. You need to have two image's. One is cleared and updated every time a line is being draw, then when the user mouseUp's, you finalize that to the master buffer.

Display to the user is the master buffer with the scratch buffer overlayed. If you want the erasor to work, you need to finalize what you draw to a master buffer bitmap. You shouldn't need to redraw every line and shape every refresh, they should be hard-stored in a master buffer.

I hope that makes sense. Been a while since I did a paint program, but thats how I did it before (I think, heh). Later man.


dogfin -
Image

User avatar
eman7613
Posts: 597
Joined: Sat Sep 16, 2006 2:52 pm

Post by eman7613 » Mon Nov 06, 2006 8:05 am

wierd, mine works fine with g.drawString, very confusing. thank for the advice om going to try it when i get a chance.

EDIT: Woot! thanks for the advice works perfect now!
Yes i know, my spelling sucks

Post Reply
5 posts • Page 1 of 1

Who is online

Users browsing this forum: No registered users and 82 guests