Quick Start Guide to JavaFX by J. F. DiMarzio

Quick Start Guide to JavaFX by J. F. DiMarzio

Author:J. F. DiMarzio
Language: eng
Format: epub
Tags: -
Publisher: McGraw-Hill Education
Published: 2014-02-20T05:00:00+00:00


The Canvas

JavaFX provides another API for drawing to the screen. The Canvas API, another subclass of Node, can be used in a scene graph to write to the screen and display shapes, colors, and textures.

The Canvas API uses a GraphicsContext in rendering objects to the screen. The GraphicsContext class fulfills drawing calls from the Canvas API. Just a handful of the available methods for drawing, filling, and writing to the Canvas are used in the example provided in this section.

Let’s use the Canvas API to draw two circles to the screen. The first circle is a red filled circle, and the second circle is a black, unfilled outline.

First, set up a new Stage. Instantiate a new Canvas, Group, and GraphicsContext for the new Stage, as follows:



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.