HOME DEMOS TUTORIAL DEVKIT GITHUB

Draw shapes

ra has many methods that draw shapes. They can be called with positional parameters:

const ra = require('raster'); ra.setSize(20, 25); ra.setZoom(4); ra.drawRect(2, 3, 14, 8); ra.run();

or using named parameters as an object literal:

const ra = require('raster'); ra.setSize(20, 25); ra.setZoom(4); ra.drawRect({x: 2, y: 3, w: 14, h: 8}); ra.run();

All of these methods have a corresponding fill method, it fills in the same shape:

const ra = require('raster'); ra.setSize(20, 25); ra.setZoom(4); ra.fillRect({x: 2, y: 3, w: 14, h: 8}); ra.run();

Here are the different ways to draw shapes:

drawLine | - drawSquare | fillSquare drawRect | fillRect drawCircle | fillCircle drawPolygon | fillPolygon
Previous: Starting Off Table of Contents Next: Using color