Skip to content

Instantly share code, notes, and snippets.

@Vindaar
Created July 9, 2018 11:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Vindaar/e518e310eb3a0a95bdda7bbe8e4341f8 to your computer and use it in GitHub Desktop.
Save Vindaar/e518e310eb3a0a95bdda7bbe8e4341f8 to your computer and use it in GitHub Desktop.
when defined(EAPI):
when defined(WIN32):
when defined(BUILDING_DLL):
const
EAPI* = __declspec(dllexport)
else:
const
EAPI* = __declspec(dllimport)
else:
when defined(__GNUC__):
when __GNUC__ >= 4:
const
EAPI* = __attribute__((visibility("default")))
else:
const
EAPI* = true
else:
const
EAPI* = true
when not defined(X_DISPLAY_MISSING):
## Data types to use
when not defined(DATA64):
type
DATA64* = culonglong
DATA32* = cuint
DATA16* = cushort
DATA8* = cuchar
## opaque data types
type
Imlib_Context* = pointer
Imlib_Image* = pointer
Imlib_Color_Modifier* = pointer
Imlib_Updates* = pointer
Imlib_Font* = pointer
Imlib_Color_Range* = pointer
Imlib_Filter* = pointer
Imlib_Border* = _imlib_border
Imlib_Color* = _imlib_color
ImlibPolygon* = pointer
## blending operations
type
_imlib_operation* = enum
IMLIB_OP_COPY, IMLIB_OP_ADD, IMLIB_OP_SUBTRACT, IMLIB_OP_RESHADE
type
_imlib_text_direction* = enum
IMLIB_TEXT_TO_RIGHT = 0, IMLIB_TEXT_TO_LEFT = 1, IMLIB_TEXT_TO_DOWN = 2,
IMLIB_TEXT_TO_UP = 3, IMLIB_TEXT_TO_ANGLE = 4
type
_imlib_load_error* = enum
IMLIB_LOAD_ERROR_NONE, IMLIB_LOAD_ERROR_FILE_DOES_NOT_EXIST,
IMLIB_LOAD_ERROR_FILE_IS_DIRECTORY,
IMLIB_LOAD_ERROR_PERMISSION_DENIED_TO_READ,
IMLIB_LOAD_ERROR_NO_LOADER_FOR_FILE_FORMAT, IMLIB_LOAD_ERROR_PATH_TOO_LONG,
IMLIB_LOAD_ERROR_PATH_COMPONENT_NON_EXISTANT,
IMLIB_LOAD_ERROR_PATH_COMPONENT_NOT_DIRECTORY,
IMLIB_LOAD_ERROR_PATH_POINTS_OUTSIDE_ADDRESS_SPACE,
IMLIB_LOAD_ERROR_TOO_MANY_SYMBOLIC_LINKS, IMLIB_LOAD_ERROR_OUT_OF_MEMORY,
IMLIB_LOAD_ERROR_OUT_OF_FILE_DESCRIPTORS,
IMLIB_LOAD_ERROR_PERMISSION_DENIED_TO_WRITE,
IMLIB_LOAD_ERROR_OUT_OF_DISK_SPACE, IMLIB_LOAD_ERROR_UNKNOWN
## Encodings known to Imlib2 (so far)
type
_imlib_TTF_encoding* = enum
IMLIB_TTF_ENCODING_ISO_8859_1, IMLIB_TTF_ENCODING_ISO_8859_2,
IMLIB_TTF_ENCODING_ISO_8859_3, IMLIB_TTF_ENCODING_ISO_8859_4,
IMLIB_TTF_ENCODING_ISO_8859_5
type
Imlib_Operation* = _imlib_operation
Imlib_Load_Error* = _imlib_load_error
Imlib_Text_Direction* = _imlib_text_direction
Imlib_TTF_Encoding* = _imlib_TTF_encoding
type
_imlib_border* {.bycopy.} = object
left*: cint
right*: cint
top*: cint
bottom*: cint
_imlib_color* {.bycopy.} = object
alpha*: cint
red*: cint
green*: cint
blue*: cint
## Progressive loading callbacks
type
Imlib_Progress_Function* = proc (im: Imlib_Image; percent: char; update_x: cint;
update_y: cint; update_w: cint; update_h: cint): cint
Imlib_Data_Destructor_Function* = proc (im: Imlib_Image; data: pointer)
## *INDENT-OFF*
## *INDENT-ON*
## context handling
proc imlib_context_new*(): Imlib_Context
proc imlib_context_free*(context: Imlib_Context)
proc imlib_context_push*(context: Imlib_Context)
proc imlib_context_pop*()
proc imlib_context_get*(): Imlib_Context
## context setting
when not defined(X_DISPLAY_MISSING):
proc imlib_context_set_display*(display: ptr Display)
proc imlib_context_disconnect_display*()
proc imlib_context_set_visual*(visual: ptr Visual)
proc imlib_context_set_colormap*(colormap: Colormap)
proc imlib_context_set_drawable*(drawable: Drawable)
proc imlib_context_set_mask*(mask: Pixmap)
proc imlib_context_set_dither_mask*(dither_mask: char)
proc imlib_context_set_mask_alpha_threshold*(mask_alpha_threshold: cint)
proc imlib_context_set_anti_alias*(anti_alias: char)
proc imlib_context_set_dither*(dither: char)
proc imlib_context_set_blend*(blend: char)
proc imlib_context_set_color_modifier*(color_modifier: Imlib_Color_Modifier)
proc imlib_context_set_operation*(operation: Imlib_Operation)
proc imlib_context_set_font*(font: Imlib_Font)
proc imlib_context_set_direction*(direction: Imlib_Text_Direction)
proc imlib_context_set_angle*(angle: cdouble)
proc imlib_context_set_color*(red: cint; green: cint; blue: cint; alpha: cint)
proc imlib_context_set_color_hsva*(hue: cfloat; saturation: cfloat; value: cfloat;
alpha: cint)
proc imlib_context_set_color_hlsa*(hue: cfloat; lightness: cfloat;
saturation: cfloat; alpha: cint)
proc imlib_context_set_color_cmya*(cyan: cint; magenta: cint; yellow: cint; alpha: cint)
proc imlib_context_set_color_range*(color_range: Imlib_Color_Range)
proc imlib_context_set_progress_function*(
progress_function: Imlib_Progress_Function)
proc imlib_context_set_progress_granularity*(progress_granularity: char)
proc imlib_context_set_image*(image: Imlib_Image)
proc imlib_context_set_cliprect*(x: cint; y: cint; w: cint; h: cint)
proc imlib_context_set_TTF_encoding*(encoding: Imlib_TTF_Encoding)
## context getting
when not defined(X_DISPLAY_MISSING):
proc imlib_context_get_display*(): ptr Display
proc imlib_context_get_visual*(): ptr Visual
proc imlib_context_get_colormap*(): Colormap
proc imlib_context_get_drawable*(): Drawable
proc imlib_context_get_mask*(): Pixmap
proc imlib_context_get_dither_mask*(): char
proc imlib_context_get_anti_alias*(): char
proc imlib_context_get_mask_alpha_threshold*(): cint
proc imlib_context_get_dither*(): char
proc imlib_context_get_blend*(): char
proc imlib_context_get_color_modifier*(): Imlib_Color_Modifier
proc imlib_context_get_operation*(): Imlib_Operation
proc imlib_context_get_font*(): Imlib_Font
proc imlib_context_get_angle*(): cdouble
proc imlib_context_get_direction*(): Imlib_Text_Direction
proc imlib_context_get_color*(red: ptr cint; green: ptr cint; blue: ptr cint;
alpha: ptr cint)
proc imlib_context_get_color_hsva*(hue: ptr cfloat; saturation: ptr cfloat;
value: ptr cfloat; alpha: ptr cint)
proc imlib_context_get_color_hlsa*(hue: ptr cfloat; lightness: ptr cfloat;
saturation: ptr cfloat; alpha: ptr cint)
proc imlib_context_get_color_cmya*(cyan: ptr cint; magenta: ptr cint; yellow: ptr cint;
alpha: ptr cint)
proc imlib_context_get_imlib_color*(): ptr Imlib_Color
proc imlib_context_get_color_range*(): Imlib_Color_Range
proc imlib_context_get_progress_function*(): Imlib_Progress_Function
proc imlib_context_get_progress_granularity*(): char
proc imlib_context_get_image*(): Imlib_Image
proc imlib_context_get_cliprect*(x: ptr cint; y: ptr cint; w: ptr cint; h: ptr cint)
proc imlib_context_get_TTF_encoding*(): Imlib_TTF_Encoding
proc imlib_get_cache_used*(): cint
proc imlib_get_cache_size*(): cint
proc imlib_set_cache_size*(bytes: cint)
proc imlib_get_color_usage*(): cint
proc imlib_set_color_usage*(max: cint)
proc imlib_flush_loaders*()
when not defined(X_DISPLAY_MISSING):
proc imlib_get_visual_depth*(display: ptr Display; visual: ptr Visual): cint
proc imlib_get_best_visual*(display: ptr Display; screen: cint;
depth_return: ptr cint): ptr Visual
proc imlib_load_image*(file: cstring): Imlib_Image
proc imlib_load_image_immediately*(file: cstring): Imlib_Image
proc imlib_load_image_without_cache*(file: cstring): Imlib_Image
proc imlib_load_image_immediately_without_cache*(file: cstring): Imlib_Image
proc imlib_load_image_with_error_return*(file: cstring;
error_return: ptr Imlib_Load_Error): Imlib_Image
proc imlib_free_image*()
proc imlib_free_image_and_decache*()
## query/modify image parameters
proc imlib_image_get_width*(): cint
proc imlib_image_get_height*(): cint
proc imlib_image_get_filename*(): cstring
proc imlib_image_get_data*(): ptr DATA32
proc imlib_image_get_data_for_reading_only*(): ptr DATA32
proc imlib_image_put_back_data*(data: ptr DATA32)
proc imlib_image_has_alpha*(): char
proc imlib_image_set_changes_on_disk*()
proc imlib_image_get_border*(border: ptr Imlib_Border)
proc imlib_image_set_border*(border: ptr Imlib_Border)
proc imlib_image_set_format*(format: cstring)
proc imlib_image_set_irrelevant_format*(irrelevant: char)
proc imlib_image_set_irrelevant_border*(irrelevant: char)
proc imlib_image_set_irrelevant_alpha*(irrelevant: char)
proc imlib_image_format*(): cstring
proc imlib_image_set_has_alpha*(has_alpha: char)
proc imlib_image_query_pixel*(x: cint; y: cint; color_return: ptr Imlib_Color)
proc imlib_image_query_pixel_hsva*(x: cint; y: cint; hue: ptr cfloat;
saturation: ptr cfloat; value: ptr cfloat;
alpha: ptr cint)
proc imlib_image_query_pixel_hlsa*(x: cint; y: cint; hue: ptr cfloat;
lightness: ptr cfloat; saturation: ptr cfloat;
alpha: ptr cint)
proc imlib_image_query_pixel_cmya*(x: cint; y: cint; cyan: ptr cint; magenta: ptr cint;
yellow: ptr cint; alpha: ptr cint)
## rendering functions
when not defined(X_DISPLAY_MISSING):
proc imlib_render_pixmaps_for_whole_image*(pixmap_return: ptr Pixmap;
mask_return: ptr Pixmap)
proc imlib_render_pixmaps_for_whole_image_at_size*(pixmap_return: ptr Pixmap;
mask_return: ptr Pixmap; width: cint; height: cint)
proc imlib_free_pixmap_and_mask*(pixmap: Pixmap)
proc imlib_render_image_on_drawable*(x: cint; y: cint)
proc imlib_render_image_on_drawable_at_size*(x: cint; y: cint; width: cint;
height: cint)
proc imlib_render_image_part_on_drawable_at_size*(source_x: cint; source_y: cint;
source_width: cint; source_height: cint; x: cint; y: cint; width: cint; height: cint)
proc imlib_render_get_pixel_color*(): DATA32
proc imlib_blend_image_onto_image*(source_image: Imlib_Image; merge_alpha: char;
source_x: cint; source_y: cint;
source_width: cint; source_height: cint;
destination_x: cint; destination_y: cint;
destination_width: cint;
destination_height: cint)
## creation functions
proc imlib_create_image*(width: cint; height: cint): Imlib_Image
proc imlib_create_image_using_data*(width: cint; height: cint; data: ptr DATA32): Imlib_Image
proc imlib_create_image_using_copied_data*(width: cint; height: cint;
data: ptr DATA32): Imlib_Image
when not defined(X_DISPLAY_MISSING):
proc imlib_create_image_from_drawable*(mask: Pixmap; x: cint; y: cint; width: cint;
height: cint; need_to_grab_x: char): Imlib_Image
proc imlib_create_image_from_ximage*(image: ptr XImage; mask: ptr XImage; x: cint;
y: cint; width: cint; height: cint;
need_to_grab_x: char): Imlib_Image
proc imlib_create_scaled_image_from_drawable*(mask: Pixmap; source_x: cint;
source_y: cint; source_width: cint; source_height: cint;
destination_width: cint; destination_height: cint; need_to_grab_x: char;
get_mask_from_shape: char): Imlib_Image
proc imlib_copy_drawable_to_image*(mask: Pixmap; x: cint; y: cint; width: cint;
height: cint; destination_x: cint;
destination_y: cint; need_to_grab_x: char): char
proc imlib_get_ximage_cache_count_used*(): cint
proc imlib_get_ximage_cache_count_max*(): cint
proc imlib_set_ximage_cache_count_max*(count: cint)
proc imlib_get_ximage_cache_size_used*(): cint
proc imlib_get_ximage_cache_size_max*(): cint
proc imlib_set_ximage_cache_size_max*(bytes: cint)
proc imlib_clone_image*(): Imlib_Image
proc imlib_create_cropped_image*(x: cint; y: cint; width: cint; height: cint): Imlib_Image
proc imlib_create_cropped_scaled_image*(source_x: cint; source_y: cint;
source_width: cint; source_height: cint;
destination_width: cint;
destination_height: cint): Imlib_Image
## imlib updates. lists of rectangles for storing required update draws
proc imlib_updates_clone*(updates: Imlib_Updates): Imlib_Updates
proc imlib_update_append_rect*(updates: Imlib_Updates; x: cint; y: cint; w: cint; h: cint): Imlib_Updates
proc imlib_updates_merge*(updates: Imlib_Updates; w: cint; h: cint): Imlib_Updates
proc imlib_updates_merge_for_rendering*(updates: Imlib_Updates; w: cint; h: cint): Imlib_Updates
proc imlib_updates_free*(updates: Imlib_Updates)
proc imlib_updates_get_next*(updates: Imlib_Updates): Imlib_Updates
proc imlib_updates_get_coordinates*(updates: Imlib_Updates; x_return: ptr cint;
y_return: ptr cint; width_return: ptr cint;
height_return: ptr cint)
proc imlib_updates_set_coordinates*(updates: Imlib_Updates; x: cint; y: cint;
width: cint; height: cint)
proc imlib_render_image_updates_on_drawable*(updates: Imlib_Updates; x: cint; y: cint)
proc imlib_updates_init*(): Imlib_Updates
proc imlib_updates_append_updates*(updates: Imlib_Updates;
appended_updates: Imlib_Updates): Imlib_Updates
## image modification
proc imlib_image_flip_horizontal*()
proc imlib_image_flip_vertical*()
proc imlib_image_flip_diagonal*()
proc imlib_image_orientate*(orientation: cint)
proc imlib_image_blur*(radius: cint)
proc imlib_image_sharpen*(radius: cint)
proc imlib_image_tile_horizontal*()
proc imlib_image_tile_vertical*()
proc imlib_image_tile*()
## fonts and text
proc imlib_load_font*(font_name: cstring): Imlib_Font
proc imlib_free_font*()
## NB! The four functions below are deprecated.
proc imlib_insert_font_into_fallback_chain*(font: Imlib_Font;
fallback_font: Imlib_Font): cint
proc imlib_remove_font_from_fallback_chain*(fallback_font: Imlib_Font)
proc imlib_get_prev_font_in_fallback_chain*(fn: Imlib_Font): Imlib_Font
proc imlib_get_next_font_in_fallback_chain*(fn: Imlib_Font): Imlib_Font
## NB! The four functions above are deprecated.
proc imlib_text_draw*(x: cint; y: cint; text: cstring)
proc imlib_text_draw_with_return_metrics*(x: cint; y: cint; text: cstring;
width_return: ptr cint; height_return: ptr cint;
horizontal_advance_return: ptr cint; vertical_advance_return: ptr cint)
proc imlib_get_text_size*(text: cstring; width_return: ptr cint;
height_return: ptr cint)
proc imlib_get_text_advance*(text: cstring; horizontal_advance_return: ptr cint;
vertical_advance_return: ptr cint)
proc imlib_get_text_inset*(text: cstring): cint
proc imlib_add_path_to_font_path*(path: cstring)
proc imlib_remove_path_from_font_path*(path: cstring)
proc imlib_list_font_path*(number_return: ptr cint): cstringArray
proc imlib_text_get_index_and_location*(text: cstring; x: cint; y: cint;
char_x_return: ptr cint;
char_y_return: ptr cint;
char_width_return: ptr cint;
char_height_return: ptr cint): cint
proc imlib_text_get_location_at_index*(text: cstring; index: cint;
char_x_return: ptr cint;
char_y_return: ptr cint;
char_width_return: ptr cint;
char_height_return: ptr cint)
proc imlib_list_fonts*(number_return: ptr cint): cstringArray
proc imlib_free_font_list*(font_list: cstringArray; number: cint)
proc imlib_get_font_cache_size*(): cint
proc imlib_set_font_cache_size*(bytes: cint)
proc imlib_flush_font_cache*()
proc imlib_get_font_ascent*(): cint
proc imlib_get_font_descent*(): cint
proc imlib_get_maximum_font_ascent*(): cint
proc imlib_get_maximum_font_descent*(): cint
## color modifiers
proc imlib_create_color_modifier*(): Imlib_Color_Modifier
proc imlib_free_color_modifier*()
proc imlib_modify_color_modifier_gamma*(gamma_value: cdouble)
proc imlib_modify_color_modifier_brightness*(brightness_value: cdouble)
proc imlib_modify_color_modifier_contrast*(contrast_value: cdouble)
proc imlib_set_color_modifier_tables*(red_table: ptr DATA8; green_table: ptr DATA8;
blue_table: ptr DATA8; alpha_table: ptr DATA8)
proc imlib_get_color_modifier_tables*(red_table: ptr DATA8; green_table: ptr DATA8;
blue_table: ptr DATA8; alpha_table: ptr DATA8)
proc imlib_reset_color_modifier*()
proc imlib_apply_color_modifier*()
proc imlib_apply_color_modifier_to_rectangle*(x: cint; y: cint; width: cint;
height: cint)
## drawing on images
proc imlib_image_draw_pixel*(x: cint; y: cint; make_updates: char): Imlib_Updates
proc imlib_image_draw_line*(x1: cint; y1: cint; x2: cint; y2: cint; make_updates: char): Imlib_Updates
proc imlib_image_draw_rectangle*(x: cint; y: cint; width: cint; height: cint)
proc imlib_image_fill_rectangle*(x: cint; y: cint; width: cint; height: cint)
proc imlib_image_copy_alpha_to_image*(image_source: Imlib_Image; x: cint; y: cint)
proc imlib_image_copy_alpha_rectangle_to_image*(image_source: Imlib_Image; x: cint;
y: cint; width: cint; height: cint; destination_x: cint; destination_y: cint)
proc imlib_image_scroll_rect*(x: cint; y: cint; width: cint; height: cint; delta_x: cint;
delta_y: cint)
proc imlib_image_copy_rect*(x: cint; y: cint; width: cint; height: cint; new_x: cint;
new_y: cint)
## polygons
proc imlib_polygon_new*(): ImlibPolygon
proc imlib_polygon_free*(poly: ImlibPolygon)
proc imlib_polygon_add_point*(poly: ImlibPolygon; x: cint; y: cint)
proc imlib_image_draw_polygon*(poly: ImlibPolygon; closed: cuchar)
proc imlib_image_fill_polygon*(poly: ImlibPolygon)
proc imlib_polygon_get_bounds*(poly: ImlibPolygon; px1: ptr cint; py1: ptr cint;
px2: ptr cint; py2: ptr cint)
proc imlib_polygon_contains_point*(poly: ImlibPolygon; x: cint; y: cint): cuchar
## ellipses
proc imlib_image_draw_ellipse*(xc: cint; yc: cint; a: cint; b: cint)
proc imlib_image_fill_ellipse*(xc: cint; yc: cint; a: cint; b: cint)
## color ranges
proc imlib_create_color_range*(): Imlib_Color_Range
proc imlib_free_color_range*()
proc imlib_add_color_to_color_range*(distance_away: cint)
proc imlib_image_fill_color_range_rectangle*(x: cint; y: cint; width: cint;
height: cint; angle: cdouble)
proc imlib_image_fill_hsva_color_range_rectangle*(x: cint; y: cint; width: cint;
height: cint; angle: cdouble)
## image data
proc imlib_image_attach_data_value*(key: cstring; data: pointer; value: cint;
destructor_function: Imlib_Data_Destructor_Function)
proc imlib_image_get_attached_data*(key: cstring): pointer
proc imlib_image_get_attached_value*(key: cstring): cint
proc imlib_image_remove_attached_data_value*(key: cstring)
proc imlib_image_remove_and_free_attached_data_value*(key: cstring)
## saving
proc imlib_save_image*(filename: cstring)
proc imlib_save_image_with_error_return*(filename: cstring;
error_return: ptr Imlib_Load_Error)
## FIXME:
## need to add arbitrary rotation routines
## rotation/skewing
proc imlib_create_rotated_image*(angle: cdouble): Imlib_Image
## rotation from buffer to context (without copying)
proc imlib_rotate_image_from_buffer*(angle: cdouble; source_image: Imlib_Image)
proc imlib_blend_image_onto_image_at_angle*(source_image: Imlib_Image;
merge_alpha: char; source_x: cint; source_y: cint; source_width: cint;
source_height: cint; destination_x: cint; destination_y: cint; angle_x: cint;
angle_y: cint)
proc imlib_blend_image_onto_image_skewed*(source_image: Imlib_Image;
merge_alpha: char; source_x: cint; source_y: cint; source_width: cint;
source_height: cint; destination_x: cint; destination_y: cint; h_angle_x: cint;
h_angle_y: cint; v_angle_x: cint; v_angle_y: cint)
when not defined(X_DISPLAY_MISSING):
proc imlib_render_image_on_drawable_skewed*(source_x: cint; source_y: cint;
source_width: cint; source_height: cint; destination_x: cint;
destination_y: cint; h_angle_x: cint; h_angle_y: cint; v_angle_x: cint;
v_angle_y: cint)
proc imlib_render_image_on_drawable_at_angle*(source_x: cint; source_y: cint;
source_width: cint; source_height: cint; destination_x: cint;
destination_y: cint; angle_x: cint; angle_y: cint)
## image filters
proc imlib_image_filter*()
proc imlib_create_filter*(initsize: cint): Imlib_Filter
proc imlib_context_set_filter*(filter: Imlib_Filter)
proc imlib_context_get_filter*(): Imlib_Filter
proc imlib_free_filter*()
proc imlib_filter_set*(xoff: cint; yoff: cint; a: cint; r: cint; g: cint; b: cint)
proc imlib_filter_set_alpha*(xoff: cint; yoff: cint; a: cint; r: cint; g: cint; b: cint)
proc imlib_filter_set_red*(xoff: cint; yoff: cint; a: cint; r: cint; g: cint; b: cint)
proc imlib_filter_set_green*(xoff: cint; yoff: cint; a: cint; r: cint; g: cint; b: cint)
proc imlib_filter_set_blue*(xoff: cint; yoff: cint; a: cint; r: cint; g: cint; b: cint)
proc imlib_filter_constants*(a: cint; r: cint; g: cint; b: cint)
proc imlib_filter_divisors*(a: cint; r: cint; g: cint; b: cint)
proc imlib_apply_filter*(script: cstring) {.varargs.}
proc imlib_image_clear*()
proc imlib_image_clear_color*(r: cint; g: cint; b: cint; a: cint)
## *INDENT-OFF*
## *INDENT-ON*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment