4.2 The Graphics Coordinate System and Color
JavaFX’s GraphicsContext class, in the javafx.scene.canvas package, provides methods to draw figures such as rectangles, circles, and lines; to set the colors for drawing; and to write text in a window.
To draw on the window, we specify the location where we want to put our shapes and the color we want the shapes to have.
A window is composed of pixels, which can be thought of as colored dots. A window with a width of 700 pixels and a height of 400 pixels has a total of 28,000 (700 * 400) pixels. Each pixel has a location expressed using an (x, y) coordinate system. The x coordinate specifies the horizontal position, beginning at 0 on the left side of the window and increasing as you move to the ...
Get Java Illuminated, 5th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.