Re: paint program using canvas
On 8=EC=9B=9416=EC=9D=BC, =EC=98=A4=ED=9B=848=EC=8B=9C19=EB=B6=84, "John B.=
Matthews" <nos...@nospam.invalid> wrote:
In article
<1450ddd2-3e2d-4f64-bde1-6a3105a28...@v36g2000yqv.googlegroups.com>,
Andy Cho <dogmea...@gmail.com> wrote:
I'm developing small paint program using canvas class. But I don't
know how retain lines which I draw. All lines are disapeared when
another window is on top of my paint window.
Suppose each line has these attributes:
class Line {
Point p1; Point p2; float width;
public Line(Point p1, Point p2, float width) =
{
this.p1 = p1;
this.p2 = p2;
this.width = width;
}
}
Create a suitable collection of Lines:
List<Line> lines = new ArrayList<Line>();
Each time the user creates a line, add it to the list:
lines.add(new Line(...));
Finally loop through all the lines in your paint() method, drawing each
one:
for (Line line : lines) { ... }
And how can I control the thickness of lines.
See Knute Johnson's example, nearby.
--
John B. Matthews
trashgod at gmail dot com
<http://sites.google.com/site/drjohnbmatthews>
Thanks John
I've wrote my own LineData class including coordinates, thickness and
color.
Regards
Andy