Nothing

What stays fixed when I rotate or resize?

Rotate a drawable or change its dimensions around a chosen point.

Read as Markdown

Set rotate on the shape to turn its picture about the drawable’s pivot. Set width on the rectangle to change its local geometry about the registration point. Both points start at the shape’s local origin in the sampled rectangle scene.

Keep the center fixed

The first shape’s translation places its local origin at (32, 24). Its rectangle uses the default center registration. The shape owns the rotation track and the rectangle owns a separate width track.

FrameShape rotationLocal rectangle sizePainted footprint in scene coordinates
00°12 × 812 × 8
490° clockwise12 × 88 × 12
890° clockwise20 × 88 × 20

The footprint stays centered at (32, 24). At frame 8 the 20-unit local X dimension appears vertical because the shape’s rotation applies after computing its local geometry.

Keep the left edge mounted

Set anchor-u="0" on the first rectangle and leave anchor-v at its default of 0.5. Its local left-edge midpoint now sits at the shape pivot, (32, 24) in the scene. At frame 8 the rotated rectangle extends downward from y = 24 to 44.

Set a geometry offset to move the registration point within the drawable. Set a drawable pivot to move the rotation point. Use a group to transform several drawables together, or a locator to keep a child mounted on the geometry. Registration and offset · Local-to-parent transforms

Examples

The shape owns the rotation. The rectangle owns its local width. The shape’s translation and the rectangle’s default center registration keep the painted rectangle centered at (32, 24).

Download the complete .nothing source · Source on GitHub

Rendered with ncf-preview at 80 × 56.

A 12 × 8 white rectangle centered at (32, 24). Three smaller registration examples sit to its right.
Frame 0 · Initial poseA 12 × 8 white rectangle centered at (32, 24). Three smaller registration examples sit to its right.
The rectangle turns 90° clockwise. Its painted extent is 8 × 12 and its center stays at (32, 24).
Frame 4 · Quarter turnThe rectangle turns 90° clockwise. Its painted extent is 8 × 12 and its center stays at (32, 24).
The local width increases to 20 while the quarter turn holds. The painted extent is 8 × 20 and its center stays at (32, 24).
Frame 8 · Wider rectangleThe local width increases to 20 while the quarter turn holds. The painted extent is 8 × 20 and its center stays at (32, 24).
XML source
  <shape translate-x="32" translate-y="24">
    <animate attributeName="rotate" fill="freeze">
      <key frame="0" value="0" ease="linear"/>
      <key frame="4" value="90"/>
    </animate>
    <rect width="12" height="8">
      <animate attributeName="width" fill="freeze">
        <key frame="4" value="12" ease="linear"/>
        <key frame="8" value="20"/>
      </animate>
    </rect>
    <fill><paint><solid color="#FFFFFFFF"/></paint></fill>
  </shape>

On this page