Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Making a Paint program

Status
Not open for further replies.

Garra

Technical User
Jul 10, 2002
1
CL
Hi, i am trying to simulate a paint style program but in the rectangle drawing tool i get some graphic corruption.

The rectangle tool works like this:

with xo, yo the place you press the mouse, and x, y the current place of the mouse when dragging it.

if (x <= xo && y >= yo) {

borrar(x, yo, xo, y);

x = e.getX();
y = e.getY();

graficar(x, yo, xo, y);


} else if (y <= yo && x >= xo) {

clean(xo, y, x, yo);

x = e.getX();
y = e.getY();

graph(xo, y, x, yo);

} else if (x <= xo && y <= yo) {

clean(x, y, xo, yo);

x = e.getX();
y = e.getY();

graph(x, y, xo, yo);

} else if (x >= xo && y >= yo) {

clean(xo, yo, x, y);

x = e.getX();
y = e.getY();

graph(xo, yo, x, y);

}


//the methods graph and clean


public void graph (int x1, int y1, int x2, int y2) {

g.drawRect(x1, y1, Math.abs(x2-x1), Math.abs(y2-y1));

}


public void clean (int x1, int y1, int x2, int y2) {

g.setColor(Color.white);
graficar(x1, y1, x2, y2);
g.setColor(Color.black);

}

as you see its a simple program, if you have an alternative way of doing it i would apreciate if you post it.

Thanks for reading.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top