Skip to content
Martin Cohen edited this page Dec 1, 2016 · 3 revisions

Primitives

Punity can currently draw following primitives:

  • Pixel (pixel_draw)
  • Line (line_draw)
  • Rectangle (filled) (rect_draw)
  • Rectangle (frame and fill) (frame_draw)
  • Bitmap (bitmap_draw)
  • Text (text_draw)

Canvas

Some of the draw functions use properties set in CORE->canvas:

  • clip is a Rect that specifies clip. Set with clip_set which does additional checks. Also see other clip_* functions.
  • translate_x and CORE->canvas.translate_y are used to translate the drawing operations. You can also use camera_* functions.
  • font is used in text_draw to get the font.
  • flags is used to set additional properties for bitmap drawing like horizontal or vertical flip, or mask that will cause every non-transparent pixel to be drawn with color set in CORE->canvas.mask (this is how text is being drawn, for example).

Draw lists

Along with standard painter's algorithm drawing, Punity also supports deferred sorted drawing via draw list. All primitives (except for pixel_draw) are available. Function names are the same, but sport a _push suffix and one additional argument for z coordinate at the end. So for example compare the two calls:

// Standard call.
rect_draw(rect_make(0, 0, 50, 50), 1);
// Draw-list call with z = 12.
rect_draw_push(rect_make(0, 0, 50, 50), 1, 12);

The lower z, the sooner the draw operation is made. The sorting is stable, that means that if two draw commands have the same z coordinate, they will be drawn in the call order.

Each draw command also carries a copy of Canvas, so all the properties set to CORE->canvas are kept and applied.

By default, CORE->draw_list is used to store the draw commands. This draw list is automatically initialized and drawn each frame.

Clone this wiki locally