Download presentation
Presentation is loading. Please wait.
Published byJemimah Woods Modified over 8 years ago
1
Advanced AWT Paint
2
● Paint is used to fill a shape, its inside is covered with paint. ● Use the setPaint method to set the paint style to an object with a class that implements the Paint interface. ● The Java 2D API provides three such classes ● The Color class implements the Paint interface – g2.setPaint(Color.red);
3
● The GradientPaint class varies colors by interpolating between two given color values – g2.setPaint(new GradientPaint(p1, Color.RED, p2, Color.YELLOW)); ● Colors are interpolated along the line joining the two points. Colors are constant along lines that are perpendicular to that joining line. Points beyond an end point of the line are given the color at the end point. – g2.setPaint(new GradientPaint(p1, Color.RED, p2, Color.YELLOW, true)); ● The color variation cycles and keeps varying beyond the end points.
4
● The TexturePaint class fills an area with repetitions of an image. – TexturePaint(BufferedImage texture, Rectangle2D anchor) – The anchor rectangle defines the tiling of the space to be painted; it is repeated indefinitely in x- and y-directions, and the texture image is scaled to fill each tile.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.