pixie/bindings/bindings.nim

329 lines
7.9 KiB
Nim
Raw Normal View History

2021-12-13 21:22:49 +00:00
import genny, pixie, pixie/internal, unicode
2021-08-24 01:21:10 +00:00
2021-10-11 05:47:49 +00:00
var lastError: ref PixieError
2021-08-24 01:21:10 +00:00
2021-10-11 05:47:49 +00:00
proc takeError(): string =
2021-08-24 01:21:10 +00:00
result = lastError.msg
lastError = nil
2021-10-11 05:47:49 +00:00
proc checkError(): bool =
2021-08-24 01:21:10 +00:00
result = lastError != nil
2021-08-27 03:18:39 +00:00
type
Vector2* = object
x*, y*: float32
Matrix3* = object
2021-09-07 23:46:55 +00:00
values*: array[9, float32]
2021-08-27 03:18:39 +00:00
2021-10-11 05:47:49 +00:00
proc matrix3(): Matrix3 =
2021-09-08 00:14:00 +00:00
cast[Matrix3](mat3())
2021-09-07 23:46:55 +00:00
2021-10-11 05:47:49 +00:00
proc mul(a, b: Matrix3): Matrix3 =
2021-09-07 23:46:55 +00:00
cast[Matrix3](cast[Mat3](a) * cast[Mat3](b))
2021-10-11 05:47:49 +00:00
proc translate(x, y: float32): Matrix3 =
2021-09-07 23:58:47 +00:00
cast[Matrix3](translate(vec2(x, y)))
2021-09-07 23:46:55 +00:00
2021-10-11 05:47:49 +00:00
proc rotate(angle: float32): Matrix3 =
2021-09-07 23:58:47 +00:00
cast[Matrix3](rotate(angle))
2021-09-07 23:46:55 +00:00
2021-10-11 05:47:49 +00:00
proc scale(x, y: float32): Matrix3 =
2021-09-07 23:58:47 +00:00
cast[Matrix3](scale(vec2(x, y)))
2021-09-07 23:46:55 +00:00
2021-10-11 05:47:49 +00:00
proc inverse(m: Matrix3): Matrix3 =
2021-09-08 01:35:16 +00:00
cast[Matrix3](inverse(cast[Mat3](m)))
2021-10-11 05:47:49 +00:00
proc parseColor(s: string): Color {.raises: [PixieError]} =
2021-09-07 23:46:55 +00:00
try:
result = parseHtmlColor(s)
except:
2021-12-04 01:29:58 +00:00
raise currentExceptionAsPixieError()
2021-08-24 01:21:10 +00:00
2021-10-11 05:47:49 +00:00
proc drawImage2(
2021-08-24 01:21:10 +00:00
ctx: Context, image: Image, dx, dy, dWidth, dHeight: float32
) {.raises: [PixieError].} =
ctx.drawImage(image, dx, dy, dWidth, dHeight)
2021-10-11 05:47:49 +00:00
proc drawImage3(
2021-08-24 01:21:10 +00:00
ctx: Context,
image: Image,
sx, sy, sWidth, sHeight,
dx, dy, dWidth, dHeight: float32
) {.raises: [PixieError].} =
ctx.drawImage(image, sx, sy, sWidth, sHeight, dx, dy, dWidth, dHeight)
2021-08-27 01:32:07 +00:00
exportConsts:
2021-08-31 22:51:44 +00:00
defaultMiterLimit
autoLineHeight
2021-08-27 01:32:07 +00:00
2021-08-24 22:31:35 +00:00
exportEnums:
2021-08-31 22:51:44 +00:00
FileFormat
BlendMode
PaintKind
WindingRule
LineCap
LineJoin
HorizontalAlignment
VerticalAlignment
TextCase
2021-08-24 01:21:10 +00:00
exportProcs:
2021-08-31 22:51:44 +00:00
checkError
takeError
2021-08-24 01:21:10 +00:00
2021-08-27 03:18:39 +00:00
exportObject Vector2:
2021-08-31 16:51:22 +00:00
discard
2021-08-27 03:18:39 +00:00
exportObject Matrix3:
2021-08-31 22:51:44 +00:00
constructor:
matrix3
2021-09-07 23:46:55 +00:00
procs:
mul(Matrix3, Matrix3)
2021-08-27 03:18:39 +00:00
exportObject Rect:
discard
exportObject Color:
discard
exportObject ColorStop:
2021-08-31 16:51:22 +00:00
discard
2021-08-27 03:18:39 +00:00
exportObject TextMetrics:
discard
2021-08-24 01:21:10 +00:00
exportSeq seq[float32]:
discard
exportSeq seq[Span]:
2021-08-31 22:51:44 +00:00
procs:
typeset(seq[Span], Vec2, HorizontalAlignment, VerticalAlignment, bool)
2022-04-25 05:16:20 +00:00
layoutBounds(seq[Span])
2021-08-31 22:51:44 +00:00
exportRefObject Image:
fields:
width
height
constructor:
newImage(int, int)
procs:
writeFile(Image, string)
copy(Image)
getColor
setColor
fill(Image, Color)
flipHorizontal
flipVertical
subImage
minifyBy2(Image, int)
2021-10-04 22:34:19 +00:00
magnifyBy2(Image, int)
2021-08-31 22:51:44 +00:00
applyOpacity(Image, float32)
invert(Image)
blur(Image, float32, Color)
newMask(Image)
resize(Image, int, int)
shadow(Image, Vec2, float32, float32, Color)
superImage
draw(Image, Image, Mat3, BlendMode)
draw(Image, Mask, Mat3, BlendMode)
fillGradient
fillText(Image, Font, string, Mat3, Vec2, HorizontalAlignment, VerticalAlignment)
fillText(Image, Arrangement, Mat3)
strokeText(Image, Font, string, Mat3, float32, Vec2, HorizontalAlignment, VerticalAlignment, LineCap, LineJoin, float32, seq[float32])
strokeText(Image, Arrangement, Mat3, float32, LineCap, LineJoin, float32, seq[float32])
fillPath(Image, Path, Paint, Mat3, WindingRule)
strokePath(Image, Path, Paint, Mat3, float32, LineCap, LineJoin, float32, seq[float32])
newContext(Image)
exportRefObject Mask:
fields:
width
height
constructor:
newMask(int, int)
procs:
writeFile(Mask, string)
copy(Mask)
getValue
setValue
fill(Mask, uint8)
minifyBy2(Mask, int)
2021-10-04 22:34:19 +00:00
magnifyBy2(Mask, int)
2021-08-31 22:51:44 +00:00
spread
ceil(Mask)
newImage(Mask)
applyOpacity(Mask, float32)
invert(Mask)
blur(Mask, float32, uint8)
2022-06-08 04:50:04 +00:00
resize(Mask, int, int)
2021-08-31 22:51:44 +00:00
draw(Mask, Mask, Mat3, BlendMode)
draw(Mask, Image, Mat3, BlendMode)
fillText(Mask, Font, string, Mat3, Vec2, HorizontalAlignment, VerticalAlignment)
fillText(Mask, Arrangement, Mat3)
strokeText(Mask, Font, string, Mat3, float32, Vec2, HorizontalAlignment, VerticalAlignment, LineCap, LineJoin, float32, seq[float32])
strokeText(Mask, Arrangement, Mat3, float32, LineCap, LineJoin, float32, seq[float32])
fillPath(Mask, Path, Mat3, WindingRule)
strokePath(Mask, Path, Mat3, float32, LineCap, LineJoin, float32, seq[float32])
exportRefObject Paint:
fields:
kind
blendMode
opacity
color
image
imageMat
gradientHandlePositions
gradientStops
constructor:
newPaint(PaintKind)
procs:
newPaint(Paint)
exportRefObject Path:
constructor:
newPath
procs:
transform(Path, Mat3)
addPath(Path, Path)
closePath(Path)
computeBounds(Path)
fillOverlaps
strokeOverlaps
moveTo(Path, float32, float32)
lineTo(Path, float32, float32)
bezierCurveTo(Path, float32, float32, float32, float32, float32, float32)
quadraticCurveTo(Path, float32, float32, float32, float32)
ellipticalArcTo(Path, float32, float32, float32, bool, bool, float32, float32)
arc(Path, float32, float32, float32, float32, float32, bool)
arcTo(Path, float32, float32, float32, float32, float32)
rect(Path, float32, float32, float32, float32)
roundedRect(Path, float32, float32, float32, float32, float32, float32, float32, float32, bool)
ellipse(Path, float32, float32, float32, float32)
circle(Path, float32, float32, float32)
polygon(Path, float32, float32, float32, int)
exportRefObject Typeface:
fields:
filePath
procs:
ascent
descent
lineGap
lineHeight
2021-09-07 19:53:09 +00:00
hasGlyph
2021-08-31 22:51:44 +00:00
getGlyphPath
getAdvance
getKerningAdjustment
newFont
exportRefObject Font:
fields:
typeface
size
lineHeight
paints
2021-10-13 03:42:08 +00:00
paint
2021-08-31 22:51:44 +00:00
textCase
underline
strikethrough
noKerningAdjustments
procs:
scale(Font)
defaultLineHeight
typeset(Font, string, Vec2, HorizontalAlignment, VerticalAlignment, bool)
2022-04-25 05:16:20 +00:00
layoutBounds(Font, string)
2021-08-31 22:51:44 +00:00
exportRefObject Span:
fields:
text
font
constructor:
newSpan
exportRefObject Arrangement:
procs:
2022-04-25 05:16:20 +00:00
layoutBounds(Arrangement)
computeBounds(Arrangement, Mat3)
2021-08-31 22:51:44 +00:00
exportRefObject Context:
fields:
image
fillStyle
strokeStyle
globalAlpha
lineWidth
miterLimit
lineCap
lineJoin
font
fontSize
textAlign
constructor:
newContext(int, int)
procs:
save
saveLayer
restore
beginPath
closePath(Context)
fill(Context, WindingRule)
fill(Context, Path, WindingRule)
clip(Context, WindingRule)
clip(Context, Path, WindingRule)
stroke(Context)
stroke(Context, Path)
measureText
getTransform
setTransform
transform(Context, Mat3)
resetTransform
2022-02-05 23:03:06 +00:00
getLineDash
setLineDash
2021-09-07 23:46:55 +00:00
drawImage(Context, Image, float32, float32)
2021-08-31 22:51:44 +00:00
drawImage2
drawImage3
moveTo(Context, float32, float32)
lineTo(Context, float32, float32)
bezierCurveTo(Context, float32, float32, float32, float32, float32, float32)
quadraticCurveTo(Context, float32, float32, float32, float32)
arc(Context, float32, float32, float32, float32, float32, bool)
arcTo(Context, float32, float32, float32, float32, float32)
rect(Context, float32, float32, float32, float32)
roundedRect(Context, float32, float32, float32, float32, float32, float32, float32, float32)
ellipse(Context, float32, float32, float32, float32)
circle(Context, float32, float32, float32)
polygon(Context, float32, float32, float32, int)
clearRect(Context, float32, float32, float32, float32)
fillRect(Context, float32, float32, float32, float32)
strokeRect(Context, float32, float32, float32, float32)
2021-09-07 23:46:55 +00:00
strokeSegment(Context, float32, float32, float32, float32)
2021-08-31 22:51:44 +00:00
fillText(Context, string, float32, float32)
strokeText(Context, string, float32, float32)
translate(Context, float32, float32)
scale(Context, float32, float32)
rotate(Context, float32)
isPointInPath(Context, float32, float32, WindingRule)
isPointInPath(Context, Path, float32, float32, WindingRule)
isPointInStroke(Context, float32, float32)
isPointInStroke(Context, Path, float32, float32)
2021-08-24 01:21:10 +00:00
exportProcs:
2021-08-31 22:51:44 +00:00
readImage
readmask
readTypeface
readFont
parsePath
miterLimitToAngle
angleToMiterLimit
2021-09-07 23:46:55 +00:00
parseColor
translate(float32, float32)
rotate(float32)
scale(float32, float32)
2021-09-08 01:35:16 +00:00
inverse(Matrix3)
2021-08-24 01:21:10 +00:00
2021-09-30 17:45:58 +00:00
writeFiles("bindings/generated", "Pixie")
2021-08-24 01:21:10 +00:00
2021-08-25 03:19:28 +00:00
include generated/internal