-
Notifications
You must be signed in to change notification settings - Fork 8
Graphics Library API
Brom Bresenham edited this page Jan 30, 2026
·
16 revisions
extends BitmapBlitFn
| Signature | Return Type | Description |
|---|---|---|
| call( src:Bitmap, src_x1:Int, src_y1:Int, dest:Bitmap, dest_x1:Int, dest_y1:Int, blit_width:Int, blit_height:Int ) |
extends BitmapBlitFn
| Name | Type | Description |
|---|---|---|
| color | Color |
| Signature | Return Type | Description |
|---|---|---|
| init( color:Color ) | ||
| call( src:Bitmap, src_x1:Int, src_y1:Int, dest:Bitmap, dest_x1:Int, dest_y1:Int, blit_width:Int, blit_height:Int ) |
extends Object
| Name | Type | Description |
|---|---|---|
| transparent_checkerboard_evens | Color | |
| transparent_checkerboard_odds | Color |
| Signature | Return Type | Description |
|---|---|---|
| create( bytes:Byte[] ) | Bitmap | |
| create( existing:Bitmap, subset:Box ) | Bitmap | |
| create( file:File ) | Bitmap | |
| create( width:Int, height:Int ) | Bitmap | |
| decode( bytes:Byte[] ) | Bitmap | |
| decode_bmp( bytes:Byte[] ) | Bitmap | |
| decode_heic( bytes:Byte[] ) | Bitmap | |
| decode_jpeg( bytes:Byte[] ) | Bitmap | |
| decode_png( bytes:Byte[] ) | Bitmap | |
| decode_webp( bytes:Byte[] ) | Bitmap | |
| detect_string( bytes:Byte[], index:Int, string:String ) | Logical | |
| encode_data( bytes:Byte[], [width=0:Int] ) | Bitmap |
Creates a bitmap that uses the raw bytes as pixel values so that a chunk of data can be saved as a PNG or other lossless format. Use decode_data[] to reverse the process. Every three bytes is stored as an R,G,B value with an alpha of 255 (1.0). We can't reliably use the alpha byte as storage because various graphics routines will fuss with alpha values in one way or another. Examples include premultiplying RGBxA upon loading and using 7-bit alpha instead of 8-bit alpha. |
| load( file:File ) | Bitmap |
| Name | Type | Description |
|---|---|---|
| error | String | |
| filepath | String | |
| height | Int | |
| is_premultiplied_alpha | Logical | |
| pixels | Color[] | |
| width | Int |
| Signature | Return Type | Description |
|---|---|---|
| init( existing:Bitmap, bounds:Box ) | ||
| init( size:XY, [color=Color(0):Color] ) | ||
| init( size:XY, pixels:Color[] ) | ||
| init( width:Int, height:Int, color:Color ) | ||
| init( width:Int, height:Int, pixels:Color[] ) | ||
| add_rows( rows:Int, [color=0:Color] ) | ||
| all_pixels_are_transparent( [bounds=null:Box?] ) | Logical | |
| blit( bounds:Box, dest_bitmap:Bitmap, [dest_position=XY(0,0):XY], [blit_fn=BitmapBlitFn.OPAQUE:BitmapBlitFn] ) | ||
| blit( bounds:Box, dest_bitmap:Bitmap, x:Int, y:Int, [blit_fn=BitmapBlitFn.OPAQUE:BitmapBlitFn] ) | ||
| blit( dest_bitmap:Bitmap, [pos=XY(0,0):XY], [blit_fn=BitmapBlitFn.OPAQUE:BitmapBlitFn] ) | ||
| blit( dest_bitmap:Bitmap, x:Int, y:Int, [blit_fn=BitmapBlitFn.OPAQUE:BitmapBlitFn] ) | ||
| clear( [color=Color(0):Color] ) | ||
| cloned() | Bitmap | |
| convert_gray_to_alpha() | ||
| crop( delta:Int, [pad_color=Color(0):Color] ) | ||
| crop( left:Int, top:Int, right:Int, bottom:Int, [pad_color=Color(0):Color] ) | ||
| crop( new_width:Int, new_height:Int, [anchor=Anchor.TOP_LEFT:Anchor], [pad_color=Color(0):Color] ) | ||
| crop( subset_bounds:Box ) | ||
| cropped( delta:Int, [pad_color=Color(0):Color] ) | Bitmap | |
| cropped( left:Int, top:Int, right:Int, bottom:Int, [pad_color=Color(0):Color] ) | Bitmap | |
| cropped( new_width:Int, new_height:Int, [anchor=Anchor.TOP_LEFT:Anchor], [pad_color=Color(0):Color] ) | Bitmap | |
| decode_data( [start_x=0:Int], [start_y=0:Int], [byte_count=-1:Int], [bytes=Byte[]:Byte[]] ) | Byte[] | See encode_data() |
| draw( box:Box, color:Color ) | ||
| draw( box:Box, color:Color, channel_mask:Int ) | ||
| draw( line:Line, color:Color, [thickness=1:Real] ) | ||
| expand_to_power_of_2() | ||
| expand( delta:Int, [pad_color=Color(0):Color] ) | ||
| expand( left:Int, top:Int, right:Int, bottom:Int, [pad_color=Color(0):Color] ) | ||
| extend_edges( bounds:Box ) | ||
| extract( subset_bounds:Box ) | Bitmap | |
| fill( box:Box, color:Color, [channel_mask=0xFFFFFFFF:Int32] ) | ||
| fill( box:Box, color_gradient:ColorGradient, [fn=ColorGradientBitmapFillFn:ColorGradientBitmapFillFn], [channel_mask=0xFFFFFFFF:Int32] ) | ||
| fill( box:Box, fn:BitmapFillFn, [channel_mask=0xFFFFFFFF:Int32] ) | ||
| fill( quad:Quad, color:Color ) | ||
| fill( triangle:Triangle, color:Color ) | ||
| flip( &h, &v ) | ||
| get( x:Int, y:Int ) | Color | |
| get( xy:XY ) | Color | |
| is_opaque() | Logical | |
| is_power_of_2() | Logical | |
| non_transparent_bounds( &top, &left, &bottom, &right ) | Box? | |
| operator+( rhs:Bitmap ) | Bitmap | Join two bitmaps side by side - this on the left and rhs on the right. If necessary the shorter bitmap will be aspect-resized to match the height of the taller bitmap before joining. |
| operator/( bottom:Bitmap ) | Bitmap | Stack two bitmaps vertically - this bitmap on the top. If necessary the narrower bitmap will be aspect-resized to match the width of the wider bitmap before stacking. |
| operator==( other:Bitmap ) | Logical | |
| premultiply_alpha() | Multiplies the R,G,B components of each color by their current alpha value - so Color(255,192,0,127) becomes Color(127,95,0,127). | |
| reframe( new_width:Int, new_height:Int, [anchor=Anchor.TOP_LEFT:Anchor], [pad_color=Color(0):Color] ) | ||
| reset( width:Int, height:Int, [color=Color(0):Color?] ) | ||
| resize( new_size:XY ) | ||
| resize( new_width:Int, new_height:Int ) | ||
| resize_add_row( src_i:Int, new_width:Int, multiplier:Real, resize_row_buffer:Real[] ) | ||
| resize_to( other:Bitmap ) |
Uses a custom algorithm inspired by Bresenham's line drawing algorithm. Here's the essential idea of this algorithm. Say we want to resize a set of 10 pixels to be 7 pixels: 10 pixels 0 0 9 9 0 0 9 9 0 0 Mathmatically make 7 copies of each of 10 pixels = 10 groups of 7 0000000 0000000 9999999 9999999 0000000 0000000 9999999 9999999 0000000 0000000 Regroup as 7 groups of 10 0000000000 0000999999 9999999900 0000000000 0099999999 9999990000 0000000000 Average out into 7 single pixels 0 5 7 0 7 5 0 |
|
| resize_to_fill( min_width:Int, min_height:Int, [crop=null:Anchor?] ) | ||
| resize_to_fit( max_width:Int, max_height:Int ) | ||
| resize_write_row( dest_bitmap:Bitmap, dest_i:Int, new_width:Int, resize_row_buffer:Real[] ) | ||
| resized( new_size:XY ) | Bitmap | |
| resized( new_width:Int, new_height:Int ) | Bitmap | |
| resized_to_height( new_height:Int ) | Bitmap | Returns a bitmap that has been resized to the specified height. The aspect ratio is preserved. This bitmap is returned if no resizing is required; otherwise a new bitmap is returned. |
| resized_to_width( new_width:Int ) | Bitmap | Returns a bitmap that has been resized to the specified width. The aspect ratio is preserved. This bitmap is returned if no resizing is required; otherwise a new bitmap is returned. |
| rotate_180() | ||
| rotate_90( &cw, &ccw ) | ||
| save_as_jpeg( file:File, [quality=75:Int] ) | Logical | |
| save_as_png( file:File ) | Logical | |
| set( x:Int, y:Int, color:Color ) | ||
| set( xy:XY, color:Color ) | ||
| size() | XY | |
| split( tiles_wide:Int, tiles_high:Int ) | Bitmap[] | |
| swap_red_and_blue() | ||
| to<<String>>() | String | |
| to_png_bytes() | Byte[] | |
| to_tiff_bytes() | Byte[] | |
| to<<TextCanvas>>( &dither, [bg8=CharacterStyle.BG_BLACK:Int], [bg24=Color.BLACK:Color] ) | TextCanvas | |
| to_jpeg_bytes( [quality=75:Int] ) | Byte[] | |
| trim( &top, &left, &bottom, &right ) | Logical | |
| unmultiply_alpha() | Performs the reverse of premultiply_alpha(). Due to integer division, component values may not be exactly the same as before. | |
| validate_premultiplied_alpha() | Checks for pixels that |
extends Function(Bitmap,Int,Int,Bitmap,Int,Int,Int,Int)
| Name | Type | Description |
|---|---|---|
| ALPHA | AlphaBitmapBlitFn | |
| OPAQUE | BitmapBlitFn |
| Signature | Return Type | Description |
|---|---|---|
| call( src:Bitmap, src_x1:Int, src_y1:Int, dest:Bitmap, dest_x1:Int, dest_y1:Int, blit_width:Int, blit_height:Int ) |
incorporates CommonCompoundMethods
| Category | Value | Description |
|---|---|---|
| TYPE_TIFF | 0 | |
| TYPE_BMP | 1 | |
| TYPE_GIF | 2 | |
| TYPE_JPEG | 3 | |
| TYPE_PNG | 4 | |
| TYPE_JPEG2000 | 5 |
| Name | Type | Description |
|---|---|---|
| categories | BitmapEncodingType[] |
| Signature | Return Type | Description |
|---|---|---|
| create( name:String ) | BitmapEncodingType | |
| create( value:Int ) | BitmapEncodingType |
| Name | Type | Description |
|---|---|---|
| value | Int |
| Signature | Return Type | Description |
|---|---|---|
| description() | String | |
| hashcode() | Int | |
| name() | String | |
| operator?() | Logical | |
| operator==( other:BitmapEncodingType ) | Logical | |
| print_to( buffer:PrintWriter ) | ||
| to<<Int>>() | Int | |
| to<<Object>>() | Object | |
| to<<String>>() | String | |
| to<<Variant>>() | Variant | |
| type_info() | TypeInfo |
extends Object
| Signature | Return Type | Description |
|---|---|---|
| call( bitmap:Bitmap, bounds:Box, [channel_mask=0xFFFFFFFF:Int32] ) |
extends BitmapFillFn
| Name | Type | Description |
|---|---|---|
| gradient | ColorGradient |
| Signature | Return Type | Description |
|---|---|---|
| call( bitmap:Bitmap, bounds:Box, [channel_mask=0xFFFFFFFF:Int32] ) |
extends ColorGradientBitmapFillFn
| Name | Type | Description |
|---|---|---|
| gradient | ColorGradient |
| Signature | Return Type | Description |
|---|---|---|
| call( bitmap:Bitmap, bounds:Box, [channel_mask=0xFFFFFFFF:Int32] ) |
extends BitmapBlitFn
| Name | Type | Description |
|---|---|---|
| success | Logical |
| Signature | Return Type | Description |
|---|---|---|
| call( src:Bitmap, src_x1:Int, src_y1:Int, dest:Bitmap, dest_x1:Int, dest_y1:Int, blit_width:Int, blit_height:Int ) | ||
| check( bitmap:Bitmap, bounds:Box ) | Logical |
extends BitmapFillFn
| Name | Type | Description |
|---|---|---|
| color | Color |
| Signature | Return Type | Description |
|---|---|---|
| call( bitmap:Bitmap, bounds:Box, [channel_mask=0xFFFFFFFF:Int32] ) |
extends Object
| Name | Type | Description |
|---|---|---|
| atlas | Bitmap | Font strip |
| characters | BitmapFontCharacterInfo[] | |
| height | Int | |
| kerning | Int[] |
Format. kerning[] is indexed into from the "prev_ch" BitmapFontCharacterInfo. [count_x,next1,offset1,next2,offset2,..., count_y,next1,offset1,...] Conceptual equivalent: local prev_ch = ... : Character local cur_ch = ... : Character if (kerning and kerning.contains(prev_ch) and kerning[prev_ch].contains(cur_ch)) cursor_x += kerning[prev_ch][cur_ch] endIf Actual use of kerning data structure: local prev_ch = ... : BitmapFontCharacterInfo local cur_ch = ... : BitmapFontCharacterInfo local i = prev_ch.kerning_index if (i) local n = kerning[i] ++i loop n if (kerning[i] == prev_ch.character) cursor_x += kerning[i+1] escapeLoop endIf i += 2 endLoop endIf |
| Signature | Return Type | Description |
|---|---|---|
| init() | Used by FreeTypeFace.to->BitmapFont | |
| init( atlas:Bitmap, height:Int ) | Caller should next populate font info with calls to add(BitmapFontCharacterInfo) and modifications to .kerning | |
| init( font_name:String, pixel_height:Int, [characters=null:String], &ascii ) | ||
| init( font_name:String, pixel_height:Int, characters:Character[], &ascii ) | ||
| add( info:BitmapFontCharacterInfo ) | ||
| bitmap( ch:BitmapFontCharacterInfo ) | Bitmap | |
| bitmap( ch:Character ) | Bitmap | |
| draw( text:String, dest_bitmap:Bitmap, position:XY, [anchor=Anchor.TOP_LEFT:Anchor], [blit_fn=BitmapBlitFn.ALPHA:BitmapBlitFn] ) | ||
| draw( text:String, dest_bitmap:Bitmap, x:Int, y:Int, [anchor=Anchor.TOP_LEFT:Anchor], [blit_fn=BitmapBlitFn.ALPHA:BitmapBlitFn] ) | ||
| get( ch:Character ) | BitmapFontCharacterInfo? | |
| measure( text:String ) | XY |
incorporates CommonCompoundMethods
kerning
Advance mappings for this as the previous character.
| Signature | Return Type | Description |
|---|---|---|
| create( character:Character, offset_x:Int, advance_x:Int, kerning_index:Int, bounds:Box ) | BitmapFontCharacterInfo |
| Name | Type | Description |
|---|---|---|
| advance_x | Int | |
| bounds | Box | |
| character | Character | |
| kerning_index | Int | |
| offset_x | Int |
| Signature | Return Type | Description |
|---|---|---|
| description() | String | |
| operator==( other:BitmapFontCharacterInfo ) | Logical | |
| print_to( buffer:PrintWriter ) | ||
| to<<Object>>() | Boxed<<BitmapFontCharacterInfo>> | |
| to<<String>>() | String | |
| to<<Variant>>() | Variant | |
| type_info() | TypeInfo |
incorporates CommonCompoundMethods
| Signature | Return Type | Description |
|---|---|---|
| create( argb:Int ) | Color | |
| create( argb:Int32 ) | Color | |
| create( r:Int, g:Int, b:Int, [a=255:Int] ) | Color | |
| create( r:Real, g:Real, b:Real, [a=1.0:Real] ) | Color |
| Name | Type | Description |
|---|---|---|
| argb | Int32 |
| Signature | Return Type | Description |
|---|---|---|
| abgr() | Int32 | |
| alpha() | Real | |
| alpha_byte() | Int | |
| alpha_premultiplied() | Color | |
| alpha_unmultiplied() | Color | |
| blue() | Real | |
| blue_byte() | Int | |
| description() | String | |
| green() | Real | |
| green_byte() | Int | |
| hashcode() | Int | |
| is_opaque() | Logical | |
| operator!() | Color | |
| operator?() | Logical | |
| operator&( n:Int ) | Color | |
| operator*( other:Color ) | Color | |
| operator*( value:Real ) | Color | |
| operator<>( other:Color ) | Int | |
| operator==( other:Color ) | Logical | |
| operator|( n:Int ) | Color | |
| print_to( buffer:PrintWriter ) | ||
| red() | Real | |
| red_byte() | Int | |
| rgba() | Int32 | |
| to<<Object>>() | Boxed<<Color>> | |
| to<<String>>() | String | |
| to<<Variant>>() | Variant | |
| to<<XYZW>>() | XYZW | |
| type_info() | TypeInfo | |
| with_alpha( a:Real ) | Color | Sets the alpha channel value 0.0-1.0. |
| with_alpha_byte( a:Int ) | Color | Sets the alpha channel byte value 0-255. |
| with_opacity( a:Real ) | Color | Multiplies the alpha channel by the given opacity. |
incorporates CommonCompoundMethods
| Signature | Return Type | Description |
|---|---|---|
| create( solid_color:Color ) | ColorGradient | |
| create( top_color:Color, bottom_color:Color ) | ColorGradient | |
| create( top_left:Color, top_right:Color, bottom_left:Color, bottom_right:Color ) | ColorGradient |
| Name | Type | Description |
|---|---|---|
| bottom_left | Color | |
| bottom_right | Color | |
| top_left | Color | |
| top_right | Color |
| Signature | Return Type | Description |
|---|---|---|
| clip( old_bounds:Box, new_bounds:Box ) | ||
| description() | String | |
| operator==( other:ColorGradient ) | Logical | |
| print_to( buffer:PrintWriter ) | ||
| to<<Object>>() | Boxed<<ColorGradient>> | |
| to<<String>>() | String | |
| to<<Variant>>() | Variant | |
| type_info() | TypeInfo |
incorporates CommonCompoundMethods
| Signature | Return Type | Description |
|---|---|---|
| create( a:Color, b:Color, steps:Int ) | ColorLerp | |
| create( a:IntLerp, r:IntLerp, g:IntLerp, b:IntLerp ) | ColorLerp |
| Name | Type | Description |
|---|---|---|
| a | IntLerp | |
| b | IntLerp | |
| g | IntLerp | |
| r | IntLerp |
| Signature | Return Type | Description |
|---|---|---|
| description() | String | |
| operator==( other:ColorLerp ) | Logical | |
| print_to( buffer:PrintWriter ) | ||
| read_another() | Color? | |
| skip( n:Int ) | ||
| to<<Object>>() | Boxed<<ColorLerp>> | |
| to<<String>>() | String | |
| to<<Variant>>() | Variant | |
| type_info() | TypeInfo |
incorporates CommonCompoundMethods
| Signature | Return Type | Description |
|---|---|---|
| create( a:Int, b:Int, steps:Int, [index=0:Int] ) | IntLerp |
| Name | Type | Description |
|---|---|---|
| a | Int | |
| b | Int | |
| index | Int | |
| steps | Int |
| Signature | Return Type | Description |
|---|---|---|
| description() | String | |
| operator==( other:IntLerp ) | Logical | |
| print_to( buffer:PrintWriter ) | ||
| read_another() | Int? | |
| skip( n:Int ) | ||
| to<<Object>>() | Boxed<<IntLerp>> | |
| to<<String>>() | String | |
| to<<Variant>>() | Variant | |
| type_info() | TypeInfo |
extends Object
| Name | Type | Description |
|---|---|---|
| advance_x | Int | |
| bitmap | Bitmap | |
| offset_x | Int | |
| unicode | Character |
| Signature | Return Type | Description |
|---|---|---|
| init( bitmap:Bitmap, offset_x:Int, advance_x:Int ) | ||
| init( unicode:Character ) | ||
| init( unicode:Character, bitmap:Bitmap, offset_x:Int, advance_x:Int ) | ||
| character() | Character | |
| to<<String>>() | String |
extends Object
| Signature | Return Type | Description |
|---|---|---|
| create( name:String, height:Int, [search_folders=null:String[]] ) | FreeTypeFace | |
| create( names:String[], height:Int, [search_folders=null:String[]] ) | FreeTypeFace |
| Name | Type | Description |
|---|---|---|
| @native122 | RogueCNativeProperty | |
| characters | FreeTypeCharacter[] | |
| data | Byte[] | |
| error | String | |
| filepath | String | |
| ft_height | Int | height we send FT to get height |
| height | Int | requested pixel height |
| kerning | [Character:[Character:Int]] |
if (kerning and kerning.contains(prev_ch) and kerning[prev_ch].contains(cur_ch)) cursor += kerning[prev_ch][cur_ch] endIf |
| max_offset | Int | zero or negative |
| Signature | Return Type | Description |
|---|---|---|
| init( filepath:String, data:Byte[], height:Int, [error=null:String] ) | ||
| init( filepath:String, height:Int, initialize:Logical, [error=null:String] ) | 'initialize' is a dummy argument to disambiguate from create(filepath,height). | |
| atlas() | Bitmap | |
| render_ascii() | FreeTypeCharacter[] | |
| render( characters:Character[] ) | FreeTypeCharacter[] | |
| render( new_characters:FreeTypeCharacter[] ) | ||
| to<<BitmapFont>>() | BitmapFont | |
| to<<BitmapFont>>( font:BitmapFont ) | BitmapFont |
incorporates CommonCompoundMethods
| Signature | Return Type | Description |
|---|---|---|
| create( color:Color ) | HSV | Creates a HSV compound from the given Color compound. |
| create( hue:Real, saturation:Real, value:Real ) | HSV |
| Name | Type | Description |
|---|---|---|
| hue | Real | |
| saturation | Real | |
| value | Real |
| Signature | Return Type | Description |
|---|---|---|
| description() | String | |
| hashcode() | Int | |
| operator==( other:HSV ) | Logical | |
| print_to( buffer:PrintWriter ) | ||
| to<<Color>>() | Color | |
| to<<Object>>() | Boxed<<HSV>> | |
| to<<String>>() | String | |
| to<<Variant>>() | Variant | |
| type_info() | TypeInfo |
incorporates CommonCompoundMethods
| Signature | Return Type | Description |
|---|---|---|
| create( color:Color ) | RealColor | |
| create( red:Real, green:Real, blue:Real, [alpha=1.0:Real] ) | RealColor |
| Name | Type | Description |
|---|---|---|
| alpha | Real | |
| blue | Real | |
| green | Real | |
| red | Real |
| Signature | Return Type | Description |
|---|---|---|
| description() | String | |
| operator*( other:RealColor ) | RealColor | |
| operator*( value:Real ) | RealColor | |
| operator+( other:RealColor ) | RealColor | |
| operator+( value:Real ) | RealColor | |
| operator-( other:RealColor ) | RealColor | |
| operator-( value:Real ) | RealColor | |
| operator/( other:RealColor ) | RealColor | |
| operator/( value:Real ) | RealColor | |
| operator==( other:RealColor ) | Logical | |
| print_to( buffer:PrintWriter ) | ||
| to<<Color>>() | Color | |
| to<<Object>>() | Boxed<<RealColor>> | |
| to<<String>>() | String | |
| to<<Variant>>() | Variant | |
| type_info() | TypeInfo |