Category:Pluto-bitmap
This is an example of a library. You may see a list of other libraries used on Rosetta Code at Category:Solutions by Library.
Pluto-bitmap is a module which enables one to draw simple 2D geometric figures or to create static images or charts using the Pluto programming language. As such, it builds on the basic functionality of the built-in canvas class.
The module has 4 classes: bitmap, chart, turtle and tpen.
- bitmap is a wrapper for the canvas class. A wrapper is desirable because it is not possible to add instance methods to canvas using Pluto itself because it is a 'userdata' class i.e. it is written in C++.
- chart uses bitmap to plot points, create charts or to draw other figures which require x and y axes as a frame of reference. Coordinates are expressed relative to these axes and are mapped internally to canvas coordinates whose origin (0, 0) is always at the top left hand corner of its window.
- turtle (and the associated tpen class) enables one to draw on a bitmap using the popular turtle graphics system.
There are also four color maps: color, color2, pico and pico2. The canvas (and hence the bitmap) class support saving to a file in either .bmp or .png format. The color and pico maps express colors in BGR order and the color2 and pico2 maps in RGB order as required by these respective formats.
The pico/pico2 maps are for compatibility with DOME which uses PICO-8 video game colors rather than standard RGB colors.
- To use the module, copy the source into a file named
bitmap.pluto.
- The file needs to be in the same directory as your program.
Then, add require "bitmap" to your program.
As this module already requires 'canvas', there is no need to require it again in your program.
If you want to create a .png file rather than a .bmp file, you should use the color2 (or pico2) map either directly or by simply adding the line: color = color2 (or pico = pico2) after the 'require' statement.
For examples of usage check out any of the tasks listed below.
Pages in category "Pluto-bitmap"
The following 32 pages are in this category, out of 32 total.