Java Reference
In-Depth Information
// Ice cream
Path path = new Path();
MoveTo moveTo = new MoveTo();
moveTo.setX(50);
moveTo.setY(150);
...// Additional Path Elements created.
LineTo lineTo1 = new LineTo();
lineTo1.setX(50);
lineTo1.setY(150);
...// Additional Path Elements created.
path.getElements().add(moveTo);
path.getElements().add(quadCurveTo);
path.getElements().add(lineTo1);
Rendering the QuadCurve (smile) object, you instantiate a new QuadCurve ob-
ject and set each of the attributes accordingly. Again, each of the attributes accepts a
single value.
Last is the tasty donut shape with a drop shadow effect, which is actually created by
two circular ellipses. By subtracting the smaller ellipse (donut hole) from the larger el-
lipse area, a newly derived shape is created and returned using the
Path.subtract() method. Following is the code snippet that creates the donut
shape using the Path.subtract() method:
// outer donut
Ellipse bigCircle = ...//Outer shape area
// donut hole
Ellipse smallCircle = ...// Inner shape area
// make a donut
Shape donut = Path.subtract(bigCircle, smallCircle);
Next, a drop shadow effect is added to the donut. This time instead of drawing the
shape twice, similar to a prior recipe, you draw it once and use the setEffect()
Search WWH ::




Custom Search