OK, so RIA doesn't really stand for Release your Inner Artist, rather, it has come to mean Rich Internet Applications. Part of this richness is achieved with 2D graphics, and in this post I'm going to introduce you to a resource that will help you explore the 2D capabilities of JavaFX Script.
Drawing on the Canvas
You may recall that the very first post in this blog showed you how to create a Hello World style program that draws a Text object on a Canvas. The Text object is actually considered a Shape, which is one of many shapes that may be drawn on a Canvas. Other shapes include:
- Rect
- Circle
- Ellipse
- Line
- Polyline
- Polygon
- Arc
- CubicCurve
- QuadCurve
- Star
- Path
In addition to drawing shapes, you can:
- Paint with colors, linear and radial gradients, and patterns.
- Perform transformations on graphic objects, including translating (moving), rotating, scaling and skewing.
- Place graphic objects into groups so that they share a coordinate space and can be transformed as a group.
- Place images on a Canvas, and transform them as well.
- Achieve effects such as filtering, transparency, clipping, animation and shape morphing.
- Capture input events such as mouse clicks.
- Define your own custom graphic components.
The list of capabilities of the Canvas widget goes on and on, so as an introduction I'd like you to experience the JavaFX Canvas Tutorial. This may be run locally if you downloaded the Project OpenJFX package as described in an earlier post. Just run the tutorial.bat or tutorial.sh file (depending on your operating system) that is located in the trunk/demos/tutorial folder. Alternatively, you can run it straight off the Internet.
Please be sure to visit each category of capabilities listed on the left side, and click each link on the right side. At the bottom of the tutorial you'll see the associated example code along with the UI produced by that code above it. As with JavaFXPad, you'll be able to alter the code and see its effect on the UI. Here's a screenshot of the JavaFX Canvas Tutorial when it is invoked:
Have fun with this! Future posts will explore some of these capabilities further.
Regards,
Jim Weaver
JavaFX Script: Dynamic Java Scripting for Rich Internet/Client-side Applications
Congratulations, codecraig! By the way, the link to your article had an extra right-paren. Here is the correct link http://codecraig.com/articles/2007/11/06/javafx-script-ebook-received
Posted by: Jim Weaver | November 06, 2007 at 11:37 PM
I agree with Jim on this one...certainly check out the demos that come with the JavaFX download. There is lots of stuff to play with and you can see how the developers of JavaFX write their JavaFX Script code!!
On a side note I received my FREE copy (http://codecraig.com/articles/2007/11/06/javafx-script-ebook-received) of Jim's book (thanks to his puzzler!
Posted by: codecraig | November 06, 2007 at 11:18 PM