PrintAt

Bitmaps
Aptilis 1

PrintAt(BitmapHandle, x, y, String, Colour)

PrintAt will write a string at a given position in previously created bitmap.
The coordinates given indicate the lower left corner of the rectangular zone in which the string is going to be written.

PrintAt uses a fixed-size font by default where all letters have a width of 8 pixel and a height of 16.
You can specify a font to use in a bitmap with setFont in which case it is difficult to estimate the length of a string, unless you call getStringMetrics.

Return Value:
0 if everything was OK or -1 if you indicated a non-valid bitmap.

Example:

b = createBitmap(250, 50)
if b = -1
print("Ooops, could not create the bitmap....\n")
else

// White background
clearBitmap(b, RGB(255, 255, 255))

// Unix user need to find a true type font and copy its file
// somewhere on their system, and refer to it here correctly.
// Windows user can choose another ttf file if they want.

setFont(b, "c:\\windows\\system\\aribl0.ttf", 20)

getStringMetrics(b, mf[], "Aptilis is ")
getStringMetrics(b, ms[], "COOL!")

// total width
w = mf[0] + ms[0]


x = (250 - w) / 2
// The y coordinate is the bottom of the string, hence the plus.
y = (50 + mf[1]) / 2


printAt(b, x, y, "Aptilis is", RGB(0, 0, 0))
printAt(b, x + mf[0], y, "COOL!", RGB(0, 255, 255))

saveGIFFile("font.gif", b)


end if
Result:

For more details see the Bitmap topic.