Glimma

View the Project on GitHub ztripez/glimma

Glimma DSL Specification

This document defines the syntax and semantics of the Glimma animation language. Refer to the project README for the high level overview.

Overview

Glimma is a declarative language for creating SVG animations. A .glimma file contains one or more scenes, each defining shapes, groups, and timelines that orchestrate animations.

Basic Structure

scene SceneName {
  shape shapeId shapeType attr1=value1 attr2=value2
  group groupId {
    shape nestedShape rect x=10 y=10
  }
  timeline:
    0s: shapeId fadeIn over 2s
    1s: groupId move x=100 over 1.5s
}

Scenes

A scene is the top-level container for an animation. Each scene generates a separate animation output.

scene demo {
  // shapes, groups, timeline
}

Shapes

Shapes define visual elements that can be animated.

shape shapeId shapeType attribute=value

Shape Types

Rectangle (rect)

shape box rect x=10 y=10 width=100 height=50 fill="blue"

Circle (circle)

shape dot circle cx=50 cy=50 r=20 fill="#ff0000"

Text (text)

shape label text content="Hello World" x=10 y=30

Path (path)

shape line path d="M10 80 L60 80" stroke="black"

Common Attributes

All shapes support:

Groups

Groups allow hierarchical organization of shapes for collective animation.

group groupId {
  shape child1 rect x=0 y=0 width=20 height=20
  shape child2 circle cx=30 cy=10 r=5
  group nestedGroup {
    shape grandchild text content="nested" x=0 y=40
  }
}

Timeline

The timeline defines when and how animations occur.

timeline:
  0s: target action over duration
  1.5s: target action attribute=value over duration

Timeline Entry Format

timeInSeconds: targetId actionType [attributes] over durationInSeconds

Animation Actions

fadeIn

0s: box fadeIn over 2s

Animates opacity from 0 to 1.

fadeOut

2s: box fadeOut over 1s

Animates opacity from current value to 0.

move

1s: box move x=200 over 1.5s

Translates element to new position.

rotate

2s: box rotate angle=45 over 2s

Rotates element around its center.

scale

1s: circle scale factor=1.5 over 2s

Scales element size.

Comments

Comments start with # and continue to end of line:

# This is a comment
scene demo {
  shape box rect x=10 y=10  # inline comment
}

Value Types

Numbers

Strings

Identifiers

Example

scene intro {
  shape background rect x=0 y=0 width=400 height=300 fill="#f0f0f0"
  shape title text content="Welcome" x=50 y=50
  
  group controls {
    shape button rect x=50 y=100 width=80 height=30 fill="blue"
    shape buttonText text content="Click" x=70 y=120 fill="white"
  }
  
  timeline:
    0s: background fadeIn over 0.5s
    0.5s: title fadeIn over 1s
    1.5s: controls fadeIn over 0.8s
    3s: controls move x=200 over 2s
    5s: title fadeOut over 1s
}