Skip to content

2dlib

These commands draw on the used bitmap, in both modes, mostly with the blitter. With Line, Box, Boxf, Circle, Circlef and Poly, a colour of -1 inverts the pixels drawn instead of setting them; Polyf draws nothing with a negative colour. Drawing is clipped to the edges of the bitmap.

Use BitMap 0
Line 0,0,319,199,1
Box 10,10,100,60,2
Circlef 160,100,40,20,3

Poly and Polyf take their points from memory, as pairs of words: an array or a NewType of words, given by the address of its first element.

Dim pts.w(5)
pts(0)=10 : pts(1)=10 : pts(2)=100 : pts(3)=10 : pts(4)=50 : pts(5)=80
Polyf 3,&pts(0),2

Circlef, FloodFill and ReMap work through a buffer of one bitplane the size of the bitmap, which the library makes when it first needs it; FreeFill frees it. BitMapOrigin moves the point 0,0 of a bitmap for Line, Box, Boxf, Circle, Poly and Polyf (not for Circlef). BitPlanesBitMap and BitMapWindow make a second bitmap object that shows a part of another one.

Based on the 2dlib guide by Acid Software.

Library number 119.

Commands

AllocFill

Makes the fill buffer for the used bitmap. It is declared for internal use only, and a program does not need it, since Circlef, FloodFill and ReMap make the buffer themselves.

Statement. Help text: for internal use only (polylib.obj)
No arguments.

BitMapOrigin

Moves the point 0,0 of the bitmap to x,y, for Line, Box, Boxf, Circle, Poly and Polyf (not for Circlef).

Statement. Help text: BitMap#,x,y
Arguments: .w, .w, .w

BitMapWindow

Makes destbitmap a bitmap that shows the area of srcbitmap at x,y, w pixels wide and h high. Drawing into it with the commands of this library stays inside that area.

Statement. Help text: srcbitmap,destbitmap,x,y,w,h
Arguments: .w, .w, .w, .w, .w, .w

x and w are rounded down to multiples of 16. Nothing happens when destbitmap already holds a bitmap.

BitPlanesBitMap

Makes destbitmap a bitmap that shows only the bitplanes of srcbitmap selected by the bits of planepick. Drawing on fewer planes is faster. Nothing happens when destbitmap already holds a bitmap.

Statement. Help text: srcbitmap,destbitmap,planepick
Arguments: .w, .w, .w

Box

Draws the outline of a rectangle with the corners x1,y1 and x2,y2.

Statement. Help text: x1,y1,x2,y2,color
Arguments: .w, .w, .w, .w, .w

The origin set with BitMapOrigin is added once, as for Line and Boxf; Blitz Basic 2 added it twice (Box added the bitmap origin twice).

Boxf

Draws a filled rectangle with the corners x1,y1 and x2,y2.

Statement. Help text: x1,y1,x2,y2,color
Arguments: .w, .w, .w, .w, .l

Circle

Draws a circle of radius rx around x,y, or an ellipse with the radii rx and ry.

Statement. Help text: x,y,rx[,ry],color
2 forms:

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

The parts of the circle beyond the edges of the bitmap are not drawn.

Circlef

Draws a filled circle of radius rx around x,y, or a filled ellipse with the radii rx and ry.

Statement. Help text: x,y,rx[,ry],color
2 forms:

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

As with Circle, the parts beyond the edges of the bitmap are not drawn.

ClipBlit

Draws a shape as Blit does, but cuts it at the edges of the used bitmap. Excess sets the bitplanes beyond the shape’s depth under the shape, a bit for each, 1 to set and 0 to clear.

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

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

ClipBlitMode

The blitter mode (the value of the BLTCON0 register) with which ClipBlit draws; the start value is $FCA, as for BlitMode.

Statement. Help text: BPLCON0
Arguments: .w

FloodFill

Fills the area around x,y with colour. Without border colour, the area is all connected pixels of the colour at x,y; with it, all pixels up to a border of that colour.

Statement. Help text: x,y,colour [,border colour]
2 forms:

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

FreeFill

Frees the fill buffer that Circlef, FloodFill and ReMap use; the next of them makes it again.

Statement. Help text: frees memory allocated for 2d fill routines
No arguments.

Line

Draws a line from x1,y1 to x2,y2; without x1,y1, from the end of the last line drawn. width makes the line thicker by that many pixels.

Statement. Help text: [x1,y1,]x2,y2,color[,width]
3 forms:

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

Poly

Draws the outline of a polygon of numpts points, which are pairs of words at the address given.

Statement. Help text: numpts,*coords.w,color
Arguments: .w, .l, .w

With runtime error checking, fewer than 2 points are the error “Poly needs at least 2 Points”.

Polyf

Draws a filled polygon of numpts points, which are pairs of words at the address given. A polygon whose points run anticlockwise is drawn in color2 if it is given, which helps to show the back of a face in 3D graphics.

Statement. Help text: numpts,*coords.w,color[,color2]
2 forms:

  • .w, .l, .w
  • .w, .l, .w, .w

The direction is taken from the first three points. A negative colour draws nothing. A polygon has at most 16 points; with runtime error checking, more are the error “Too Many Points”.

ReMap

Gives every pixel of the used bitmap that has the first colour the second colour. With a destination bitmap, the pixels of the first colour get the second colour there instead.

Statement. Help text: colour# to replace,destination colour# [,BitMap destintion
2 forms:

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