On this page:
2.1 General Forms
define-art
@
draw-realizer
number
numbers
symbol
hole
fill-holes
2.2 Coordinates
2.2.1 Interval
interval
i@
--
--
translate
dilate
loop
expand-loop
rhythm
uniform-rhythm
rhythm->holes
2.2.2 Sets
2.2.3 Indices
index
ix@
ix--
2.2.4 Name
name
name@
2.3 Contexts
2.3.1 Timeline
timeline
rewrite-in-timeline
2.3.2 Sequence
seq
rewrite-in-seq
!
seq-ref
ix-loop
expand-ix-loop
2.3.3 Namespace
namespace
rewrite-in-namespace
ref
resolve-ref
reify-art-definitions
namespace-provide-realizer

2 Core Library🔗ℹ

Art comes with a library of objects, coordinates, contexts, rewriters, and realizers which will be generally useful across various languages.

    2.1 General Forms

    2.2 Coordinates

      2.2.1 Interval

      2.2.2 Sets

      2.2.3 Indices

      2.2.4 Name

    2.3 Contexts

      2.3.1 Timeline

      2.3.2 Sequence

      2.3.3 Namespace

2.1 General Forms🔗ℹ

syntax

(define-art id art-statement ...)

Define an art variable. The statements are evaluated in an empty context.

syntax

(@ [coordinate ...] art-statement...)

Intuitively, run the given statements at the given coordinates.

This is accomplished by independently merging the given coordinates into the identity context of each statement, then running the statements.

syntax

(draw-realizer [width height])

Draw an artwork. See Extending the Draw Realizer.

syntax

(number value)

A number.

Example:
> (realize (draw-realizer [50 50]) (number 42))

image

syntax

(numbers number ...)

a series of indexed numbers, shorthand for (ix-- (number ...) (number ...) (number ...)).

Example:
> (realize (draw-realizer [300 50]) (seq (numbers 42 1.618 57 3.14)))

image

syntax

(symbol value)

A symbol.

Example:
> (realize (draw-realizer [50 50]) (symbol hello))

image

syntax

(hole)

Represents a place where an object might go.

Example:
> (realize (draw-realizer [50 50]) (hole))

image

syntax

(fill-holes id)

A rewriter which maps all holes within its coordinates to all objects of type id which surround the hole. The inserted objects will have their own identities and the same coordinates as the former hole.

Examples:
> (define-art square1  (seq (ix-- (numbers 1 4/3) (numbers 5/3 2))))
> (realize (draw-realizer [200 200]) square1)

image

> (define-art mystery-square (seq (ix-- (ix-- (hole) (symbol square)) (ix-- (symbol back) (hole)))))
> (realize (draw-realizer [200 200]) mystery-square)

image

> (realize (draw-realizer [200 200])
    (seq square1 mystery-square (run-apl (mix *ctxt*)) (fill-holes number)))

for: expected a sequence for expr, got something else: #<syn

tax:/home/root/user/.local/share/racket/8.12/pkgs/art-lib/pr

ivate/core.rkt:354:65 ((number 1) (number 4/3) (number 5/3)

(number 2) (hole) (symbol square) (symbol back) (hole))>

2.2 Coordinates🔗ℹ

2.2.1 Interval🔗ℹ

Intervals are coordinates with a start and an end. Interval within? is the intuitive definition of closed interval containment. Merging intervals offsets the right interval by the start of the left interval. Intervals are used in timelines and music.

syntax

(interval (start number) (end number))

An interval coordinate.

Example:
> (realize (draw-realizer [800 100])
    (timeline
      (@ [(interval (start 2) (end 5))] (symbol hello))
      (@ [(interval (start 5) (end 10))] (symbol world))))

image

syntax

(i@ [number number] body ...)

Shorthand for an interval.

Example:
> (realize (draw-realizer [800 100])
    (timeline
      (i@ [2 5] (symbol hello))
      (i@ [5 10] (symbol world))))

image

syntax

(-- number [number art-expr ...] ...)

syntax

(-- [number art-expr ...] ...)

Create a series of consecutive intervals of the given lengths, running the statements within those intervals. The first number determines the start of the first interval. If it is not provided then it is 0.

Example:
> (realize (draw-realizer [800 100])
    (timeline
      (-- 2 [3 (symbol hello)] [5 (symbol world)])))

image

syntax

(translate number)

Translate all intervals by the given amount.

Example:
> (realize (draw-realizer [800 100])
    (timeline
      (-- 2 [3 (symbol hello)] [5 (symbol world)])
      (translate -2)
      (-- 2 [3 (symbol hello-)] [5 (symbol world-)])))

image

syntax

(dilate number)

Dilate all intervals by the given factor. The distance between the target interval and the start of the dilation is also dilated (which is the intuitive behavior).

Examples:
> (realize (draw-realizer [800 100])
    (timeline
      (-- 1 [1 (symbol hello)] [1 (symbol world)])
      (dilate 4)
      (-- 1 [1 (symbol hello-)] [1 (symbol world-)])))

for: expected a sequence for expr, got something else: #<syn

tax:/home/root/user/.local/share/racket/8.12/pkgs/art-lib/pr

ivate/core.rkt:354:65 ((i@ (4 8) (symbol hello)) (i@ (8 12)

(symbol world)))>

> (realize (draw-realizer [800 100])
    (timeline
      (-- 1 [1 (symbol hello)] [1 (symbol world)])
      (i@ 1 (dilate 4))
      (-- 1 [1 (symbol hello-)] [1 (symbol world-)])))

for: expected a sequence for expr, got something else: #<syn

tax:/home/root/user/.local/share/racket/8.12/pkgs/art-lib/pr

ivate/core.rkt:354:65 ((i@ (1 5) (symbol hello)) (i@ (5 9)

(symbol world)))>

syntax

(loop number art-expr ...)

syntax

(expand-loop)

Represents a loop of the specified duration. The loop must be expanded within an interval and will be expanded to consecutive intervals containing the given expressions. It will be repeated as many times as fits cleanly into the surrounding interval. TODO explain rewriters inside loops

Example:
> (realize (draw-realizer [800 100])
    (timeline
      (i@ [0 30]
        (loop 10 (-- 2 [3 (symbol hello)] [5 (symbol world)])))
      (expand-loop)))

image

syntax

(rhythm number ...)

Represents a series of consecutive intervals of the given durations. A sequence and a rhythm can be converted to a concrete series of intervals via apply-rhythm. A type that is in context over the entire span of the rhythm can be converted to a concrtete series of intervals via rhythm->holes and fill->holes.

syntax

(uniform-rhythm number)

A rewriter that creates a rhythm subdividing its interval into equal parts of the provided length.

A rewriter that converts a rhythm to a consecutive series of holes. Useful in tandem with fill-holes.

Examples:
> (define-art world-domination-plan
    (timeline
      (i@ [0 3.5] (symbol Cat)) (i@ [0 2.5] (symbol Hello_____World)) (i@ [2 4] (symbol ___!))
      (rhythm 1 1.25 0.75 0.5)))
; Better decipher this, before it’s too late!
> (realize (draw-realizer [800 100]) world-domination-plan)

image

; We’ve had a breakthrough! We’ve almost got it...
> (realize (draw-realizer [800 100])
    world-domination-plan (rewrite-in-timeline (rhythm->holes)))

image

; Oh no, it’s all meowver—- *HISSSSS* [END TRANSMISSION]
> (realize (draw-realizer [800 100])
    world-domination-plan (rewrite-in-timeline (rhythm->holes) (fill-holes symbol)))

image

2.2.2 Sets🔗ℹ

Sets are coordinates with a set of identifiers. Set within? and merge can either be superset and union, or subset and intersection. Subset sets are used for voices in music. Superset sets are used for lexical scope.

2.2.3 Indices🔗ℹ

Indices are coordinates with a list of numbers. An index with n-numbers is called an n-dimensional index. Index within? is = and merge is append. Indices are used in sequences.

syntax

(index expr ...)

syntax

(ix@ [number ...] expr ...)

syntax

(ix-- expr ...)

2.2.4 Name🔗ℹ

Names are coordinates with a list of identifiers. Name within? is prefix match and merge is append. Names are used in namespaces.

syntax

(name id ...)

syntax

(name@ (id ...) expr ...)

2.3 Contexts🔗ℹ

2.3.1 Timeline🔗ℹ

Timelines are contexts equipped with an interval coordinate.

syntax

(timeline expr ...)

syntax

(rewrite-in-timeline expr ...)

Examples:
> (define-art layer3 (timeline (i@ [0 1] (number 42)) (i@ [2 3] (number 42))))
> (define-art layer2 (timeline (i@ [0 3] layer3) (i@ [6 9] layer3)))
> (define-art layer1 (timeline (i@ [0 9] layer2) (i@ [18 27] layer2)))
> (realize (draw-realizer [800 50]) layer1)

image

2.3.2 Sequence🔗ℹ

Sequences are contexts equipped with an index coordinate.

syntax

(seq expr ...)

syntax

(rewrite-in-seq expr ...)

Examples:
> (define-art the-seqs
    (ix--
      (seq (ix-- (number 42) (number 42) (symbol X)))
      (seq (ix-- (number 42) (symbol X) (number 42)))
      (seq (ix-- (symbol X) (number 42) (number 42)))))
> (realize (draw-realizer [500 50]) (seq the-seqs))

image

> (realize (draw-realizer [200 100]) (seq the-seqs (run-apl (mix *ctxt*))))

for: expected a sequence for expr, got something else: #<syn

tax:/home/root/user/.local/share/racket/8.12/pkgs/art-lib/pr

ivate/core.rkt:354:65 ((number 42) (number 42) (symbol X)

(number 42) (symbol X) (number 42) (symbol X) (number 42)

(number 42))>

syntax

(! ix)

syntax

(seq-ref)

syntax

(ix-loop expr ...)

syntax

(expand-ix-loop expr ...)

2.3.3 Namespace🔗ℹ

Namespaces are contexts equipped with a name coordinate.

syntax

(namespace expr ...)

syntax

(rewrite-in-namespace expr ...)

Example:
> (realize (draw-realizer [800 50])
    (namespace
      (name@ the-answer (number 42))
      (name@ the-questions
        (namespace
          (name@ q1 (symbol |What is 4 + 2?|))
          (name@ q2 (symbol Life))))))

image

syntax

(ref id)

syntax

(resolve-ref)

Namespaces have some convenient interactions with art definition forms.

syntax

(reify-art-definitions)

Reify identifiers bound using define-art into a namespace art. FIXME jagen this has 500 possible semantics and needs clarification.

Example:

syntax

(namespace-provide-realizer)

Compile all names in a namespace to racket art definitions, and provide them.

Examples:
> (module test racket
    (require art art/namespace)
    (realize (namespace-provide-realizer)
      (name@ the-answer (number 42))
      (name@ the-questions
        (namespace
          (name@ q1 (symbol |What is 4 + 2?|))
          (name@ q2 (symbol Life))))))
> (require 'test)
> (realize (draw-realizer [50 50]) the-answer)

image

A cool technique is possible using the two forms above- running a transform over an entire module before exporting.

Examples:
> (module test2 racket
    (require art art/namespace art/sequence art/sequence/ravel)
  
    ; <Foo, Bar>
    (define-art thing1 (seq (ix-- (symbol Foo) (symbol Bar))))
  
    ; <1, 2, 3>
    (define-art thing2 (seq (numbers 1 2 3)))
  
    ; provide the definitions, but reversed and repeated 3 times, for demo purposes.
    (realize (namespace-provide-realizer)
      (reify-art-definitions)
      (rewrite-in-seq (run-apl (replicate (lit 3) (enclose (apl:reverse *ctxt*)))))))

for: expected a sequence for expr, got something else: #<syn

tax:/home/root/user/.local/share/racket/8.12/pkgs/art-lib/pr

ivate/core.rkt:354:65 ((seq (number 3) (number 2) (number

1)) (seq (number 3) (number 2) (number 1)) (seq (number 3)

(number 2) (number 1)))>

> (require 'test2)

require: unknown module

  module name: 'test2

> (realize (draw-realizer [800 50]) thing1 thing2)

eval:36:0: run-art-expr: unknown var: #<syntax:eval:36:0

thing1>

  in: thing1