Non-destructive transforms
Image, paint, and shape layers support non-destructive transforms. These transforms are applied at render time without modifying the source pixel data.Position
Move a layer by setting itsx and y coordinates:
Rotation
Rotate a layer by an arbitrary angle (in degrees, clockwise):Scale
Scale a layer horizontally and vertically:Flip
Flip a layer along the X or Y axis:Anchor points
The anchor determines the origin point for transforms. Two options are available:topLeft(default): Transforms are applied relative to the top-left cornercenter: Transforms are applied relative to the center of the layer
Combined example
All transform properties can be set together:Destructive transforms
These operations permanently modify the layer’s pixel buffer.Resize
Resize a layer using one of three algorithms:Nearest-neighbor
Fast and lossless for pixel art:Bilinear
Smooth interpolation for photos:Lanczos3
Highest quality for photo downscaling (slower):Crop
Extract a rectangular sub-region:Trim
Auto-crop to the bounding box of non-transparent pixels:Rotate (destructive)
Rotate by an arbitrary angle with bilinear interpolation. The output buffer is sized to contain the full rotated image:For 90-degree-increment rotations, prefer the non-destructive
rotation property which is lossless and faster.Transform performance
Non-destructive transforms are cached at render time. If you apply the same transform multiple times, only the first render will compute the transformed raster. Subsequent renders reuse the cached result until the source buffer or transform properties change. See~/workspace/source/crates/kimg-core/src/transform.rs:1-18 for resize algorithm details and ~/workspace/source/crates/kimg-core/src/layer.rs:132-168 for the transform cache implementation.