Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Drawing Capabilities Example

This example demonstrates the drawing capabilities of akesi lili by showcasing various drawing functions. These functions allow you to create a wide range of visual elements on the screen, from text and shapes to sprites and lines.

Drawing

Explanation

The code uses different drawing functions to render various elements on the screen. It clears the background, draws text, shapes, pixels, and sprites. This example highlights the versatility of akesi lili's drawing functions.

Code

export draw=||
 # Fills background with color 0
 clear 0

 # Draws text "Drawing"
 txt 'Drawing', 1, 1, 3

 # Draws bordered rectangle
 rect 1, 11, 21, 31, 2

 # Draws filled rectangle
 fill_rect 1, 32, 21, 52, 2

 # Draws bordered circle
 circ 34, 21, 10, 1

 # Draws filled circle
 fill_circ 34, 42, 10, 1

 # Draws single pixel
 pix 53, 21, 3

 # Draws sprite
 spr 0, 49, 38

 # Draws a line
 line 1, 52, 21, 60, 3

How It Works

  1. Background Clearing: The clear(0) function fills the entire screen with color 0 (the first color in the active palette), providing a clean canvas for drawing.

  2. Text Rendering: The txt() function displays the text "Drawing" at position (1,1) in color 3, demonstrating basic text output.

  3. Rectangle Drawing: Two types of rectangles are shown:

    • rect(1,11,21,31,2) draws a bordered rectangle from point (1,11) to (21,31) in color 2
    • fill_rect(1,32,21,52,2) draws a filled rectangle from point (1,32) to (21,52) in color 2
  4. Circle Drawing: Two types of circles are demonstrated:

    • circ(34,21,10,1) draws a bordered circle centered at (34,21) with radius 10 in color 1
    • fill_circ(34,42,10,1) draws a filled circle centered at (34,42) with radius 10 in color 1
  5. Pixel Drawing: The pix(53,21,3) function sets a single pixel at coordinates (53,21) in color 3, useful for precise drawing operations.

  6. Sprite Rendering: The spr(0,49,38) function draws sprite index 0 from the sprite sheet at position (49,38) with no flipping (flip=0 is implied by default).

  7. Line Drawing: The line(1,52,21,60,3) function draws a line from point (1,52) to (21,60) in color 3.

This example showcases the complete set of basic drawing primitives available in akesi lili, demonstrating how to create diverse visual elements for your games.