15 March 2021

The Canvas Object

A canvas comes with a "pen." These objects live in package javafx.scene.canvas. A good place to stash a canvas object? How about the center of a BorderPane?


Canvas c = new Canvas(700, 500);
GraphicsContext pen = c.getGraphicsContext2D();

Time to Spelunk The pen has methods fillRect() and strokeRect(). What is the difference? Put a 50X50 rectangle in each of the four corners of your canvas.