Skip to content

Drawing on the screen

Victor Rodriguez edited this page Jun 2, 2020 · 17 revisions

Drawing in pSEngine is very easy. All you need is a draw(drawer) function in your object's class, which is automatically called by the engine. The drawer parameter of the function is an object of class Drawer with several member functions that allow us to create basic geometry, handle colors and strokes, and do some more complex operations.

Basic geometry

A basic draw() function looks like this:

draw(drawer) {
      drawer
          .stroke(255, 255, 255)
          .line(0, 0, 40, 150);
   }

We will talk about the stroke(255, 255, 255) part later (but be careful not to forget it, or else you won't be able to see the line). The line(x0, y0, x1, y1) function draws a line between (x0, y0) and (x1, y1). The other functions you can use to draw basic geometry are the following:

  • ellipse(x, y, rx, ry): draws an ellipse of radii rx and ry with center (x, y).

Strokes and colors

More complex geometry

Clone this wiki locally