Java Reference
In-Depth Information
def radialGrad = RadialGradient {
radius:1; centerX: 0.5, centerY: 0.5
proportional : true
stops: [ ...]
Here, radius = 1 means to stretch out the size of the radial gradient to 100% of the size
of the target node. In our snippet, the centerX and centerY properties are expressed as
fractional values of 0.5 , which will cause the gradient to be generated at half the size of
the circle.
See also
F Introduction
Creating your own customized Paint
In previous recipes (and chapters), we have seen the use of the Color class used to apply
paint color to an object. In the recipe Applying cool paint effects with gradients , we explored
how to use JavaFX's built-in gradient classes to apply paint effects to visual objects. But, what
if you want to create your own customized paint? This is exactly what is covered in this recipe.
You will learn how to create your own Paint instance, which can be used to fill in your objects.
Getting ready
This recipe makes use of the javafx.scene.paint.Paint class to create a customized
Paint instance that can be used to paint any node object. We are also going to make use
of additional classes, javax.imageio.ImageIO , , java.awt.geom.
Rectangle2D , and java.awt.TexturePaint , that are used to load the image and
create the paint texture.
How to do it…
Creating a customized paint involves extending class Paint . To illustrate how to accomplish
this, the next code snippet creates the class CustomPaint to be used as textured
paint. You can get the full listing of the code in ch03/source-code/src/effects/
CustomPaintDemo.fx .
class CustomPaint extends Paint {
public-init var url:String;
override public function impl_getPlatformPaint () : Object
var buff = URL(url));
Search WWH ::

Custom Search