artc language
...seeks to be a moderately good option for expressing some forms of art concisely and precisely.
What is it?
It's a function, which deterministically evaluates/renders...
...from: to any one of these formats:
┌───────────────┐ ⎧ .usdz files of 3D objects / scenes / animations,⎫
│ │ ⎪ ⎪
│ .artc code │ --> ⎨ .json files of 2D Canvas drawing operations, ⎬
│ │ ⎪ ⎪
│ (Python fork) │ ⎩ .mid files of MIDI ⎭
└───────────────┘
⎧ language for, ⎫ ⎧ OpenUSD, ⎫
⎪ ⎪ ⎪ ⎪
It's a ⎨ library for, ⎬ ── ⎨ CanvasRenderingContext2D, ⎬
⎪ ⎪ ⎪ ⎪
⎪ intro to, ⎪ ⎪ MIDI, ⎪
⎪ ⎪ ⎪ ⎪
⎩ celebration of ⎭ ⎩ some basic physics ⎭
It does NOT involve generative AI or seek to replace or automate artistic choices or subtleties.
What's OpenUSD?
What's CanvasRenderingContext2D?
What's MIDI?
Why is it?
It's for:
- art
- diagrams
- { learning / teaching / exploring } stuff
It doesn't make new stuff possible,
but it tries to make some forms of already-possible stuff somewhat easier.
Language
The language is a fork of Python.
The standard library is very different, and there's some additional syntax / semantics:
Examples | |
---|---|
45° -5 m/s² 90 BPM | You can include units in a Quantity literal. |
Gray(25%) | You can use % to indicate percentages, in many cases. |
| You can use the You can specify absolute or relative for:
The interpolation can be eased with easing functions. When a relevant assignment statement does not use an |
shape.x = 1m ± 50cm ... += random( ± 15° ) | You can define an Interval via ± , e.g. for implicitly[1] or explicitly drawing a sample from a uniform distribution over that Interval using the global PRNG instance. |
| Expressions that would be large blobs of code can be collapsed/elided/hidden, getting replaced with a symbol like This can be helpful for things such as:
|
How format-on-save helps with non-ASCII
Normalized result | via ASCII | or type it |
---|---|---|
5 m/s² | 5 m/s2 | |
45° | 45deg | Opt + Shift + 8 |
x ± y | Interval.plus_or_minus(x, y) | Opt + Shift + + |
random( ± 5cm ) | random(Interval.plus_or_minus(0, y)) | Opt + Shift + + |
Standard library
Binary encoding
.artc code <-------> binary-encoded
(as text) form of .artc code
Questions
What works of art are we capable of expressing in at most 100 bytes of [additional] information?
If there's an information-storage bottleneck someday, how much art could losslessly survive?
Design goals
- Have the encoded hex be (somewhat) readable:
- Have the edges of the Huffman trees represent nibbles, not bits.
- Operate on syntax trees, not text
- Note: this will normalize / autoformat your code
- Note: there's a
.Gap
AST node for expressing additional blank lines
- Optimize for names and patterns specific to this language and standard library
(vs plain text or Python in general). - You should be able to simply (albeit tediously) decode it yourself, with pencil and paper
Examples
Example 1
B26B2
is a 2.5-byte encoding of the following:
scene.aspect_ratio = "√2:1"
scene.background = Gray(25%)
scene.padding = 6%
Note: this is a common initial pattern for concise 2D works ("set aspect ratio, background, and a padding percentage beyond the bounding box of whatever shapes end up in the scene graph"), so the encoding optimizes for it.
Full walk-through of this example
Background:
- Current state: there's a finite set of states, each of which has its own Huffman tree which maps input-nibble prefix code sequences to action bundles. Some states (like
.end_sequence_b2_init
) map the empty string to one specific action bundle and do nothing else. - Input chunk: a full prefix code of one or more nibbles, which take us all the way from the root of this state's Huffman tree to one of its leaves
- Action bundle: a named list of actions
- State stack: like a to-do list, defining upcoming states. See also: Pushdown automaton
- Node stack: a temporary stack of AST nodes, to be used soon in upcoming action bundles
- Code: the AST that's been built so far. Its root is a
.Module
node.
Current state | Input chunk | Action bundle for this (state, input) |
---|---|---|
.initial
| B | .use_draft_b :
|
.b_initial
| 2 | .start_sequence_b2_init :
|
.get_padding_percent
| 6 | .make_padding_percent with value=6 :
|
.get_background_color
| B | .make_gray_percent with value=25 :
|
.get_aspect_ratio
| 2 | .make_string with value = (index of "√2:1" in the list of string constants):
|
.end_sequence_b2_init
| .end_sequence_b2_init :
|
Project status
Not yet published.
Project itinerary
- Not yet published
- Draft WASM blob (+ wrapper code) available at no cost
- FLOSS, v1.0