Prelude Classes

Classes defined in stdlib/prelude.mac, automatically loaded at startup.

Size

Pixel dimensions with arithmetic operators.

var s = Size(720, 480);
print s.width;                // 720
print s.height;               // 480

var doubled = s * 2;          // Size(1440, 960)
var combined = s + Size(100, 0); // Size(820, 480)
print s == Size(720, 480);    // true
MethodReturnsDescription
init(w, h)SizeConstructor
__add__(other)SizeAdd two sizes
__mul__(n)SizeMultiply by scalar
__eq__(other)boolEquality check

Duration

Time duration in milliseconds with arithmetic.

var d = Duration(500);
print d.ms;                   // 500

var longer = d * 3;           // Duration(1500)
var total = d + Duration(200); // Duration(700)
MethodReturnsDescription
init(ms)DurationConstructor
__add__(other)DurationAdd durations
__mul__(n)DurationMultiply by scalar
__eq__(other)boolEquality check

Meme

Builder-pattern meme construction (alternative to meme literals).

var m = Meme(Template("blank"));
m.text(Position("top"), "Hello");
m.text(Position("bottom"), "World");
m.save("png", "hello.png");
MethodReturnsDescription
init(template)MemeConstructor with Template
text(position, str)MemeAdd text at position (chainable)
resize(size)MemeCreate resized copy
save(format, path)nilSave to file

Gif

Animated GIF builder (alternative to gif { } blocks). Supports transitions via _tl for animated transitions between frames.

var g = Gif();
g.frame(@blank "One", Duration(500));
g.frame(@blank "Two", Duration(500));
g.save("output.gif");
MethodReturnsDescription
init()GifConstructor
frame(meme, duration)GifAdd frame (chainable)
transition(type, duration)GifAdd transition between frames (chainable)
save(path)nilSave as animated GIF
__add__(frame)GifAdd Frame object

Helper Classes

Position

Text position constants.

var top = Position("top");
var bottom = Position("bottom");
var center = Position("center");

Format

Output format constants.

var png = Format("png");
var jpg = Format("jpg");
var gif = Format("gif");

Template

Meme template reference.

var t = Template("two_panel");
var custom = Template("path/to/image.png");

See Also