Login Register


Learn to Draw in LindenMASM! filter_list
Author
Message
Learn to Draw in LindenMASM! #1
Syntax();
Learn to Draw in LindenMASM!



Table of Contents
  1. Introduction
  2. Syntax
  3. Commands
  4. Examples



Chapter 1: Introduction

LindenMASM is an esoteric programming language I designed for the purposes of drawing Lindenmayer systems. It uses an Assembly-like syntax, hence the name LindenMASM. The original reason I made the language was for a code-golf challenge, which was to create a LindenMASM interpreter in the fewest bytes possible. Since this was too similar to a challenge that had already been made, I scrapped the idea, but held on to the interpreter.

The interpreter was written in Python 3.4, and does all of the drawing using a Turtle object. You can download the interpreter here.



Chapter 2: Syntax

There are only a few functional keywords in LindenMASM, 8 to be exact.
  • STT - Begins every LindenMASM file.
  • AXI $ - Sets the axiom (initial state) of the system.
    • $ is a series of commands/variables/constants, ranging from the built-ins plus any user-defined functions.
  • DEG $ - Sets the degree of which all turns will follow, default is 90.
  • MOV $ - Sets the move distance of which all position adjustments will follow, default is 10.
  • INC $ - Sets the number of iterations the generation should go through, default is 0.
  • SET $ # - Sets a constant $ to a specified command #.
    • $ should be a character that is not one of []+-.
    • # will either be a 0 or a 1, where a 0 corresponds to the constant being one that draws forward, and a 1 corresponds to the constant being one that moves fowards.
  • RPL $ # - On every iteration, variable/constant $ will be replaced with the command/variable/constant string #.
    • $ should be a character that is not one of []+-. It does not need to be SET to be replaced.
    • # is a string of commands/variables/constants that $ should be replaced with.
  • END - Ends every LindenMASM file.

Each keyword should be placed on a new line. Every file should start with STT and end with END.



Chapter 3: Commands

There are only four built-in commands, however with these you can do a bunch of stuff!
  • + - Rotates the pointer to the right DEG degrees.
  • - - Rotates the pointer to the left DEG degrees.
  • [ - Saves the pointer's coordinates and heading to a list.
  • ] - Pops the last value of a list and sets the pointer's coordinates and heading to that.



Chapter 4: Examples

Dragon Curve, n = 12
Code:
STT INC 12 AXI FX SET F 0 RPL X X+YF+ RPL Y -FX-Y END

This will draw something like this:

[Image: 300px-N12DragonCurve.png]

Fractal Tree, n = 6
Code:
STT AXI X DEG 25 MOV 2 INC 6 SET F 0 RPL X F-[[X]+X]+F[+FX]-X RPL F FF END

This will draw something like this:

[Image: 300px-N6FractalTree.png]



Thanks for reading! The language isn't expansive or anything, but it's fun to play around with! Biggrin
[Image: CDUAq9d.png]

[+] 2 users Like Shebang's post
Reply

RE: Learn to Draw in LindenMASM! #2
dude, this is awesome. I might start using this for vector generation
It's often the outcasts, the iconoclasts ... those who have the least to lose because they
don't have much in the first place, who feel the new currents and ride them the farthest.

Reply

RE: Learn to Draw in LindenMASM! #3
Holy crap that looks fun. I might port this over to Python2.

Reply

RE: Learn to Draw in LindenMASM! #4
(08-19-2015, 07:59 PM)eclipse Wrote: Holy crap that looks fun. I might port this over to Python2.

I think the only thing needing changing is the tracer call, since that's not supported in Py2 (at least, the same way it is in Py3).
[Image: CDUAq9d.png]

Reply







Users browsing this thread: 1 Guest(s)