About Adam

  • Adam is a language to describe the relationships between values
  • The basic construct is a sheet containing cells and relationships between cells
  • As cells are edited, the relationships are upheld in a predictable manner
    • The primary use is to control UI behavior
  • Sheets support recording and playback, designed to support Ps Actions
    • Capturing a dictionary (unordered) of the source values and applying it to a fresh sheet guarantees the same result

A first sheet

Change width or height. Source cells hold the values you write.

sheet hello {
    source width = 1920;
    source height = 1080;
}

Filters

Enter a value outside 0-100 and watch level return to its domain.

sheet volume {
    source level: i32 = 50 filter 0..=100;
}

Out cells

Change width or height. The forced output area follows automatically.

sheet area_demo {
    source width = 10 filter 0..=100;
    source height = 20 filter 0..=100;

    out area := width * height;
}

Cells and relationships

Edit either a or b. Watch the graph reverse its flow to preserve your edit.

sheet basic_relationship {
    cell a: f64 filter 0.0..=200.0;
    cell b = 2.0 filter 0.0..=100.0;

    relationship {
        a := b * 2.0;
        b := a / 2.0;
    }
}

Chained relationships

Move a to 100, then back to 0. The previous values of b and c return.

sheet inequality {
    cell a = 10 filter 0..=100;
    cell b = 20 filter 0..=100;
    cell c = 30 filter 0..=100;

    relationship {
        a := min(a, b);
        b := max(a, b);
    }

    relationship {
        b := min(b, c);
        c := max(b, c);
    }
}

Conditionals

Enable constrain to link a and b; disable it to edit them independently.

sheet constrain {
    source constrain = false;
    cell a = 5 filter 1..=100;
    cell b = 10 filter 1..=100;

    conditional constrain {
        true => {
            relationship {
                a := b;
                b := a;
            }
        }
    }
}

Forced conditional values

Enable constrain to force a to 42. Disable it to restore the source value.

When the value of a cell is forced, the widget is disabled.

sheet conditional_forced {
    source constrain = false;
    cell a = 5 filter 1..=100;

    conditional constrain {
        true => {
            relationship {
                a := 42;
            }
        }
    }
}

Filter diagnostics

The derived width exceeds its filter. Edit height to explore the diagnostic.

sheet filter_diagnostic {
    cell width: i32 filter 0..=100;
    cell height = 150 filter 0..=200;

    relationship {
        width := height;
        height := width;
    }
}

Requirements

Set width and height to 100. The output reports its violated requirement.

sheet area_demo {
    source width = 10 filter 1..=100;
    source height = 10 filter 1..=100;

    out area := width * height require {
        @not_too_big area <= 1000;
    };
}

Composed

sheet three_way {
    source ratio = 3.0 / 5.0;
    source resolution = 72.0;
    cell lock = false;
    cell width_pixels: f64;
    cell height_pixels: f64;
    cell width_inches = 3.0;
    cell height_inches = 5.0;

    relationship {
        width_pixels := width_inches * resolution;
        width_inches := width_pixels / resolution;
    }
    relationship {
        height_pixels := height_inches * resolution;
        height_inches := height_pixels / resolution;
    }

    conditional lock {
        true => {
            relationship {
                width_pixels := height_pixels * ratio;
                height_pixels := width_pixels / ratio;
            }
        }
    }
}