Skip to content

shapetrixlib

These commands change a shape object in place: Scale stretches or shrinks it, Rotate turns it, and XFlip and YFlip mirror it. The shape gets new image data, and a new cookie if it had one, so it can be drawn at once. Each change works on the pixels, so repeated changes lose detail: to show several sizes or angles of one image, make each from a copy of the original shape, for example with CopyShape.

LoadShape 0,"ship.iff"
CopyShape 0,1
Rotate 1,.25
Scale 1,.5,.5

The ratios and the angle are numbers with a fraction, as quick values.

Based on the shapetrixlib guide by Acid Software.

Library number 118.

Commands

Rotate

Turns a shape by Angle Ratio of a full turn, from 0 to 1; .25 turns it by 90 degrees and .5 by 180 degrees. The shape gets the size of the turned image, and its handle becomes the top left corner.

Statement. Help text: Shape#,Angle Ratio
Arguments: .w, .q

With runtime error checking, a turned image too large for a shape is the error “Shape too Big”, with the limits of InitShape.

Scale

Stretches or shrinks a shape, its width by X Ratio and its height by Y Ratio; a ratio above 1 enlarges, below 1 reduces, and 1 keeps that size. The two ratios may differ.

Statement. Help text: Shape#,X Ratio,Y Ratio[,Palette#]
2 forms:

  • .w, .q, .q
  • .w, .q, .q, .w

When the shape shrinks, each new pixel gets the colour that covers most of the pixels it replaces. With Palette#, the colours are weighed by their brightness in that palette instead, so that bright details survive. A size that would fall below one pixel becomes one pixel, made from the whole row or column of the shape. With runtime error checking, a new size too large for a shape is the error “Shape too Big”, with the limits of InitShape.

XFlip

Mirrors a shape horizontally, from left to right.

Statement. Help text: Shape#
Arguments: .w

YFlip

Mirrors a shape vertically, upside down.

Statement. Help text: Shape#
Arguments: .w