[id] = PenArrayToBrush(id, table, width, height[, t])
table
. The table can be seen as a matrix containing height
number of rows where each row has width
number of elements, stored
sequentially. The order of the pen data in this table must be as follows:
Row after row in top-down format, i.e. the table starts with the first row of pens.
Each row must contain exactly width
number of pens, and there must
be exactly height
number of rows. The table must be one-dimensional,
i.e. it mustn't use subtables for the individual rows but just store
the pen values sequentially.
The palette that the pens should use can be set in the optional table
argument t
. The following table elements are currently recognized:
Palette:
TransparentPen:
#NOPEN
, which
is also the default.
Please note that the table that you pass to this function will usually eat lots of memory. Thus, you should set this table to Nil as soon as you no longer need it. Otherwise you will waste huge amounts of memory and it could even happen that your script runs out of memory altogether. So please keep in mind that you should always set pixel array tables to Nil as soon as you are done with them.
To convert a palette brush to a pen array, you can use the BrushToPenArray() function. See BrushToPenArray for details.
pixels = {} For Local y = 0 To 479 For Local x = 0 To 639 Do pixels[y * 640 + x] = y \ 2 Next PenArrayToBrush(1, pixels, 640, 480, {Palette = #PALETTE_AGA}) pixels = Nil ; IMPORTANT: free memory! DisplayBrush(1, 0, 0)The code above creates a palette brush that contains the first 240 pens from the default palette
#PALETTE_AGA
. Each palette pen uses two rows.
Important: Do not forget to set the pixel array to Nil when
you no longer need it because otherwise it will stay in memory and pixel arrays
will eat huge amounts of memory!