Kanvas-mumu
Version: 0.1.1
License: Dual-licensed under MIT or Apache-2.0
Author: Tom Fotheringham <tom@nu11.co.uk>
Overview
Kanvas-mumu is a plugin for the MuMu / Lava ecosystem that provides simple 2D graphics capabilities from within MuMu scripts. It uses the minifb cross-platform framebuffer library to open windows and draw pixels, rectangles, triangles, and lines — all from script code.
Once loaded via extend("kanvas") in your MuMu environment, you can create windows, draw shapes, refresh the display, and remove shapes, all using dynamic functions provided by the plugin.
Installation
Build the plugin:
make
Install system-wide (Linux example):
sudo make install
In MuMu/Lava, load the plugin:
extend("kanvas")
Provided Functions
kanvas:create(keyed_array) – Create a window.
Parameters:
width (int, optional, default 640)
height (int, optional, default 480)
title (string, optional, default "Kanvas Window")
Returns: Window handle (int)
kanvas:display(window_handle) – Allow window to process events and stay visible.
kanvas:refresh(window_handle) – Clear and redraw all shapes in the window buffer.
kanvas:remove(window_handle, item_handle) – Remove a shape by its item handle.
kanvas:pixel(window_handle, [x, y], color) – Draw a pixel.
color in #RRGGBB or #AARRGGBB hex format.
kanvas:rectangle(window_handle, [[x1, y1],[x2, y2]], color) – Draw a filled rectangle.
kanvas:triangle(window_handle, [[x1, y1],[x2, y2],[x3, y3]], color) – Draw a filled triangle (integer or float coordinates).
kanvas:line(window_handle, [[x1, y1],[x2, y2]], color) – Draw a straight line between two points.
Example Usage
extend("kanvas")
win = kanvas:create([width: 320, height: 240, title: "Demo"])
kanvas:pixel(win, [10, 10], "#FF0000")
kanvas:rectangle(win, [[20, 20],[60, 40]], "#00FF0080") // semi-transparent green
kanvas:triangle(win, [[80, 20],[100, 60],[60, 60]], "#0000FF")
kanvas:line(win, [[0, 0],[319, 239]], "#FFFFFFFF")
kanvas:refresh(win)
kanvas:display(win)
Building From Source
Ensure you have Rust installed (edition 2021) and the MuMu core crate available. This plugin links against core-mumu and minifb.
cargo build --release
On success, the shared library (e.g. libmumukanvas.so) will be in target/release/.
License
This project is licensed under either:
MIT license
Apache License, Version 2.0
You may choose either license to govern your use of this software.xxxxxxxxxx # create window with custom title, height, width, etc.win = kanvas:create([ title: "Show Me", width: 400, height: 300])kanvas:display(win)kanvas:pixel(win, [10,15], "#FF00FF") # sets pixel to magentakanvas:rectangle(win, [[ 20,30 ], [ 100,60 ]], "#FFC0000") # draws green rectkanvas:triangle(win, [[ 50,50 ], [250,80], [120,200]], "#FF00FF") # filled trianglekanvas:line(win, [[10,10], [100,80]], "#00FF00") # green linekanvas:refresh(win) # Refresh window, rerdraw items### Colors & Alpha Blending** Values for colors should be #RRGFBB or #AARGFBBB** Both full 8-digit and 6-digit Hex are supported, and both can be transparency preferring.### Support, Licensing & ContributingThe **community** actively developed at https://gitlab.com/tofo/mumu-kanvas.The project is under the MIT Or Apache-2.0 License (SEE LICENSE).muu