shapeslib
A shape is a Blitz object, numbered from 0: a graphic of its own width,
height and depth, kept in chip memory, so that the blitter can draw it
fast. The blitting libraries draw shapes into bitmaps, WBlit into
windows, and gadgets and menu items can show them.
A shape has a handle, the point of it that a drawing command places
at the given position; it is the top left corner unless Handle or
MidHandle moves it. A shape can also have a cookie, a mask of all
its pixels that are not colour 0, which drawing commands use to leave
the background visible around the shape. With AutoCookie On, which is
the start value, every shape that is loaded or made gets its cookie
automatically.
A shape keeps the size the blitter draws it with in one word, so it can be at most 1023 rows high and 992 pixels wide, and each of its planes must be smaller than 64 KB. For a larger image, use a bitmap.
LoadShape loads an IFF ILBM picture as a shape; an IFF ANIM file
gives one shape per frame, in the following shape numbers. SaveShapes
and LoadShapes save and load shapes in Blitz’s own file format, and
DecodeShapes reads that format from memory, for example from data
included in the program. With runtime error checking, using a shape
that is not there is the error “Uninitialized Shape”.
Library number 154. It manages Shape objects, by default at most 100 (the compiler options set the maximum).
Commands
AutoCookie
With On, the shapes loaded or made from now on get their cookie automatically; On is the start value.
Statement. Help text: On|Off
Arguments: .w
CopyShape
Copies the first shape into the second.
Statement. Help text: Shape#,Shape#
Arguments: .w, .w
DecodeShapes
Reads shapes in the format of SaveShapes from memory, such as data included in the program with IncBin. Data in chip memory is used where it is.
Statement. Help text: Shape#[,Shape#],MemoryLocation
2 forms:
.w, .l.w, .w, .l
With the address 0, the error is “Shapes file at memory location 0? NOWAY!”.
GetaShape
Makes a shape from an area of the used bitmap.
Statement. Help text: Shape#,X,Y,Width,Height
Arguments: .w, .w, .w, .w, .w
With runtime error checking, an area too large for a shape is the
error “Shape too Big”, with the limits of InitShape.
Handle
Sets the handle of the shape, the point placed at the position given to drawing commands.
Statement. Help text: Shape#,X,Y
Arguments: .w, .w, .w
InitShape
Makes an empty shape of the given width, height and depth. With runtime error checking, a depth of 0 is the error “Illegal Shape Depth”.
Statement. Help text: Shape#,Width,Height,Depth
Arguments: .w, .w, .w, .w
With runtime error checking, a width or height of 0 is the error “Illegal Shape Size”, and a shape too large the error “Shape too Big”. These are the limits:
- The size of one plane with its extra word per row, (⌈width / 16⌉ × 2 + 2) × height bytes, must stay below 65536 (64 KB).
- The height is at most 1023 rows.
- The width is at most 992 pixels.
LoadShape
Loads an IFF ILBM picture as a shape, and with Palette# its colours into that palette object. An IFF ANIM file gives its first frame in this shape and each further frame in the next shape number.
Statement. Help text: Shape#,Filename$[,Palette#]
2 forms:
.w, $.w, $, .w
Only ANIM files of the usual compression (method 5) are read; others give “ANIM format not supported”. Each frame is made from the frame its header names: two frames back, as most ANIM files have it (double buffering), or the one before it, or any number of frames back. The frames go into the shape numbers up to the highest one; the rest of the animation is not loaded.
A picture that does not fit a shape is the error “Can’t Read/Write
Shapes File”, also without runtime error checking. The limits are
those of InitShape:
- The size of one plane with its extra word per row, (⌈width / 16⌉ × 2 + 2) × height bytes, must stay below 65536 (64 KB); 992 by 528 pixels is too large.
- The height is at most 1023 rows.
- The width is at most 992 pixels.
A picture whose header gives 0 bitplanes is the error “Illegal Shape Depth”; one whose header gives a width or a height of 0 is the error “Illegal Shape Size”. Both are errors also without runtime error checking.
“ANIM format not supported” comes after the first frame is loaded. The file is closed before the error, and the shape keeps the first frame.
LoadShapes
Loads shapes from a file saved with SaveShapes, into the range of shape numbers given, or from the first number on.
Statement. Help text: Shape#[,Shape#],Filename$
2 forms:
.w, $.w, .w, $
MakeCookie
Makes the cookie of the shape, the mask of all its pixels that are not colour 0.
Statement. Help text: Shape#
Arguments: .w
MidHandle
Puts the handle of the shape in its middle.
Statement. Help text: Shape#
Arguments: .w
SaveShapes
Saves a range of shapes, from the first to the second number, into a file in Blitz’s shapes format.
Statement. Help text: Shape#,Shape#,Filename$
Arguments: .w, .w, $
Shape
The object of a shape, as the introduction describes.
Object name. Help text: - image
ShapeHeight
The height of the shape in pixels.
Function, result .w. Help text: (Shape#)
Arguments: .w
ShapeWidth
The width of the shape in pixels.
Function, result .w. Help text: (Shape#)
Arguments: .w