Skip to content

Instantly share code, notes, and snippets.

@treytomes
treytomes / doodle.ms
Created April 26, 2024 13:47
Building a simple scene graph, part 3.
import "events"
import "json"
import "listUtil"
import "qa"
import "stringUtil"
import "tc"
import "textUtil"
Shape = {}
Shape.make = function(x, y)
@treytomes
treytomes / doodle.ms
Created April 18, 2024 18:41
Building a simple scene graph, part 2.
import "events"
import "json"
import "stringUtil"
import "tc"
Ellipse = {}
Ellipse.make = function(x, y, width, height, color=null, penSize=1)
if color == null then color == gfx.color
self.className = "Ellipse"
self.left = x - width / 2
@treytomes
treytomes / doodle.ms
Last active April 18, 2024 18:40
Building a simple scene graph, part 1
import "tc"
import "stringUtil"
Ellipse = {}
Ellipse.make = function(x, y, width, height, color=null, penSize=1)
if color == null then color == gfx.color
self.left = x - width / 2
self.bottom = y - height / 2
self.width = width
self.height = height
@treytomes
treytomes / graph.ms
Created February 7, 2024 14:53
Several ways of graphing an equation.
MIN_X = -10
MAX_X = 10
MIN_Y = -10
MAX_Y = 10
RANGE_X = MAX_X - MIN_X + 1
RANGE_Y = MAX_Y - MIN_Y + 1
// Transform grid coordinates into screen coordinates.
transform = function(x, y)
// Metaballs / Marching Squares Demo
// https://jamie-wong.com/2014/08/19/metaballs-and-marching-squares/
// https://jurasic.dev/marching_squares/
import "tc"
GRID_RESOLUTION = 24
PRINT_SAMPLES = false
SHOW_GRID = false
DRAW_CIRCLES = true
FILL_RECTS = false
@treytomes
treytomes / wiki.ms
Created January 30, 2024 20:54
Mini Micro Help
import "json"
import "stringUtil"
wikiApiUrl = "https://miniscript.org/w/api.php"
formatParams = function(params)
query = []
for key in params.indexes
query.push "{0}={1}".fill([ key, params[key] ])
end for
@treytomes
treytomes / song.ms
Created January 22, 2024 19:41
Playing a familiar tune with the Mini Micro sound generator.
// Play a familiar tune.
bpm = 200
bps = bpm / 60
spb = 1 / bps
notes = {
"R": 0,
"C4": 60,
"C5": 72,
////
// Weird experiment to see what Rust-style traits might look like in MiniScript.
////
import "listUtil"
import "stringUtil"
PartialEq = {}
PartialEq.eq = function(other)
return refEquals(self, other)
@treytomes
treytomes / splitQuote.ms
Created January 5, 2024 14:31
Split a quoted string around a delimiter.
import "qa"
// Split a quoted string on a delimiter.
string.splitQuote = function(delim)
a = self.split("""")
b = []
for n in a.indexes
if n % 2 == 0 then
b += a[n].trim.split(delim)
else
@treytomes
treytomes / spec.ms
Created April 6, 2023 19:43
Creating a Cucumber-style test in MiniScript.
import "qa"
Scenario = {}
Scenario.init = function(name)
self.name = name
return self
end function
Scenario.Given = {}