development of graphics module
This commit is contained in:
parent
0b07b47f69
commit
64da2f1681
7 changed files with 508 additions and 272 deletions
203
lib/impure/graphics.nim
Normal file
203
lib/impure/graphics.nim
Normal file
|
|
@ -0,0 +1,203 @@
|
|||
#
|
||||
#
|
||||
# Nimrod's Runtime Library
|
||||
# (c) Copyright 2010 Andreas Rumpf
|
||||
#
|
||||
# See the file "copying.txt", included in this
|
||||
# distribution, for details about the copyright.
|
||||
#
|
||||
|
||||
## This module implements graphical output for Nimrod; the current
|
||||
## implementation uses SDL but the interface is meant to support multiple
|
||||
## backends some day.
|
||||
|
||||
import sdl, colors
|
||||
|
||||
type
|
||||
TRect* = tuple[x, y, width, height: int]
|
||||
TPoint* = tuple[x, y: int]
|
||||
|
||||
PSurface* = ref TSurface ## a surface to draw onto
|
||||
TSurface {.pure, final.} = object
|
||||
w, h: int
|
||||
s: sdl.PSurface
|
||||
|
||||
proc surfaceFinalizer(s: PSurface) = sdl.freeSurface(s.s)
|
||||
|
||||
proc newSurface*(width, height: int): PSurface =
|
||||
## creates a new surface.
|
||||
new(result, surfaceFinalizer)
|
||||
result.w = width
|
||||
result.h = height
|
||||
result.s = SDL.CreateRGBSurface(SDL.SWSURFACE, width, height,
|
||||
32, 0x00FF0000, 0x0000FF00, 0x000000FF, 0xff000000)
|
||||
|
||||
proc textBounds*(text: string): tuple[len, height: int]
|
||||
proc drawText*(sur: PSurface, p: TPoint, text: string)
|
||||
|
||||
proc writeToPNG*(sur: PSurface, filename: string) =
|
||||
## writes the contents of the surface `sur` to the file `filename`.
|
||||
|
||||
|
||||
type
|
||||
TPixels = array[0..1000_000-1, int32]
|
||||
PPixels = ptr TPixels
|
||||
|
||||
template setPix(video, pitch, x, y, col: expr): expr =
|
||||
video[y * pitch + x] = col
|
||||
|
||||
template getPix(video, pitch, x, y: expr): expr =
|
||||
video[y * pitch + x]
|
||||
|
||||
const
|
||||
ColSize = 4
|
||||
|
||||
proc getPixel(sur: PSurface, x, y: Natural): TColor =
|
||||
result = getPix(PPixels(sur.pixels), sur.pitch div ColSize, x, y)
|
||||
|
||||
proc setPixel(sur: PSurface, x, y: Natural; col: TColor) =
|
||||
setPix(PPixels(sur.pixels), sur.pitch div ColSize, x, y, col)
|
||||
|
||||
proc `[]`*(sur: PSurface, p: TPoint): TColor =
|
||||
result = getPixel(sur, p.x, p.y)
|
||||
|
||||
proc `[,]`*(sur: PSurface, x, y: int): TColor =
|
||||
result = setPixel(sur, x, y)
|
||||
|
||||
proc `[]=`*(sur: PSurface, p: TPoint, col: TColor) =
|
||||
setPixel(sur, p.x, p.y, col)
|
||||
|
||||
proc `[,]=`*(sur: PSurface, x, y: int, col: TColor) =
|
||||
setPixel(sur, x, y, col)
|
||||
|
||||
proc drawCircle*(sur: PSurface, p: TPoint, r: Natural, color: TColor) =
|
||||
## draws a circle with center `p` and radius `r` with the given color
|
||||
## onto the surface `sur`.
|
||||
var video = sur.pixels
|
||||
var pitch = sur.pitch div ColSize
|
||||
var p = 1 - r
|
||||
var py = r
|
||||
var px = 0
|
||||
var x = p.x
|
||||
var y = p.y
|
||||
while px <= py + 1:
|
||||
setPix(video, pitch, x + px, y + py, color)
|
||||
setPix(video, pitch, x + px, y - py, color)
|
||||
setPix(video, pitch, x - px, y + py, color)
|
||||
setPix(video, pitch, x - px, y - py, color)
|
||||
|
||||
setPix(video, pitch, x + py, y + px, color)
|
||||
setPix(video, pitch, x + py, y - px, color)
|
||||
setPix(video, pitch, x - py, y + px, color)
|
||||
setPix(video, pitch, x - py, y - px, color)
|
||||
|
||||
if p < 0:
|
||||
p = p + (2 * px + 3)
|
||||
else:
|
||||
p = p + (2 * (px - py) + 5)
|
||||
py = py - 1
|
||||
px = px + 1
|
||||
|
||||
proc drawLine*(sur: PSurface, p1, p2: TPoint, color: TColor) =
|
||||
## draws a line between the two points `p1` and `p2` with the given color
|
||||
## onto the surface `sur`.
|
||||
var x0: int = p1.x
|
||||
var x1: int = p2.x
|
||||
var y0: int = p1.y
|
||||
var y1: int = p2.y
|
||||
var dy: int = y1 - y0
|
||||
var dx: int = x1 - x0
|
||||
if dy < 0:
|
||||
dy = -dy
|
||||
stepy = -1
|
||||
else:
|
||||
stepy = 1
|
||||
if dx < 0:
|
||||
dx = -dx
|
||||
stepx = -1
|
||||
else:
|
||||
stepx = 1
|
||||
dy = dy * 2
|
||||
dx = dx * 2
|
||||
var video = sur.pixels
|
||||
var pitch = sur.pitch div ColSize
|
||||
setPix(video, pitch, x0, y0, color)
|
||||
if dx > dy:
|
||||
var fraction = dy - (dx div 2)
|
||||
while x0 != x1:
|
||||
if fraction >= 0:
|
||||
y0 = y0 + stepy
|
||||
fraction = fraction - dx
|
||||
x0 = x0 + stepx
|
||||
fraction = fraction + dy
|
||||
setPix(video, pitch, x0, y0, color)
|
||||
else:
|
||||
var fraction = dx - (dy div 2)
|
||||
while y0 != y1:
|
||||
if fraction >= 0:
|
||||
x0 = x0 + stepx
|
||||
fraction = fraction - dy
|
||||
y0 = y0 + stepy
|
||||
fraction = fraction + dx
|
||||
setPix(video, pitch, x0, y0, color)
|
||||
|
||||
proc drawHorLine*(sur: PSurface, x, y, w: Natural, Color: TColor) =
|
||||
## draws a horizontal line from (x,y) to (x+w-1, h).
|
||||
var video = sur.pixels
|
||||
var pitch = sur.pitch div ColSize
|
||||
for i = 0 .. w-1: setPix(video, pitch, x + i, y, color)
|
||||
|
||||
proc drawVerLine*(sur: PSurface, x, y, h: Natural, Color: TColor) =
|
||||
## draws a vertical line from (x,y) to (x, y+h-1).
|
||||
var video = sur.pixels
|
||||
var pitch = sur.pitch div ColSize
|
||||
for i in 0 .. h-1: setPix(video, pitch, x, y + i, color)
|
||||
|
||||
proc fillCircle*(s: PSurface, p: TPoint, r: Natural, color: TColor) =
|
||||
## draws a circle with center `p` and radius `r` with the given color
|
||||
## onto the surface `sur` and fills it.
|
||||
var p = 1 - r
|
||||
var py: int = r
|
||||
var px = 0
|
||||
var x = p.x
|
||||
var y = p.y
|
||||
while px <= py:
|
||||
# Fill up the middle half of the circle
|
||||
DrawVerLine(s, x + px, y, py + 1, color)
|
||||
DrawVerLine(s, x + px, y - py, py, color)
|
||||
if px != 0:
|
||||
DrawVerLine(s, x - px, y, py + 1, color)
|
||||
DrawVerLine(s, x - px, y - py, py, color)
|
||||
if p < 0:
|
||||
p = p + (2 * px + 3)
|
||||
else:
|
||||
p = p + (2 * (px - py) + 5)
|
||||
py = py - 1
|
||||
# Fill up the left/right half of the circle
|
||||
if py >= px:
|
||||
DrawVerLine(s, x + py + 1, y, px + 1, color)
|
||||
DrawVerLine(s, x + py + 1, y - px, px, color)
|
||||
DrawVerLine(s, x - py - 1, y, px + 1, color)
|
||||
DrawVerLine(s, x - py - 1, y - px, px, color)
|
||||
px = px + 1
|
||||
|
||||
proc drawRect*(sur: PSurface, r: TRect, color: TColor) =
|
||||
## draws a rectangle.
|
||||
var video = sur.pixels
|
||||
var pitch = sur.pitch div ColSize
|
||||
for i in 0 .. r.w-1:
|
||||
setPix(video, pitch, r.x + i, r.y, color)
|
||||
for i in 0 .. r.h-1:
|
||||
setPix(video, pitch, r.x, r.y + i, color)
|
||||
setPix(video, pitch, r.x + r.w - 1, r.y + i, color)
|
||||
for i in 0 .. r.w-1:
|
||||
setPix(video, pitch, r.x + i, r.y + r.h - 1, color)
|
||||
|
||||
proc fillRect*(sur: PSurface, r: TRect, col: TColor) =
|
||||
## draws and fills a rectancle.
|
||||
var video = sur.pixels
|
||||
var pitch = sur.pitch div ColSize
|
||||
for i in r.y..y+r.h-1:
|
||||
for j in r.x..r.x+r.w-1:
|
||||
setPix(video, pitch, j, i, color)
|
||||
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
## Currently only requesting URLs is implemented. The implementation depends
|
||||
## on the libcurl library!
|
||||
##
|
||||
## **Deprecated since version 0.8.0:** Use the httpclient module instead.
|
||||
## **Deprecated since version 0.8.6:** Use the httpclient module instead.
|
||||
##
|
||||
|
||||
{.deprecated.}
|
||||
|
|
|
|||
|
|
@ -57,13 +57,40 @@ else:
|
|||
type
|
||||
PByte = cstring
|
||||
TStatus* = enum
|
||||
STATUS_SUCCESS = 0, STATUS_NO_MEMORY, STATUS_INVALID_RESTORE,
|
||||
STATUS_INVALID_POP_GROUP, STATUS_NO_CURRENT_POINT, STATUS_INVALID_MATRIX,
|
||||
STATUS_INVALID_STATUS, STATUS_NULL_POINTER, STATUS_INVALID_STRING,
|
||||
STATUS_INVALID_PATH_DATA, STATUS_READ_ERROR, STATUS_WRITE_ERROR,
|
||||
STATUS_SURFACE_FINISHED, STATUS_SURFACE_TYPE_MISMATCH,
|
||||
STATUS_PATTERN_TYPE_MISMATCH, STATUS_INVALID_CONTENT, STATUS_INVALID_FORMAT,
|
||||
STATUS_INVALID_VISUAL, STATUS_FILE_NOT_FOUND, STATUS_INVALID_DASH
|
||||
STATUS_SUCCESS = 0,
|
||||
STATUS_NO_MEMORY,
|
||||
STATUS_INVALID_RESTORE,
|
||||
STATUS_INVALID_POP_GROUP,
|
||||
STATUS_NO_CURRENT_POINT,
|
||||
STATUS_INVALID_MATRIX,
|
||||
STATUS_INVALID_STATUS,
|
||||
STATUS_NULL_POINTER,
|
||||
STATUS_INVALID_STRING,
|
||||
STATUS_INVALID_PATH_DATA,
|
||||
STATUS_READ_ERROR,
|
||||
STATUS_WRITE_ERROR,
|
||||
STATUS_SURFACE_FINISHED,
|
||||
STATUS_SURFACE_TYPE_MISMATCH,
|
||||
STATUS_PATTERN_TYPE_MISMATCH,
|
||||
STATUS_INVALID_CONTENT,
|
||||
STATUS_INVALID_FORMAT,
|
||||
STATUS_INVALID_VISUAL,
|
||||
STATUS_FILE_NOT_FOUND,
|
||||
STATUS_INVALID_DASH,
|
||||
STATUS_INVALID_DSC_COMMENT,
|
||||
STATUS_INVALID_INDEX,
|
||||
STATUS_CLIP_NOT_REPRESENTABLE,
|
||||
STATUS_TEMP_FILE_ERROR,
|
||||
STATUS_INVALID_STRIDE,
|
||||
STATUS_FONT_TYPE_MISMATCH,
|
||||
STATUS_USER_FONT_IMMUTABLE,
|
||||
STATUS_USER_FONT_ERROR,
|
||||
STATUS_NEGATIVE_COUNT,
|
||||
STATUS_INVALID_CLUSTERS,
|
||||
STATUS_INVALID_SLANT,
|
||||
STATUS_INVALID_WEIGHT
|
||||
|
||||
|
||||
TOperator* = enum
|
||||
OPERATOR_CLEAR, OPERATOR_SOURCE, OPERATOR_OVER, OPERATOR_IN, OPERATOR_OUT,
|
||||
OPERATOR_ATOP, OPERATOR_DEST, OPERATOR_DEST_OVER, OPERATOR_DEST_IN,
|
||||
|
|
@ -114,8 +141,8 @@ type
|
|||
TSvgVersion* = enum
|
||||
SVG_VERSION_1_1, SVG_VERSION_1_2
|
||||
PSurface* = ptr TSurface
|
||||
PPCairoSurface* = ptr PSurface
|
||||
PCairo* = ptr TCario
|
||||
PPSurface* = ptr PSurface
|
||||
PContext* = ptr TContext
|
||||
PPattern* = ptr TPattern
|
||||
PFontOptions* = ptr TFontOptions
|
||||
PFontFace* = ptr TFontFace
|
||||
|
|
@ -135,7 +162,7 @@ type
|
|||
TDestroyFunc* = proc (data: Pointer){.cdecl.}
|
||||
TWriteFunc* = proc (closure: Pointer, data: PByte, len: int32): TStatus{.cdecl.}
|
||||
TReadFunc* = proc (closure: Pointer, data: PByte, len: int32): TStatus{.cdecl.}
|
||||
TCario*{.final.} = object #OPAQUE
|
||||
TContext*{.final.} = object #OPAQUE
|
||||
TSurface*{.final.} = object #OPAQUE
|
||||
TPattern*{.final.} = object #OPAQUE
|
||||
TScaledFont*{.final.} = object #OPAQUE
|
||||
|
|
@ -198,362 +225,362 @@ proc version_string*(): cstring{.cdecl, importc: "cairo_version_string",
|
|||
#Helper function to retrieve decoded version
|
||||
proc version*(major, minor, micro: var int32)
|
||||
#* Functions for manipulating state objects
|
||||
proc create*(target: PSurface): PCairo{.cdecl, importc: "cairo_create",
|
||||
proc create*(target: PSurface): PContext{.cdecl, importc: "cairo_create",
|
||||
dynlib: LIB_CAIRO.}
|
||||
proc reference*(cr: PCairo): PCairo{.cdecl, importc: "cairo_reference", dynlib: LIB_CAIRO.}
|
||||
proc destroy*(cr: PCairo){.cdecl, importc: "cairo_destroy", dynlib: LIB_CAIRO.}
|
||||
proc get_reference_count*(cr: PCairo): int32{.cdecl,
|
||||
proc reference*(cr: PContext): PContext{.cdecl, importc: "cairo_reference", dynlib: LIB_CAIRO.}
|
||||
proc destroy*(cr: PContext){.cdecl, importc: "cairo_destroy", dynlib: LIB_CAIRO.}
|
||||
proc get_reference_count*(cr: PContext): int32{.cdecl,
|
||||
importc: "cairo_get_reference_count", dynlib: LIB_CAIRO.}
|
||||
proc get_user_data*(cr: PCairo, key: PUserDataKey): pointer{.cdecl,
|
||||
proc get_user_data*(cr: PContext, key: PUserDataKey): pointer{.cdecl,
|
||||
importc: "cairo_get_user_data", dynlib: LIB_CAIRO.}
|
||||
proc set_user_data*(cr: PCairo, key: PUserDataKey, user_data: Pointer,
|
||||
proc set_user_data*(cr: PContext, key: PUserDataKey, user_data: Pointer,
|
||||
destroy: TDestroyFunc): TStatus{.cdecl,
|
||||
importc: "cairo_set_user_data", dynlib: LIB_CAIRO.}
|
||||
proc save*(cr: PCairo){.cdecl, importc: "cairo_save", dynlib: LIB_CAIRO.}
|
||||
proc restore*(cr: PCairo){.cdecl, importc: "cairo_restore", dynlib: LIB_CAIRO.}
|
||||
proc push_group*(cr: PCairo){.cdecl, importc: "cairo_push_group", dynlib: LIB_CAIRO.}
|
||||
proc push_group_with_content*(cr: PCairo, content: TContent){.cdecl,
|
||||
proc save*(cr: PContext){.cdecl, importc: "cairo_save", dynlib: LIB_CAIRO.}
|
||||
proc restore*(cr: PContext){.cdecl, importc: "cairo_restore", dynlib: LIB_CAIRO.}
|
||||
proc push_group*(cr: PContext){.cdecl, importc: "cairo_push_group", dynlib: LIB_CAIRO.}
|
||||
proc push_group_with_content*(cr: PContext, content: TContent){.cdecl,
|
||||
importc: "cairo_push_group_with_content", dynlib: LIB_CAIRO.}
|
||||
proc pop_group*(cr: PCairo): PPattern{.cdecl, importc: "cairo_pop_group",
|
||||
proc pop_group*(cr: PContext): PPattern{.cdecl, importc: "cairo_pop_group",
|
||||
dynlib: LIB_CAIRO.}
|
||||
proc pop_group_to_source*(cr: PCairo){.cdecl, importc: "cairo_pop_group_to_source",
|
||||
proc pop_group_to_source*(cr: PContext){.cdecl, importc: "cairo_pop_group_to_source",
|
||||
dynlib: LIB_CAIRO.}
|
||||
#* Modify state
|
||||
proc set_operator*(cr: PCairo, op: TOperator){.cdecl, importc: "cairo_set_operator",
|
||||
proc set_operator*(cr: PContext, op: TOperator){.cdecl, importc: "cairo_set_operator",
|
||||
dynlib: LIB_CAIRO.}
|
||||
proc set_source*(cr: PCairo, source: PPattern){.cdecl, importc: "cairo_set_source",
|
||||
proc set_source*(cr: PContext, source: PPattern){.cdecl, importc: "cairo_set_source",
|
||||
dynlib: LIB_CAIRO.}
|
||||
proc set_source_rgb*(cr: PCairo, red, green, blue: float64){.cdecl,
|
||||
proc set_source_rgb*(cr: PContext, red, green, blue: float64){.cdecl,
|
||||
importc: "cairo_set_source_rgb", dynlib: LIB_CAIRO.}
|
||||
proc set_source_rgba*(cr: PCairo, red, green, blue, alpha: float64){.cdecl,
|
||||
proc set_source_rgba*(cr: PContext, red, green, blue, alpha: float64){.cdecl,
|
||||
importc: "cairo_set_source_rgba", dynlib: LIB_CAIRO.}
|
||||
proc set_source_surface*(cr: PCairo, surface: PSurface, x, y: float64){.cdecl,
|
||||
proc set_source*(cr: PContext, surface: PSurface, x, y: float64){.cdecl,
|
||||
importc: "cairo_set_source_surface", dynlib: LIB_CAIRO.}
|
||||
proc set_tolerance*(cr: PCairo, tolerance: float64){.cdecl,
|
||||
proc set_tolerance*(cr: PContext, tolerance: float64){.cdecl,
|
||||
importc: "cairo_set_tolerance", dynlib: LIB_CAIRO.}
|
||||
proc set_antialias*(cr: PCairo, antialias: TAntialias){.cdecl,
|
||||
proc set_antialias*(cr: PContext, antialias: TAntialias){.cdecl,
|
||||
importc: "cairo_set_antialias", dynlib: LIB_CAIRO.}
|
||||
proc set_fill_rule*(cr: PCairo, fill_rule: TFillRule){.cdecl,
|
||||
proc set_fill_rule*(cr: PContext, fill_rule: TFillRule){.cdecl,
|
||||
importc: "cairo_set_fill_rule", dynlib: LIB_CAIRO.}
|
||||
proc set_line_width*(cr: PCairo, width: float64){.cdecl,
|
||||
proc set_line_width*(cr: PContext, width: float64){.cdecl,
|
||||
importc: "cairo_set_line_width", dynlib: LIB_CAIRO.}
|
||||
proc set_line_cap*(cr: PCairo, line_cap: TLineCap){.cdecl,
|
||||
proc set_line_cap*(cr: PContext, line_cap: TLineCap){.cdecl,
|
||||
importc: "cairo_set_line_cap", dynlib: LIB_CAIRO.}
|
||||
proc set_line_join*(cr: PCairo, line_join: TLineJoin){.cdecl,
|
||||
proc set_line_join*(cr: PContext, line_join: TLineJoin){.cdecl,
|
||||
importc: "cairo_set_line_join", dynlib: LIB_CAIRO.}
|
||||
proc set_dash*(cr: PCairo, dashes: openarray[float64], offset: float64){.cdecl,
|
||||
proc set_dash*(cr: PContext, dashes: openarray[float64], offset: float64){.cdecl,
|
||||
importc: "cairo_set_dash", dynlib: LIB_CAIRO.}
|
||||
proc set_miter_limit*(cr: PCairo, limit: float64){.cdecl,
|
||||
proc set_miter_limit*(cr: PContext, limit: float64){.cdecl,
|
||||
importc: "cairo_set_miter_limit", dynlib: LIB_CAIRO.}
|
||||
proc translate*(cr: PCairo, tx, ty: float64){.cdecl, importc: "cairo_translate",
|
||||
proc translate*(cr: PContext, tx, ty: float64){.cdecl, importc: "cairo_translate",
|
||||
dynlib: LIB_CAIRO.}
|
||||
proc scale*(cr: PCairo, sx, sy: float64){.cdecl, importc: "cairo_scale",
|
||||
proc scale*(cr: PContext, sx, sy: float64){.cdecl, importc: "cairo_scale",
|
||||
dynlib: LIB_CAIRO.}
|
||||
proc rotate*(cr: PCairo, angle: float64){.cdecl, importc: "cairo_rotate",
|
||||
proc rotate*(cr: PContext, angle: float64){.cdecl, importc: "cairo_rotate",
|
||||
dynlib: LIB_CAIRO.}
|
||||
proc transform*(cr: PCairo, matrix: PMatrix){.cdecl, importc: "cairo_transform",
|
||||
proc transform*(cr: PContext, matrix: PMatrix){.cdecl, importc: "cairo_transform",
|
||||
dynlib: LIB_CAIRO.}
|
||||
proc set_matrix*(cr: PCairo, matrix: PMatrix){.cdecl, importc: "cairo_set_matrix",
|
||||
proc set_matrix*(cr: PContext, matrix: PMatrix){.cdecl, importc: "cairo_set_matrix",
|
||||
dynlib: LIB_CAIRO.}
|
||||
proc identity_matrix*(cr: PCairo){.cdecl, importc: "cairo_identity_matrix",
|
||||
proc identity_matrix*(cr: PContext){.cdecl, importc: "cairo_identity_matrix",
|
||||
dynlib: LIB_CAIRO.}
|
||||
proc user_to_device*(cr: PCairo, x, y: var float64){.cdecl,
|
||||
proc user_to_device*(cr: PContext, x, y: var float64){.cdecl,
|
||||
importc: "cairo_user_to_device", dynlib: LIB_CAIRO.}
|
||||
proc user_to_device_distance*(cr: PCairo, dx, dy: var float64){.cdecl,
|
||||
proc user_to_device_distance*(cr: PContext, dx, dy: var float64){.cdecl,
|
||||
importc: "cairo_user_to_device_distance", dynlib: LIB_CAIRO.}
|
||||
proc device_to_user*(cr: PCairo, x, y: var float64){.cdecl,
|
||||
proc device_to_user*(cr: PContext, x, y: var float64){.cdecl,
|
||||
importc: "cairo_device_to_user", dynlib: LIB_CAIRO.}
|
||||
proc device_to_user_distance*(cr: PCairo, dx, dy: var float64){.cdecl,
|
||||
proc device_to_user_distance*(cr: PContext, dx, dy: var float64){.cdecl,
|
||||
importc: "cairo_device_to_user_distance", dynlib: LIB_CAIRO.}
|
||||
#* Path creation functions
|
||||
proc new_path*(cr: PCairo){.cdecl, importc: "cairo_new_path", dynlib: LIB_CAIRO.}
|
||||
proc move_to*(cr: PCairo, x, y: float64){.cdecl, importc: "cairo_move_to",
|
||||
proc new_path*(cr: PContext){.cdecl, importc: "cairo_new_path", dynlib: LIB_CAIRO.}
|
||||
proc move_to*(cr: PContext, x, y: float64){.cdecl, importc: "cairo_move_to",
|
||||
dynlib: LIB_CAIRO.}
|
||||
proc new_sub_path*(cr: PCairo){.cdecl, importc: "cairo_new_sub_path",
|
||||
proc new_sub_path*(cr: PContext){.cdecl, importc: "cairo_new_sub_path",
|
||||
dynlib: LIB_CAIRO.}
|
||||
proc line_to*(cr: PCairo, x, y: float64){.cdecl, importc: "cairo_line_to",
|
||||
proc line_to*(cr: PContext, x, y: float64){.cdecl, importc: "cairo_line_to",
|
||||
dynlib: LIB_CAIRO.}
|
||||
proc curve_to*(cr: PCairo, x1, y1, x2, y2, x3, y3: float64){.cdecl,
|
||||
proc curve_to*(cr: PContext, x1, y1, x2, y2, x3, y3: float64){.cdecl,
|
||||
importc: "cairo_curve_to", dynlib: LIB_CAIRO.}
|
||||
proc arc*(cr: PCairo, xc, yc, radius, angle1, angle2: float64){.cdecl,
|
||||
proc arc*(cr: PContext, xc, yc, radius, angle1, angle2: float64){.cdecl,
|
||||
importc: "cairo_arc", dynlib: LIB_CAIRO.}
|
||||
proc arc_negative*(cr: PCairo, xc, yc, radius, angle1, angle2: float64){.cdecl,
|
||||
proc arc_negative*(cr: PContext, xc, yc, radius, angle1, angle2: float64){.cdecl,
|
||||
importc: "cairo_arc_negative", dynlib: LIB_CAIRO.}
|
||||
proc rel_move_to*(cr: PCairo, dx, dy: float64){.cdecl, importc: "cairo_rel_move_to",
|
||||
proc rel_move_to*(cr: PContext, dx, dy: float64){.cdecl, importc: "cairo_rel_move_to",
|
||||
dynlib: LIB_CAIRO.}
|
||||
proc rel_line_to*(cr: PCairo, dx, dy: float64){.cdecl, importc: "cairo_rel_line_to",
|
||||
proc rel_line_to*(cr: PContext, dx, dy: float64){.cdecl, importc: "cairo_rel_line_to",
|
||||
dynlib: LIB_CAIRO.}
|
||||
proc rel_curve_to*(cr: PCairo, dx1, dy1, dx2, dy2, dx3, dy3: float64){.cdecl,
|
||||
proc rel_curve_to*(cr: PContext, dx1, dy1, dx2, dy2, dx3, dy3: float64){.cdecl,
|
||||
importc: "cairo_rel_curve_to", dynlib: LIB_CAIRO.}
|
||||
proc rectangle*(cr: PCairo, x, y, width, height: float64){.cdecl,
|
||||
proc rectangle*(cr: PContext, x, y, width, height: float64){.cdecl,
|
||||
importc: "cairo_rectangle", dynlib: LIB_CAIRO.}
|
||||
proc close_path*(cr: PCairo){.cdecl, importc: "cairo_close_path", dynlib: LIB_CAIRO.}
|
||||
proc close_path*(cr: PContext){.cdecl, importc: "cairo_close_path", dynlib: LIB_CAIRO.}
|
||||
#* Painting functions
|
||||
proc paint*(cr: PCairo){.cdecl, importc: "cairo_paint", dynlib: LIB_CAIRO.}
|
||||
proc paint_with_alpha*(cr: PCairo, alpha: float64){.cdecl,
|
||||
proc paint*(cr: PContext){.cdecl, importc: "cairo_paint", dynlib: LIB_CAIRO.}
|
||||
proc paint_with_alpha*(cr: PContext, alpha: float64){.cdecl,
|
||||
importc: "cairo_paint_with_alpha", dynlib: LIB_CAIRO.}
|
||||
proc mask*(cr: PCairo, pattern: PPattern){.cdecl, importc: "cairo_mask",
|
||||
proc mask*(cr: PContext, pattern: PPattern){.cdecl, importc: "cairo_mask",
|
||||
dynlib: LIB_CAIRO.}
|
||||
proc mask_surface*(cr: PCairo, surface: PSurface, surface_x, surface_y: float64){.
|
||||
proc mask*(cr: PContext, surface: PSurface, surface_x, surface_y: float64){.
|
||||
cdecl, importc: "cairo_mask_surface", dynlib: LIB_CAIRO.}
|
||||
proc stroke*(cr: PCairo){.cdecl, importc: "cairo_stroke", dynlib: LIB_CAIRO.}
|
||||
proc stroke_preserve*(cr: PCairo){.cdecl, importc: "cairo_stroke_preserve",
|
||||
proc stroke*(cr: PContext){.cdecl, importc: "cairo_stroke", dynlib: LIB_CAIRO.}
|
||||
proc stroke_preserve*(cr: PContext){.cdecl, importc: "cairo_stroke_preserve",
|
||||
dynlib: LIB_CAIRO.}
|
||||
proc fill*(cr: PCairo){.cdecl, importc: "cairo_fill", dynlib: LIB_CAIRO.}
|
||||
proc fill_preserve*(cr: PCairo){.cdecl, importc: "cairo_fill_preserve",
|
||||
proc fill*(cr: PContext){.cdecl, importc: "cairo_fill", dynlib: LIB_CAIRO.}
|
||||
proc fill_preserve*(cr: PContext){.cdecl, importc: "cairo_fill_preserve",
|
||||
dynlib: LIB_CAIRO.}
|
||||
proc copy_page*(cr: PCairo){.cdecl, importc: "cairo_copy_page", dynlib: LIB_CAIRO.}
|
||||
proc show_page*(cr: PCairo){.cdecl, importc: "cairo_show_page", dynlib: LIB_CAIRO.}
|
||||
proc copy_page*(cr: PContext){.cdecl, importc: "cairo_copy_page", dynlib: LIB_CAIRO.}
|
||||
proc show_page*(cr: PContext){.cdecl, importc: "cairo_show_page", dynlib: LIB_CAIRO.}
|
||||
#* Insideness testing
|
||||
proc in_stroke*(cr: PCairo, x, y: float64): TBool{.cdecl, importc: "cairo_in_stroke",
|
||||
proc in_stroke*(cr: PContext, x, y: float64): TBool{.cdecl, importc: "cairo_in_stroke",
|
||||
dynlib: LIB_CAIRO.}
|
||||
proc in_fill*(cr: PCairo, x, y: float64): TBool{.cdecl, importc: "cairo_in_fill",
|
||||
proc in_fill*(cr: PContext, x, y: float64): TBool{.cdecl, importc: "cairo_in_fill",
|
||||
dynlib: LIB_CAIRO.}
|
||||
#* Rectangular extents
|
||||
proc stroke_extents*(cr: PCairo, x1, y1, x2, y2: var float64){.cdecl,
|
||||
proc stroke_extents*(cr: PContext, x1, y1, x2, y2: var float64){.cdecl,
|
||||
importc: "cairo_stroke_extents", dynlib: LIB_CAIRO.}
|
||||
proc fill_extents*(cr: PCairo, x1, y1, x2, y2: var float64){.cdecl,
|
||||
proc fill_extents*(cr: PContext, x1, y1, x2, y2: var float64){.cdecl,
|
||||
importc: "cairo_fill_extents", dynlib: LIB_CAIRO.}
|
||||
#* Clipping
|
||||
proc reset_clip*(cr: PCairo){.cdecl, importc: "cairo_reset_clip", dynlib: LIB_CAIRO.}
|
||||
proc clip*(cr: PCairo){.cdecl, importc: "cairo_clip", dynlib: LIB_CAIRO.}
|
||||
proc clip_preserve*(cr: PCairo){.cdecl, importc: "cairo_clip_preserve",
|
||||
proc reset_clip*(cr: PContext){.cdecl, importc: "cairo_reset_clip", dynlib: LIB_CAIRO.}
|
||||
proc clip*(cr: PContext){.cdecl, importc: "cairo_clip", dynlib: LIB_CAIRO.}
|
||||
proc clip_preserve*(cr: PContext){.cdecl, importc: "cairo_clip_preserve",
|
||||
dynlib: LIB_CAIRO.}
|
||||
proc clip_extents*(cr: PCairo, x1, y1, x2, y2: var float64){.cdecl,
|
||||
proc clip_extents*(cr: PContext, x1, y1, x2, y2: var float64){.cdecl,
|
||||
importc: "cairo_clip_extents", dynlib: LIB_CAIRO.}
|
||||
proc copy_clip_rectangle_list*(cr: PCairo): PRectangleList{.cdecl,
|
||||
proc copy_clip_rectangle_list*(cr: PContext): PRectangleList{.cdecl,
|
||||
importc: "cairo_copy_clip_rectangle_list", dynlib: LIB_CAIRO.}
|
||||
proc rectangle_list_destroy*(rectangle_list: PRectangleList){.cdecl,
|
||||
importc: "cairo_rectangle_list_destroy", dynlib: LIB_CAIRO.}
|
||||
#* Font/Text functions
|
||||
proc font_options_create*(): PFontOptions{.cdecl,
|
||||
importc: "cairo_font_options_create", dynlib: LIB_CAIRO.}
|
||||
proc font_options_copy*(original: PFontOptions): PFontOptions{.cdecl,
|
||||
proc copy*(original: PFontOptions): PFontOptions{.cdecl,
|
||||
importc: "cairo_font_options_copy", dynlib: LIB_CAIRO.}
|
||||
proc font_options_destroy*(options: PFontOptions){.cdecl,
|
||||
proc destroy*(options: PFontOptions){.cdecl,
|
||||
importc: "cairo_font_options_destroy", dynlib: LIB_CAIRO.}
|
||||
proc font_options_status*(options: PFontOptions): TStatus{.cdecl,
|
||||
proc status*(options: PFontOptions): TStatus{.cdecl,
|
||||
importc: "cairo_font_options_status", dynlib: LIB_CAIRO.}
|
||||
proc font_options_merge*(options, other: PFontOptions){.cdecl,
|
||||
proc merge*(options, other: PFontOptions){.cdecl,
|
||||
importc: "cairo_font_options_merge", dynlib: LIB_CAIRO.}
|
||||
proc font_options_equal*(options, other: PFontOptions): TBool{.cdecl,
|
||||
proc equal*(options, other: PFontOptions): TBool{.cdecl,
|
||||
importc: "cairo_font_options_equal", dynlib: LIB_CAIRO.}
|
||||
proc font_options_hash*(options: PFontOptions): int32{.cdecl,
|
||||
proc hash*(options: PFontOptions): int32{.cdecl,
|
||||
importc: "cairo_font_options_hash", dynlib: LIB_CAIRO.}
|
||||
proc font_options_set_antialias*(options: PFontOptions, antialias: TAntialias){.
|
||||
proc set_antialias*(options: PFontOptions, antialias: TAntialias){.
|
||||
cdecl, importc: "cairo_font_options_set_antialias", dynlib: LIB_CAIRO.}
|
||||
proc font_options_get_antialias*(options: PFontOptions): TAntialias{.cdecl,
|
||||
proc get_antialias*(options: PFontOptions): TAntialias{.cdecl,
|
||||
importc: "cairo_font_options_get_antialias", dynlib: LIB_CAIRO.}
|
||||
proc font_options_set_subpixel_order*(options: PFontOptions,
|
||||
proc set_subpixel_order*(options: PFontOptions,
|
||||
subpixel_order: TSubpixelOrder){.cdecl,
|
||||
importc: "cairo_font_options_set_subpixel_order", dynlib: LIB_CAIRO.}
|
||||
proc font_options_get_subpixel_order*(options: PFontOptions): TSubpixelOrder{.
|
||||
proc get_subpixel_order*(options: PFontOptions): TSubpixelOrder{.
|
||||
cdecl, importc: "cairo_font_options_get_subpixel_order", dynlib: LIB_CAIRO.}
|
||||
proc font_options_set_hint_style*(options: PFontOptions, hint_style: THintStyle){.
|
||||
proc set_hint_style*(options: PFontOptions, hint_style: THintStyle){.
|
||||
cdecl, importc: "cairo_font_options_set_hint_style", dynlib: LIB_CAIRO.}
|
||||
proc font_options_get_hint_style*(options: PFontOptions): THintStyle{.cdecl,
|
||||
proc get_hint_style*(options: PFontOptions): THintStyle{.cdecl,
|
||||
importc: "cairo_font_options_get_hint_style", dynlib: LIB_CAIRO.}
|
||||
proc font_options_set_hint_metrics*(options: PFontOptions,
|
||||
proc set_hint_metrics*(options: PFontOptions,
|
||||
hint_metrics: THintMetrics){.cdecl,
|
||||
importc: "cairo_font_options_set_hint_metrics", dynlib: LIB_CAIRO.}
|
||||
proc font_options_get_hint_metrics*(options: PFontOptions): THintMetrics{.cdecl,
|
||||
proc get_hint_metrics*(options: PFontOptions): THintMetrics{.cdecl,
|
||||
importc: "cairo_font_options_get_hint_metrics", dynlib: LIB_CAIRO.}
|
||||
#* This interface is for dealing with text as text, not caring about the
|
||||
# font object inside the the TCairo.
|
||||
proc select_font_face*(cr: PCairo, family: cstring, slant: TFontSlant,
|
||||
proc select_font_face*(cr: PContext, family: cstring, slant: TFontSlant,
|
||||
weight: TFontWeight){.cdecl,
|
||||
importc: "cairo_select_font_face", dynlib: LIB_CAIRO.}
|
||||
proc set_font_size*(cr: PCairo, size: float64){.cdecl,
|
||||
proc set_font_size*(cr: PContext, size: float64){.cdecl,
|
||||
importc: "cairo_set_font_size", dynlib: LIB_CAIRO.}
|
||||
proc set_font_matrix*(cr: PCairo, matrix: PMatrix){.cdecl,
|
||||
proc set_font_matrix*(cr: PContext, matrix: PMatrix){.cdecl,
|
||||
importc: "cairo_set_font_matrix", dynlib: LIB_CAIRO.}
|
||||
proc get_font_matrix*(cr: PCairo, matrix: PMatrix){.cdecl,
|
||||
proc get_font_matrix*(cr: PContext, matrix: PMatrix){.cdecl,
|
||||
importc: "cairo_get_font_matrix", dynlib: LIB_CAIRO.}
|
||||
proc set_font_options*(cr: PCairo, options: PFontOptions){.cdecl,
|
||||
proc set_font_options*(cr: PContext, options: PFontOptions){.cdecl,
|
||||
importc: "cairo_set_font_options", dynlib: LIB_CAIRO.}
|
||||
proc get_font_options*(cr: PCairo, options: PFontOptions){.cdecl,
|
||||
proc get_font_options*(cr: PContext, options: PFontOptions){.cdecl,
|
||||
importc: "cairo_get_font_options", dynlib: LIB_CAIRO.}
|
||||
proc set_font_face*(cr: PCairo, font_face: PFontFace){.cdecl,
|
||||
proc set_font_face*(cr: PContext, font_face: PFontFace){.cdecl,
|
||||
importc: "cairo_set_font_face", dynlib: LIB_CAIRO.}
|
||||
proc get_font_face*(cr: PCairo): PFontFace{.cdecl, importc: "cairo_get_font_face",
|
||||
proc get_font_face*(cr: PContext): PFontFace{.cdecl, importc: "cairo_get_font_face",
|
||||
dynlib: LIB_CAIRO.}
|
||||
proc set_scaled_font*(cr: PCairo, scaled_font: PScaledFont){.cdecl,
|
||||
proc set_scaled_font*(cr: PContext, scaled_font: PScaledFont){.cdecl,
|
||||
importc: "cairo_set_scaled_font", dynlib: LIB_CAIRO.}
|
||||
proc get_scaled_font*(cr: PCairo): PScaledFont{.cdecl,
|
||||
proc get_scaled_font*(cr: PContext): PScaledFont{.cdecl,
|
||||
importc: "cairo_get_scaled_font", dynlib: LIB_CAIRO.}
|
||||
proc show_text*(cr: PCairo, utf8: cstring){.cdecl, importc: "cairo_show_text",
|
||||
proc show_text*(cr: PContext, utf8: cstring){.cdecl, importc: "cairo_show_text",
|
||||
dynlib: LIB_CAIRO.}
|
||||
proc show_glyphs*(cr: PCairo, glyphs: PGlyph, num_glyphs: int32){.cdecl,
|
||||
proc show_glyphs*(cr: PContext, glyphs: PGlyph, num_glyphs: int32){.cdecl,
|
||||
importc: "cairo_show_glyphs", dynlib: LIB_CAIRO.}
|
||||
proc text_path*(cr: PCairo, utf8: cstring){.cdecl, importc: "cairo_text_path",
|
||||
proc text_path*(cr: PContext, utf8: cstring){.cdecl, importc: "cairo_text_path",
|
||||
dynlib: LIB_CAIRO.}
|
||||
proc glyph_path*(cr: PCairo, glyphs: PGlyph, num_glyphs: int32){.cdecl,
|
||||
proc glyph_path*(cr: PContext, glyphs: PGlyph, num_glyphs: int32){.cdecl,
|
||||
importc: "cairo_glyph_path", dynlib: LIB_CAIRO.}
|
||||
proc text_extents*(cr: PCairo, utf8: cstring, extents: PTextExtents){.cdecl,
|
||||
proc text_extents*(cr: PContext, utf8: cstring, extents: PTextExtents){.cdecl,
|
||||
importc: "cairo_text_extents", dynlib: LIB_CAIRO.}
|
||||
proc glyph_extents*(cr: PCairo, glyphs: PGlyph, num_glyphs: int32,
|
||||
proc glyph_extents*(cr: PContext, glyphs: PGlyph, num_glyphs: int32,
|
||||
extents: PTextExtents){.cdecl,
|
||||
importc: "cairo_glyph_extents", dynlib: LIB_CAIRO.}
|
||||
proc font_extents*(cr: PCairo, extents: PFontExtents){.cdecl,
|
||||
proc font_extents*(cr: PContext, extents: PFontExtents){.cdecl,
|
||||
importc: "cairo_font_extents", dynlib: LIB_CAIRO.}
|
||||
#* Generic identifier for a font style
|
||||
proc font_face_reference*(font_face: PFontFace): PFontFace{.cdecl,
|
||||
proc reference*(font_face: PFontFace): PFontFace{.cdecl,
|
||||
importc: "cairo_font_face_reference", dynlib: LIB_CAIRO.}
|
||||
proc font_face_destroy*(font_face: PFontFace){.cdecl,
|
||||
proc destroy*(font_face: PFontFace){.cdecl,
|
||||
importc: "cairo_font_face_destroy", dynlib: LIB_CAIRO.}
|
||||
proc font_face_get_reference_count*(font_face: PFontFace): int32{.cdecl,
|
||||
proc get_reference_count*(font_face: PFontFace): int32{.cdecl,
|
||||
importc: "cairo_font_face_get_reference_count", dynlib: LIB_CAIRO.}
|
||||
proc font_face_status*(font_face: PFontFace): TStatus{.cdecl,
|
||||
proc status*(font_face: PFontFace): TStatus{.cdecl,
|
||||
importc: "cairo_font_face_status", dynlib: LIB_CAIRO.}
|
||||
proc font_face_get_type*(font_face: PFontFace): TFontType{.cdecl,
|
||||
proc get_type*(font_face: PFontFace): TFontType{.cdecl,
|
||||
importc: "cairo_font_face_get_type", dynlib: LIB_CAIRO.}
|
||||
proc font_face_get_user_data*(font_face: PFontFace, key: PUserDataKey): pointer{.
|
||||
proc get_user_data*(font_face: PFontFace, key: PUserDataKey): pointer{.
|
||||
cdecl, importc: "cairo_font_face_get_user_data", dynlib: LIB_CAIRO.}
|
||||
proc font_face_set_user_data*(font_face: PFontFace, key: PUserDataKey,
|
||||
user_data: pointer, destroy: TDestroyFunc): TStatus{.
|
||||
proc set_user_data*(font_face: PFontFace, key: PUserDataKey,
|
||||
user_data: pointer, destroy: TDestroyFunc): TStatus{.
|
||||
cdecl, importc: "cairo_font_face_set_user_data", dynlib: LIB_CAIRO.}
|
||||
#* Portable interface to general font features
|
||||
proc scaled_font_create*(font_face: PFontFace, font_matrix: PMatrix,
|
||||
ctm: PMatrix, options: PFontOptions): PScaledFont{.
|
||||
cdecl, importc: "cairo_scaled_font_create", dynlib: LIB_CAIRO.}
|
||||
proc scaled_font_reference*(scaled_font: PScaledFont): PScaledFont{.cdecl,
|
||||
proc reference*(scaled_font: PScaledFont): PScaledFont{.cdecl,
|
||||
importc: "cairo_scaled_font_reference", dynlib: LIB_CAIRO.}
|
||||
proc scaled_font_destroy*(scaled_font: PScaledFont){.cdecl,
|
||||
proc destroy*(scaled_font: PScaledFont){.cdecl,
|
||||
importc: "cairo_scaled_font_destroy", dynlib: LIB_CAIRO.}
|
||||
proc scaled_font_get_reference_count*(scaled_font: PScaledFont): int32{.cdecl,
|
||||
proc get_reference_count*(scaled_font: PScaledFont): int32{.cdecl,
|
||||
importc: "cairo_scaled_font_get_reference_count", dynlib: LIB_CAIRO.}
|
||||
proc scaled_font_status*(scaled_font: PScaledFont): TStatus{.cdecl,
|
||||
proc status*(scaled_font: PScaledFont): TStatus{.cdecl,
|
||||
importc: "cairo_scaled_font_status", dynlib: LIB_CAIRO.}
|
||||
proc scaled_font_get_type*(scaled_font: PScaledFont): TFontType{.cdecl,
|
||||
proc get_type*(scaled_font: PScaledFont): TFontType{.cdecl,
|
||||
importc: "cairo_scaled_font_get_type", dynlib: LIB_CAIRO.}
|
||||
proc scaled_font_get_user_data*(scaled_font: PScaledFont, key: PUserDataKey): Pointer{.
|
||||
proc get_user_data*(scaled_font: PScaledFont, key: PUserDataKey): Pointer{.
|
||||
cdecl, importc: "cairo_scaled_font_get_user_data", dynlib: LIB_CAIRO.}
|
||||
proc scaled_font_set_user_data*(scaled_font: PScaledFont, key: PUserDataKey,
|
||||
user_data: Pointer, destroy: TDestroyFunc): TStatus{.
|
||||
proc set_user_data*(scaled_font: PScaledFont, key: PUserDataKey,
|
||||
user_data: Pointer, destroy: TDestroyFunc): TStatus{.
|
||||
cdecl, importc: "cairo_scaled_font_set_user_data", dynlib: LIB_CAIRO.}
|
||||
proc scaled_font_extents*(scaled_font: PScaledFont, extents: PFontExtents){.
|
||||
proc extents*(scaled_font: PScaledFont, extents: PFontExtents){.
|
||||
cdecl, importc: "cairo_scaled_font_extents", dynlib: LIB_CAIRO.}
|
||||
proc scaled_font_text_extents*(scaled_font: PScaledFont, utf8: cstring,
|
||||
extents: PTextExtents){.cdecl,
|
||||
proc text_extents*(scaled_font: PScaledFont, utf8: cstring,
|
||||
extents: PTextExtents){.cdecl,
|
||||
importc: "cairo_scaled_font_text_extents", dynlib: LIB_CAIRO.}
|
||||
proc scaled_font_glyph_extents*(scaled_font: PScaledFont, glyphs: PGlyph,
|
||||
proc glyph_extents*(scaled_font: PScaledFont, glyphs: PGlyph,
|
||||
num_glyphs: int32, extents: PTextExtents){.
|
||||
cdecl, importc: "cairo_scaled_font_glyph_extents", dynlib: LIB_CAIRO.}
|
||||
proc scaled_font_get_font_face*(scaled_font: PScaledFont): PFontFace{.cdecl,
|
||||
proc get_font_face*(scaled_font: PScaledFont): PFontFace{.cdecl,
|
||||
importc: "cairo_scaled_font_get_font_face", dynlib: LIB_CAIRO.}
|
||||
proc scaled_font_get_font_matrix*(scaled_font: PScaledFont, font_matrix: PMatrix){.
|
||||
proc get_font_matrix*(scaled_font: PScaledFont, font_matrix: PMatrix){.
|
||||
cdecl, importc: "cairo_scaled_font_get_font_matrix", dynlib: LIB_CAIRO.}
|
||||
proc scaled_font_get_ctm*(scaled_font: PScaledFont, ctm: PMatrix){.cdecl,
|
||||
proc get_ctm*(scaled_font: PScaledFont, ctm: PMatrix){.cdecl,
|
||||
importc: "cairo_scaled_font_get_ctm", dynlib: LIB_CAIRO.}
|
||||
proc scaled_font_get_font_options*(scaled_font: PScaledFont,
|
||||
proc get_font_options*(scaled_font: PScaledFont,
|
||||
options: PFontOptions){.cdecl,
|
||||
importc: "cairo_scaled_font_get_font_options", dynlib: LIB_CAIRO.}
|
||||
#* Query functions
|
||||
proc get_operator*(cr: PCairo): TOperator{.cdecl, importc: "cairo_get_operator",
|
||||
proc get_operator*(cr: PContext): TOperator{.cdecl, importc: "cairo_get_operator",
|
||||
dynlib: LIB_CAIRO.}
|
||||
proc get_source*(cr: PCairo): PPattern{.cdecl, importc: "cairo_get_source",
|
||||
proc get_source*(cr: PContext): PPattern{.cdecl, importc: "cairo_get_source",
|
||||
dynlib: LIB_CAIRO.}
|
||||
proc get_tolerance*(cr: PCairo): float64{.cdecl, importc: "cairo_get_tolerance",
|
||||
proc get_tolerance*(cr: PContext): float64{.cdecl, importc: "cairo_get_tolerance",
|
||||
dynlib: LIB_CAIRO.}
|
||||
proc get_antialias*(cr: PCairo): TAntialias{.cdecl, importc: "cairo_get_antialias",
|
||||
proc get_antialias*(cr: PContext): TAntialias{.cdecl, importc: "cairo_get_antialias",
|
||||
dynlib: LIB_CAIRO.}
|
||||
proc get_current_point*(cr: PCairo, x, y: var float64){.cdecl,
|
||||
proc get_current_point*(cr: PContext, x, y: var float64){.cdecl,
|
||||
importc: "cairo_get_current_point", dynlib: LIB_CAIRO.}
|
||||
proc get_fill_rule*(cr: PCairo): TFillRule{.cdecl, importc: "cairo_get_fill_rule",
|
||||
proc get_fill_rule*(cr: PContext): TFillRule{.cdecl, importc: "cairo_get_fill_rule",
|
||||
dynlib: LIB_CAIRO.}
|
||||
proc get_line_width*(cr: PCairo): float64{.cdecl, importc: "cairo_get_line_width",
|
||||
proc get_line_width*(cr: PContext): float64{.cdecl, importc: "cairo_get_line_width",
|
||||
dynlib: LIB_CAIRO.}
|
||||
proc get_line_cap*(cr: PCairo): TLineCap{.cdecl, importc: "cairo_get_line_cap",
|
||||
proc get_line_cap*(cr: PContext): TLineCap{.cdecl, importc: "cairo_get_line_cap",
|
||||
dynlib: LIB_CAIRO.}
|
||||
proc get_line_join*(cr: PCairo): TLineJoin{.cdecl, importc: "cairo_get_line_join",
|
||||
proc get_line_join*(cr: PContext): TLineJoin{.cdecl, importc: "cairo_get_line_join",
|
||||
dynlib: LIB_CAIRO.}
|
||||
proc get_miter_limit*(cr: PCairo): float64{.cdecl, importc: "cairo_get_miter_limit",
|
||||
proc get_miter_limit*(cr: PContext): float64{.cdecl, importc: "cairo_get_miter_limit",
|
||||
dynlib: LIB_CAIRO.}
|
||||
proc get_dash_count*(cr: PCairo): int32{.cdecl, importc: "cairo_get_dash_count",
|
||||
proc get_dash_count*(cr: PContext): int32{.cdecl, importc: "cairo_get_dash_count",
|
||||
dynlib: LIB_CAIRO.}
|
||||
proc get_dash*(cr: PCairo, dashes, offset: var float64){.cdecl,
|
||||
proc get_dash*(cr: PContext, dashes, offset: var float64){.cdecl,
|
||||
importc: "cairo_get_dash", dynlib: LIB_CAIRO.}
|
||||
proc get_matrix*(cr: PCairo, matrix: PMatrix){.cdecl, importc: "cairo_get_matrix",
|
||||
proc get_matrix*(cr: PContext, matrix: PMatrix){.cdecl, importc: "cairo_get_matrix",
|
||||
dynlib: LIB_CAIRO.}
|
||||
proc get_target*(cr: PCairo): PSurface{.cdecl, importc: "cairo_get_target",
|
||||
proc get_target*(cr: PContext): PSurface{.cdecl, importc: "cairo_get_target",
|
||||
dynlib: LIB_CAIRO.}
|
||||
proc get_group_target*(cr: PCairo): PSurface{.cdecl,
|
||||
proc get_group_target*(cr: PContext): PSurface{.cdecl,
|
||||
importc: "cairo_get_group_target", dynlib: LIB_CAIRO.}
|
||||
proc copy_path*(cr: PCairo): PPath{.cdecl, importc: "cairo_copy_path",
|
||||
proc copy_path*(cr: PContext): PPath{.cdecl, importc: "cairo_copy_path",
|
||||
dynlib: LIB_CAIRO.}
|
||||
proc copy_path_flat*(cr: PCairo): PPath{.cdecl, importc: "cairo_copy_path_flat",
|
||||
proc copy_path_flat*(cr: PContext): PPath{.cdecl, importc: "cairo_copy_path_flat",
|
||||
dynlib: LIB_CAIRO.}
|
||||
proc append_path*(cr: PCairo, path: PPath){.cdecl, importc: "cairo_append_path",
|
||||
proc append_path*(cr: PContext, path: PPath){.cdecl, importc: "cairo_append_path",
|
||||
dynlib: LIB_CAIRO.}
|
||||
proc path_destroy*(path: PPath){.cdecl, importc: "cairo_path_destroy",
|
||||
proc destroy*(path: PPath){.cdecl, importc: "cairo_path_destroy",
|
||||
dynlib: LIB_CAIRO.}
|
||||
#* Error status queries
|
||||
proc status*(cr: PCairo): TStatus{.cdecl, importc: "cairo_status", dynlib: LIB_CAIRO.}
|
||||
proc status*(cr: PContext): TStatus{.cdecl, importc: "cairo_status", dynlib: LIB_CAIRO.}
|
||||
proc status_to_string*(status: TStatus): cstring{.cdecl,
|
||||
importc: "cairo_status_to_string", dynlib: LIB_CAIRO.}
|
||||
#* Surface manipulation
|
||||
proc surface_create_similar*(other: PSurface, content: TContent,
|
||||
width, height: int32): PSurface{.cdecl,
|
||||
importc: "cairo_surface_create_similar", dynlib: LIB_CAIRO.}
|
||||
proc surface_reference*(surface: PSurface): PSurface{.cdecl,
|
||||
proc reference*(surface: PSurface): PSurface{.cdecl,
|
||||
importc: "cairo_surface_reference", dynlib: LIB_CAIRO.}
|
||||
proc surface_finish*(surface: PSurface){.cdecl, importc: "cairo_surface_finish",
|
||||
proc finish*(surface: PSurface){.cdecl, importc: "cairo_surface_finish",
|
||||
dynlib: LIB_CAIRO.}
|
||||
proc surface_destroy*(surface: PSurface){.cdecl,
|
||||
proc destroy*(surface: PSurface){.cdecl,
|
||||
importc: "cairo_surface_destroy", dynlib: LIB_CAIRO.}
|
||||
proc surface_get_reference_count*(surface: PSurface): int32{.cdecl,
|
||||
proc get_reference_count*(surface: PSurface): int32{.cdecl,
|
||||
importc: "cairo_surface_get_reference_count", dynlib: LIB_CAIRO.}
|
||||
proc surface_status*(surface: PSurface): TStatus{.cdecl,
|
||||
proc status*(surface: PSurface): TStatus{.cdecl,
|
||||
importc: "cairo_surface_status", dynlib: LIB_CAIRO.}
|
||||
proc surface_get_type*(surface: PSurface): TSurfaceType{.cdecl,
|
||||
proc get_type*(surface: PSurface): TSurfaceType{.cdecl,
|
||||
importc: "cairo_surface_get_type", dynlib: LIB_CAIRO.}
|
||||
proc surface_get_content*(surface: PSurface): TContent{.cdecl,
|
||||
proc get_content*(surface: PSurface): TContent{.cdecl,
|
||||
importc: "cairo_surface_get_content", dynlib: LIB_CAIRO.}
|
||||
proc surface_write_to_png*(surface: PSurface, filename: cstring): TStatus{.
|
||||
proc write_to_png*(surface: PSurface, filename: cstring): TStatus{.
|
||||
cdecl, importc: "cairo_surface_write_to_png", dynlib: LIB_CAIRO.}
|
||||
proc surface_write_to_png_stream*(surface: PSurface, write_func: TWriteFunc,
|
||||
closure: pointer): TStatus{.cdecl,
|
||||
proc write_to_png*(surface: PSurface, write_func: TWriteFunc,
|
||||
closure: pointer): TStatus{.cdecl,
|
||||
importc: "cairo_surface_write_to_png_stream", dynlib: LIB_CAIRO.}
|
||||
proc surface_get_user_data*(surface: PSurface, key: PUserDataKey): pointer{.
|
||||
proc get_user_data*(surface: PSurface, key: PUserDataKey): pointer{.
|
||||
cdecl, importc: "cairo_surface_get_user_data", dynlib: LIB_CAIRO.}
|
||||
proc surface_set_user_data*(surface: PSurface, key: PUserDataKey,
|
||||
proc set_user_data*(surface: PSurface, key: PUserDataKey,
|
||||
user_data: pointer, destroy: TDestroyFunc): TStatus{.
|
||||
cdecl, importc: "cairo_surface_set_user_data", dynlib: LIB_CAIRO.}
|
||||
proc surface_get_font_options*(surface: PSurface, options: PFontOptions){.cdecl,
|
||||
proc get_font_options*(surface: PSurface, options: PFontOptions){.cdecl,
|
||||
importc: "cairo_surface_get_font_options", dynlib: LIB_CAIRO.}
|
||||
proc surface_flush*(surface: PSurface){.cdecl, importc: "cairo_surface_flush",
|
||||
proc flush*(surface: PSurface){.cdecl, importc: "cairo_surface_flush",
|
||||
dynlib: LIB_CAIRO.}
|
||||
proc surface_mark_dirty*(surface: PSurface){.cdecl,
|
||||
proc mark_dirty*(surface: PSurface){.cdecl,
|
||||
importc: "cairo_surface_mark_dirty", dynlib: LIB_CAIRO.}
|
||||
proc surface_mark_dirty_rectangle*(surface: PSurface, x, y, width, height: int32){.
|
||||
proc mark_dirty_rectangle*(surface: PSurface, x, y, width, height: int32){.
|
||||
cdecl, importc: "cairo_surface_mark_dirty_rectangle", dynlib: LIB_CAIRO.}
|
||||
proc surface_set_device_offset*(surface: PSurface, x_offset, y_offset: float64){.
|
||||
proc set_device_offset*(surface: PSurface, x_offset, y_offset: float64){.
|
||||
cdecl, importc: "cairo_surface_set_device_offset", dynlib: LIB_CAIRO.}
|
||||
proc surface_get_device_offset*(surface: PSurface,
|
||||
proc get_device_offset*(surface: PSurface,
|
||||
x_offset, y_offset: var float64){.cdecl,
|
||||
importc: "cairo_surface_get_device_offset", dynlib: LIB_CAIRO.}
|
||||
proc surface_set_fallback_resolution*(surface: PSurface, x_pixels_per_inch,
|
||||
proc set_fallback_resolution*(surface: PSurface, x_pixels_per_inch,
|
||||
y_pixels_per_inch: float64){.cdecl, importc: "cairo_surface_set_fallback_resolution",
|
||||
dynlib: LIB_CAIRO.}
|
||||
#* Image-surface functions
|
||||
proc image_surface_create*(format: TFormat, width, height: int32): PSurface{.
|
||||
cdecl, importc: "cairo_image_surface_create", dynlib: LIB_CAIRO.}
|
||||
proc image_surface_create_for_data*(data: Pbyte, format: TFormat,
|
||||
width, height, stride: int32): PSurface{.
|
||||
proc image_surface_create*(data: Pbyte, format: TFormat,
|
||||
width, height, stride: int32): PSurface{.
|
||||
cdecl, importc: "cairo_image_surface_create_for_data", dynlib: LIB_CAIRO.}
|
||||
proc image_surface_get_data*(surface: PSurface): cstring{.cdecl,
|
||||
proc get_data*(surface: PSurface): cstring{.cdecl,
|
||||
importc: "cairo_image_surface_get_data", dynlib: LIB_CAIRO.}
|
||||
proc image_surface_get_format*(surface: PSurface): TFormat{.cdecl,
|
||||
proc get_format*(surface: PSurface): TFormat{.cdecl,
|
||||
importc: "cairo_image_surface_get_format", dynlib: LIB_CAIRO.}
|
||||
proc image_surface_get_width*(surface: PSurface): int32{.cdecl,
|
||||
proc get_width*(surface: PSurface): int32{.cdecl,
|
||||
importc: "cairo_image_surface_get_width", dynlib: LIB_CAIRO.}
|
||||
proc image_surface_get_height*(surface: PSurface): int32{.cdecl,
|
||||
proc get_height*(surface: PSurface): int32{.cdecl,
|
||||
importc: "cairo_image_surface_get_height", dynlib: LIB_CAIRO.}
|
||||
proc image_surface_get_stride*(surface: PSurface): int32{.cdecl,
|
||||
proc get_stride*(surface: PSurface): int32{.cdecl,
|
||||
importc: "cairo_image_surface_get_stride", dynlib: LIB_CAIRO.}
|
||||
proc image_surface_create_from_png*(filename: cstring): PSurface{.cdecl,
|
||||
importc: "cairo_image_surface_create_from_png", dynlib: LIB_CAIRO.}
|
||||
proc image_surface_create_from_png_stream*(read_func: TReadFunc,
|
||||
proc image_surface_create_from_png*(read_func: TReadFunc,
|
||||
closure: pointer): PSurface{.cdecl, importc: "cairo_image_surface_create_from_png_stream",
|
||||
dynlib: LIB_CAIRO.}
|
||||
#* Pattern creation functions
|
||||
|
|
@ -567,77 +594,79 @@ proc pattern_create_linear*(x0, y0, x1, y1: float64): PPattern{.cdecl,
|
|||
importc: "cairo_pattern_create_linear", dynlib: LIB_CAIRO.}
|
||||
proc pattern_create_radial*(cx0, cy0, radius0, cx1, cy1, radius1: float64): PPattern{.
|
||||
cdecl, importc: "cairo_pattern_create_radial", dynlib: LIB_CAIRO.}
|
||||
proc pattern_reference*(pattern: PPattern): PPattern{.cdecl,
|
||||
proc reference*(pattern: PPattern): PPattern{.cdecl,
|
||||
importc: "cairo_pattern_reference", dynlib: LIB_CAIRO.}
|
||||
proc pattern_destroy*(pattern: PPattern){.cdecl,
|
||||
proc destroy*(pattern: PPattern){.cdecl,
|
||||
importc: "cairo_pattern_destroy", dynlib: LIB_CAIRO.}
|
||||
proc pattern_get_reference_count*(pattern: PPattern): int32{.cdecl,
|
||||
proc get_reference_count*(pattern: PPattern): int32{.cdecl,
|
||||
importc: "cairo_pattern_get_reference_count", dynlib: LIB_CAIRO.}
|
||||
proc pattern_status*(pattern: PPattern): TStatus{.cdecl,
|
||||
proc status*(pattern: PPattern): TStatus{.cdecl,
|
||||
importc: "cairo_pattern_status", dynlib: LIB_CAIRO.}
|
||||
proc pattern_get_user_data*(pattern: PPattern, key: PUserDataKey): Pointer{.
|
||||
proc get_user_data*(pattern: PPattern, key: PUserDataKey): Pointer{.
|
||||
cdecl, importc: "cairo_pattern_get_user_data", dynlib: LIB_CAIRO.}
|
||||
proc pattern_set_user_data*(pattern: PPattern, key: PUserDataKey,
|
||||
user_data: Pointer, destroy: TDestroyFunc): TStatus{.
|
||||
proc set_user_data*(pattern: PPattern, key: PUserDataKey,
|
||||
user_data: Pointer, destroy: TDestroyFunc): TStatus{.
|
||||
cdecl, importc: "cairo_pattern_set_user_data", dynlib: LIB_CAIRO.}
|
||||
proc pattern_get_type*(pattern: PPattern): TPatternType{.cdecl,
|
||||
proc get_type*(pattern: PPattern): TPatternType{.cdecl,
|
||||
importc: "cairo_pattern_get_type", dynlib: LIB_CAIRO.}
|
||||
proc pattern_add_color_stop_rgb*(pattern: PPattern,
|
||||
proc add_color_stop_rgb*(pattern: PPattern,
|
||||
offset, red, green, blue: float64){.cdecl,
|
||||
importc: "cairo_pattern_add_color_stop_rgb", dynlib: LIB_CAIRO.}
|
||||
proc pattern_add_color_stop_rgba*(pattern: PPattern,
|
||||
proc add_color_stop_rgba*(pattern: PPattern,
|
||||
offset, red, green, blue, alpha: float64){.
|
||||
cdecl, importc: "cairo_pattern_add_color_stop_rgba", dynlib: LIB_CAIRO.}
|
||||
proc pattern_set_matrix*(pattern: PPattern, matrix: PMatrix){.cdecl,
|
||||
proc set_matrix*(pattern: PPattern, matrix: PMatrix){.cdecl,
|
||||
importc: "cairo_pattern_set_matrix", dynlib: LIB_CAIRO.}
|
||||
proc pattern_get_matrix*(pattern: PPattern, matrix: PMatrix){.cdecl,
|
||||
proc get_matrix*(pattern: PPattern, matrix: PMatrix){.cdecl,
|
||||
importc: "cairo_pattern_get_matrix", dynlib: LIB_CAIRO.}
|
||||
proc pattern_set_extend*(pattern: PPattern, extend: TExtend){.cdecl,
|
||||
proc set_extend*(pattern: PPattern, extend: TExtend){.cdecl,
|
||||
importc: "cairo_pattern_set_extend", dynlib: LIB_CAIRO.}
|
||||
proc pattern_get_extend*(pattern: PPattern): TExtend{.cdecl,
|
||||
proc get_extend*(pattern: PPattern): TExtend{.cdecl,
|
||||
importc: "cairo_pattern_get_extend", dynlib: LIB_CAIRO.}
|
||||
proc pattern_set_filter*(pattern: PPattern, filter: TFilter){.cdecl,
|
||||
proc set_filter*(pattern: PPattern, filter: TFilter){.cdecl,
|
||||
importc: "cairo_pattern_set_filter", dynlib: LIB_CAIRO.}
|
||||
proc pattern_get_filter*(pattern: PPattern): TFilter{.cdecl,
|
||||
proc get_filter*(pattern: PPattern): TFilter{.cdecl,
|
||||
importc: "cairo_pattern_get_filter", dynlib: LIB_CAIRO.}
|
||||
proc pattern_get_rgba*(pattern: PPattern, red, green, blue, alpha: var float64): TStatus{.
|
||||
proc get_rgba*(pattern: PPattern,
|
||||
red, green, blue, alpha: var float64): TStatus{.
|
||||
cdecl, importc: "cairo_pattern_get_rgba", dynlib: LIB_CAIRO.}
|
||||
proc pattern_get_surface*(pattern: PPattern, surface: PPCairoSurface): TStatus{.
|
||||
proc get_surface*(pattern: PPattern, surface: PPSurface): TStatus{.
|
||||
cdecl, importc: "cairo_pattern_get_surface", dynlib: LIB_CAIRO.}
|
||||
proc pattern_get_color_stop_rgba*(pattern: PPattern, index: int32,
|
||||
offset, red, green, blue, alpha: var float64): TStatus{.
|
||||
proc get_color_stop_rgba*(pattern: PPattern, index: int32,
|
||||
offset, red, green, blue, alpha: var float64): TStatus{.
|
||||
cdecl, importc: "cairo_pattern_get_color_stop_rgba", dynlib: LIB_CAIRO.}
|
||||
proc pattern_get_color_stop_count*(pattern: PPattern, count: var int32): TStatus{.
|
||||
proc get_color_stop_count*(pattern: PPattern, count: var int32): TStatus{.
|
||||
cdecl, importc: "cairo_pattern_get_color_stop_count", dynlib: LIB_CAIRO.}
|
||||
proc pattern_get_linear_points*(pattern: PPattern, x0, y0, x1, y1: var float64): TStatus{.
|
||||
proc get_linear_points*(pattern: PPattern,
|
||||
x0, y0, x1, y1: var float64): TStatus{.
|
||||
cdecl, importc: "cairo_pattern_get_linear_points", dynlib: LIB_CAIRO.}
|
||||
proc pattern_get_radial_circles*(pattern: PPattern,
|
||||
x0, y0, r0, x1, y1, r1: var float64): TStatus{.
|
||||
proc get_radial_circles*(pattern: PPattern,
|
||||
x0, y0, r0, x1, y1, r1: var float64): TStatus{.
|
||||
cdecl, importc: "cairo_pattern_get_radial_circles", dynlib: LIB_CAIRO.}
|
||||
#* Matrix functions
|
||||
proc matrix_init*(matrix: PMatrix, xx, yx, xy, yy, x0, y0: float64){.cdecl,
|
||||
proc init*(matrix: PMatrix, xx, yx, xy, yy, x0, y0: float64){.cdecl,
|
||||
importc: "cairo_matrix_init", dynlib: LIB_CAIRO.}
|
||||
proc matrix_init_identity*(matrix: PMatrix){.cdecl,
|
||||
proc init_identity*(matrix: PMatrix){.cdecl,
|
||||
importc: "cairo_matrix_init_identity", dynlib: LIB_CAIRO.}
|
||||
proc matrix_init_translate*(matrix: PMatrix, tx, ty: float64){.cdecl,
|
||||
proc init_translate*(matrix: PMatrix, tx, ty: float64){.cdecl,
|
||||
importc: "cairo_matrix_init_translate", dynlib: LIB_CAIRO.}
|
||||
proc matrix_init_scale*(matrix: PMatrix, sx, sy: float64){.cdecl,
|
||||
proc init_scale*(matrix: PMatrix, sx, sy: float64){.cdecl,
|
||||
importc: "cairo_matrix_init_scale", dynlib: LIB_CAIRO.}
|
||||
proc matrix_init_rotate*(matrix: PMatrix, radians: float64){.cdecl,
|
||||
proc init_rotate*(matrix: PMatrix, radians: float64){.cdecl,
|
||||
importc: "cairo_matrix_init_rotate", dynlib: LIB_CAIRO.}
|
||||
proc matrix_translate*(matrix: PMatrix, tx, ty: float64){.cdecl,
|
||||
proc translate*(matrix: PMatrix, tx, ty: float64){.cdecl,
|
||||
importc: "cairo_matrix_translate", dynlib: LIB_CAIRO.}
|
||||
proc matrix_scale*(matrix: PMatrix, sx, sy: float64){.cdecl,
|
||||
proc scale*(matrix: PMatrix, sx, sy: float64){.cdecl,
|
||||
importc: "cairo_matrix_scale", dynlib: LIB_CAIRO.}
|
||||
proc matrix_rotate*(matrix: PMatrix, radians: float64){.cdecl,
|
||||
proc rotate*(matrix: PMatrix, radians: float64){.cdecl,
|
||||
importc: "cairo_matrix_rotate", dynlib: LIB_CAIRO.}
|
||||
proc matrix_invert*(matrix: PMatrix): TStatus{.cdecl,
|
||||
proc invert*(matrix: PMatrix): TStatus{.cdecl,
|
||||
importc: "cairo_matrix_invert", dynlib: LIB_CAIRO.}
|
||||
proc matrix_multiply*(result, a, b: PMatrix){.cdecl,
|
||||
proc multiply*(result, a, b: PMatrix){.cdecl,
|
||||
importc: "cairo_matrix_multiply", dynlib: LIB_CAIRO.}
|
||||
proc matrix_transform_distance*(matrix: PMatrix, dx, dy: var float64){.cdecl,
|
||||
proc transform_distance*(matrix: PMatrix, dx, dy: var float64){.cdecl,
|
||||
importc: "cairo_matrix_transform_distance", dynlib: LIB_CAIRO.}
|
||||
proc matrix_transform_point*(matrix: PMatrix, x, y: var float64){.cdecl,
|
||||
proc transform_point*(matrix: PMatrix, x, y: var float64){.cdecl,
|
||||
importc: "cairo_matrix_transform_point", dynlib: LIB_CAIRO.}
|
||||
#* PDF functions
|
||||
proc pdf_surface_create*(filename: cstring,
|
||||
|
|
@ -691,3 +720,18 @@ proc version(major, minor, micro: var int32) =
|
|||
major = version div 10000'i32
|
||||
minor = (version mod (major * 10000'i32)) div 100'i32
|
||||
micro = (version mod ((major * 10000'i32) + (minor * 100'i32)))
|
||||
|
||||
proc checkStatus*(s: cairo.TStatus) {.noinline.} =
|
||||
## if ``s != StatusSuccess`` the error is turned into an appropirate Nimrod
|
||||
## exception and raised.
|
||||
case s
|
||||
of StatusSuccess: nil
|
||||
of StatusNoMemory:
|
||||
raise newException(EOutOfMemory, $statusToString(s)))
|
||||
of STATUS_READ_ERROR, STATUS_WRITE_ERROR, STATUS_FILE_NOT_FOUND,
|
||||
STATUS_TEMP_FILE_ERROR:
|
||||
raise newException(EIO, $statusToString(s))
|
||||
else:
|
||||
raise newException(EAssertion, $statusToString(s))
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
#
|
||||
#
|
||||
# Nimrod's Runtime Library
|
||||
# (c) Copyright 2010 Andreas Rumpf
|
||||
#
|
||||
|
|
@ -10,19 +9,7 @@
|
|||
## This module implements graphical output for Nimrod; the current
|
||||
## implementation uses Cairo under the surface.
|
||||
|
||||
import cairo
|
||||
|
||||
type
|
||||
PSurface* = ref TSurface
|
||||
TSurface {.pure, final.} = object
|
||||
c: cairo.PSurface
|
||||
|
||||
... # internal data
|
||||
|
||||
|
||||
TRect* = tuple[x, y, width, height: int]
|
||||
TPoint* = tuple[x, y: int]
|
||||
|
||||
TColor* = distinct int ## a color stored as RGB
|
||||
|
||||
proc `==` *(a, b: TColor): bool {.borrow.}
|
||||
|
|
@ -72,14 +59,14 @@ template mix*(a, b: TColor, fn: expr): expr =
|
|||
template `><` (x: expr): expr =
|
||||
# keep it in the range 0..255
|
||||
block:
|
||||
var xx = x # eval only once
|
||||
if xx >% 255:
|
||||
xx = if xx < 0: 0 else: 255
|
||||
xx
|
||||
var y = x # eval only once
|
||||
if y >% 255:
|
||||
y = if y < 0: 0 else: 255
|
||||
y
|
||||
|
||||
extract(a, ar, ag, ab)
|
||||
extract(b, br, bg, bb)
|
||||
rawRGB(><fn(ar, br), ><fn(ag, bg), ><fn(ab, bb))
|
||||
bind extract(a, ar, ag, ab)
|
||||
bind extract(b, br, bg, bb)
|
||||
bind rawRGB(><fn(ar, br), ><fn(ag, bg), ><fn(ab, bb))
|
||||
|
||||
|
||||
const
|
||||
|
|
@ -369,44 +356,40 @@ const
|
|||
proc `$`*(c: TColor): string =
|
||||
## converts a color into its textual representation. Example: ``#00FF00``.
|
||||
result = '#' & toHex(int(c), 6)
|
||||
|
||||
proc newSurface*(width, height: int): PSurface
|
||||
|
||||
proc binaryStrSearch(x: openarray[tuple[name: string, col: TColor]],
|
||||
y: string): int =
|
||||
var a = 0
|
||||
var b = len(x) - 1
|
||||
while a <= b:
|
||||
var mid = (a + b) div 2
|
||||
var c = cmp(x[mid].name, y)
|
||||
if c < 0: a = mid + 1
|
||||
elif c > 0: b = mid - 1
|
||||
else: return mid
|
||||
result = - 1
|
||||
|
||||
proc parseColor*(name: string): TColor =
|
||||
## parses `s` to a color value. If no valid color could be
|
||||
## parses `name` to a color value. If no valid color could be
|
||||
## parsed ``EInvalidValue`` is raised.
|
||||
if name[0] == '#'
|
||||
if name[0] == '#':
|
||||
result = TColor(parseHex(name))
|
||||
else:
|
||||
var idx = binaryStrSearch(colorNames, name)
|
||||
if idx < 0: raise newException(EInvalidValue, "unkown color: " & name)
|
||||
result = colorNames[idx][1]
|
||||
|
||||
|
||||
proc isColor*(name: string): bool
|
||||
proc isColor*(name: string): bool =
|
||||
## returns true if `name` is a known color name or a hexadecimal color
|
||||
## prefixed with ``#``.
|
||||
if name[0] == '#':
|
||||
for i in 1 .. name.len-1:
|
||||
if name[i] notin {'0'..'9', 'a'..'f', 'A'..'F'}: return false
|
||||
result = true
|
||||
else:
|
||||
result = binaryStrSearch(colorNames, name) >= 0
|
||||
|
||||
proc rgb*(r, g, b: range[0..255]): TColor =
|
||||
## constructs a color from RGB values.
|
||||
result = rawRGB(r, g, b)
|
||||
|
||||
proc drawRect*(sur: PSurface, r: TRect, col: TColor)
|
||||
proc fillRect*(sur: PSurface, r: TRect, col: TColor)
|
||||
|
||||
proc drawCircle*(sur: PSurface, mid: TPoint, radius: int)
|
||||
proc drawCircle*(sur: PSurface, r: TRect)
|
||||
|
||||
proc fillCircle*(sur: PSurface, mid: TPoint, radius: int)
|
||||
proc fillCircle*(sur: PSurface, r: TRect)
|
||||
|
||||
proc drawElipse*(sur: PSurface, r: TRect)
|
||||
proc fillElipse*(sur: PSurface, r: TRect)
|
||||
|
||||
|
||||
proc textBounds*(text: string): tuple[len, height: int]
|
||||
proc drawText*(sur: PSurface, p: TPoint, text: string)
|
||||
|
||||
proc drawLine*(sur: PSurface, a, b: TPoint)
|
||||
|
||||
proc `[]`*(sur: PSurface, p: TPoint): TColor
|
||||
proc `[,]`*(sur: PSurface, x, y: int): TColor
|
||||
proc `[]=`*(sur: PSurface, p: TPoint, col: TColor)
|
||||
proc `[,]=`*(sur: PSurface, x, y: int, col: TColor)
|
||||
|
||||
proc writeToPNG*(sur: PSurface, filename: string)
|
||||
|
||||
|
||||
|
|
@ -189,6 +189,9 @@ proc GetCommandLineA*(): CString {.importc, stdcall, dynlib: "kernel32".}
|
|||
proc rdFileTime*(f: FILETIME): int64 =
|
||||
result = ze64(f.dwLowDateTime) or (ze64(f.dwHighDateTime) shl 32)
|
||||
|
||||
proc rdFileSize*(f: TWin32FindData): int64 =
|
||||
result = ze64(f.nFileSizeLow) or (ze64(f.nFileSizeHigh) shl 32)
|
||||
|
||||
proc Sleep*(dwMilliseconds: int32){.stdcall, dynlib: "kernel32",
|
||||
importc: "Sleep".}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import glib2, gtk2, gdk2, osproc, dialogs
|
||||
import glib2, gtk2, gdk2, osproc, dialogs, strutils
|
||||
|
||||
type
|
||||
output = tuple[compiler, app: string]
|
||||
|
|
@ -55,17 +55,19 @@ proc FileSaveClicked(menuitem: PGtkMenuItem, userdata: pgpointer) =
|
|||
|
||||
|
||||
proc inputKeyPressed(widget: PGtkWidget, event: PGdkEventKey, userdata: pgpointer): bool =
|
||||
if event.keyval == 65505:
|
||||
if ($gdk_keyval_name(event.keyval)).tolower() == "shift_l":
|
||||
# SHIFT is pressed
|
||||
shiftPressed = True
|
||||
|
||||
return False
|
||||
proc inputKeyReleased(widget: PGtkWidget, event: PGdkEventKey, userdata: pgpointer): bool =
|
||||
if event.keyval == 65505:
|
||||
echo(gdk_keyval_name(event.keyval))
|
||||
if ($gdk_keyval_name(event.keyval)).tolower() == "shift_l":
|
||||
# SHIFT is released
|
||||
shiftPressed = False
|
||||
|
||||
if event.keyval == 65293:
|
||||
if ($gdk_keyval_name(event.keyval)).tolower() == "return":
|
||||
echo($gdk_keyval_name(event.keyval), "Shift_L")
|
||||
# Enter pressed
|
||||
if shiftPressed == False:
|
||||
var startIter: TGtkTextIter
|
||||
|
|
@ -157,4 +159,4 @@ proc initControls() =
|
|||
|
||||
gtk_nimrod_init()
|
||||
initControls()
|
||||
gtk_main()
|
||||
gtk_main()
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ Bugfixes
|
|||
zeros.
|
||||
- Fixed a bug in ``os.setFilePermissions`` for Windows.
|
||||
- An overloadable symbol can now have the same name as an imported module.
|
||||
- Fixed a serious bug in ``strutils.cmpIgnoreCase``.
|
||||
|
||||
|
||||
Additions
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue