arthur/clips/migrations/0016_an_anchor_is_a_peg.py

43 lines
1.9 KiB
Python
Raw Normal View History

An anchor is a peg `[:xform :anchor]` is deleted. `T(a)·M·T(-a)` is a transform conjugated by a translation — "do M in a frame shifted by a" — and a parent already IS a shifted frame, so an anchor was a peg written inline: one that could not be selected, keyed, shared between nodes, or placed above a measured channel. Same expressive content, strictly less reach. `node-test` asserts the two produce the same matrix. Its two jobs split, and neither is a field on a node any more. A pivot nobody chose is DERIVED PER DRAG and stored nowhere. `gesture/pivot` is the middle of what the node draws — `pick/bounds-of`, the same call the stage draws the selection box from, on the same frame — or the node's own origin when it draws nothing. `gesture/about` solves for the position that holds that point still, so a turn now writes `pos` as well as `rot`. Nothing is cached, so nothing goes stale: the stored anchor was that same middle captured once at creation while the box beside it was recomputed every render, so on anything edited since it was made the cross and the box disagreed and the pivot was wrong. A symbol with more than one node diverged on its first edit. A pivot somebody chose is a PEG — `nest/peg`, an ordinary `:group` parent sitting on the derived pivot with `:pinv` captured so nothing moves. It is the answer to the three things a derived pivot cannot do: a pivot that persists (an arm about its shoulder), a pivot that travels (a keyed `pos`), and a hand transform over a measured one. The last was impossible before — `local`'s translation is `pos − M·a`, so under a measured `M` writing an anchor moves the thing it was meant to leave alone. `flow/freeze`'s `pivoted` pass knew this and skipped every `node/measured?` node, which is exactly why the traced mouth pivoted about (-234, -395) on a 320x200 stage: the top-left corner of the footage. That pass is gone; there is no node a derived pivot can be missing from. `demo/stage` is the one place the anchor did work a static `pos` cannot: `:scale` is keyed, and the source's middle has to stay on its authored centre throughout. It is now seven pegs, identical to the pixel. Also: `events/ui`'s `fitted` rescales a dropped tracing right after placement, and the anchor had been silently keeping the picture centred through that; it solves for the middle explicitly now. Schema 7. Nothing is converted, as in 6: every project is marked 7 and one still carrying an anchor is refused by name, with what to do about it. Dropping an anchor is pixel-exact wherever rotation and scale are the identity — everywhere a freeze or a drop wrote one — but not on anything since turned by hand, and not at all where `pos` is dense, so a conversion would be silent and wrong for exactly the nodes somebody had placed themselves. 601 CLJS tests, 68 Django tests, and the onion and take browser suites pass. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HkinzDz1VtahZVsujAGRBD
2026-10-05 19:12:16 -04:00
"""Schema 7: an anchor is a peg.
`[:xform :anchor]` is gone from the transform. `T(a)·M·T(-a)` is a transform
conjugated by a translation — "do M in a frame shifted by a" — and a parent
already is a shifted frame, so an anchor was a peg written inline: one that could
not be selected, keyed, shared between nodes, or placed above a measured channel.
A pivot nobody chose is now derived from what the node draws, per drag, and stored
nowhere; a pivot to keep is a peg, an ordinary `:group` parent.
Nothing is converted, as in schema 6. Every project is marked 7, and one that
still carries an anchor is refused when it is opened, by name and with what to do
about it — `node/problems` in the frontend.
Not converted rather than not worth converting. Dropping an anchor is in fact
pixel-exact wherever rotation and scale are the identity, since the anchor
cancels out of the composition there — and that is everywhere a freeze, a drop or
a new drawing wrote one. It is NOT exact on anything a hand has since turned or
scaled, where the composed translation is `a + p - M·a`, and it cannot be made
exact at all where `pos` is dense, because tier 2 is content-addressed and not
rewritable here. A conversion would therefore be silent and right for most nodes
and silent and wrong for exactly the ones somebody had hand-placed, which is the
worse failure: a refusal names the document and says what to do.
"""
from django.db import migrations, models
def forwards(apps, schema_editor):
apps.get_model("clips", "Project").objects.update(schema_version=7)
class Migration(migrations.Migration):
dependencies = [("clips", "0015_tracing_images")]
operations = [
migrations.AlterField(
model_name="project",
name="schema_version",
field=models.PositiveIntegerField(default=7),
),
migrations.RunPython(forwards, migrations.RunPython.noop),
]