paint on font
This commit is contained in:
parent
207608df04
commit
11fdc30399
6 changed files with 108 additions and 147 deletions
|
@ -327,31 +327,7 @@ proc strokePolygon*(
|
||||||
mask.strokePath(path, strokeWidth)
|
mask.strokePath(path, strokeWidth)
|
||||||
|
|
||||||
proc fillText*(
|
proc fillText*(
|
||||||
image: Image,
|
target: Image | Mask,
|
||||||
font: Font,
|
|
||||||
text: string,
|
|
||||||
color: SomeColor,
|
|
||||||
transform: Vec2 | Mat3 = vec2(0, 0),
|
|
||||||
bounds = vec2(0, 0),
|
|
||||||
hAlign = haLeft,
|
|
||||||
vAlign = vaTop
|
|
||||||
) =
|
|
||||||
## Typesets and fills the text. Optional parameters:
|
|
||||||
## transform: translation or matrix to apply
|
|
||||||
## bounds: width determines wrapping and hAlign, height for vAlign
|
|
||||||
## hAlign: horizontal alignment of the text
|
|
||||||
## vAlign: vertical alignment of the text
|
|
||||||
let arrangement = font.typeset(
|
|
||||||
text,
|
|
||||||
bounds,
|
|
||||||
hAlign,
|
|
||||||
vAlign
|
|
||||||
)
|
|
||||||
for i in 0 ..< arrangement.runes.len:
|
|
||||||
image.fillPath(arrangement.getPath(i), color, transform)
|
|
||||||
|
|
||||||
proc fillText*(
|
|
||||||
mask: Mask,
|
|
||||||
font: Font,
|
font: Font,
|
||||||
text: string,
|
text: string,
|
||||||
transform: Vec2 | Mat3 = vec2(0, 0),
|
transform: Vec2 | Mat3 = vec2(0, 0),
|
||||||
|
@ -364,42 +340,15 @@ proc fillText*(
|
||||||
## bounds: width determines wrapping and hAlign, height for vAlign
|
## bounds: width determines wrapping and hAlign, height for vAlign
|
||||||
## hAlign: horizontal alignment of the text
|
## hAlign: horizontal alignment of the text
|
||||||
## vAlign: vertical alignment of the text
|
## vAlign: vertical alignment of the text
|
||||||
let arrangement = font.typeset(
|
let arrangement = font.typeset(text, bounds, hAlign, vAlign)
|
||||||
text,
|
|
||||||
bounds,
|
|
||||||
hAlign,
|
|
||||||
vAlign
|
|
||||||
)
|
|
||||||
for i in 0 ..< arrangement.runes.len:
|
for i in 0 ..< arrangement.runes.len:
|
||||||
mask.fillPath(arrangement.getPath(i), transform)
|
when type(target) is Image:
|
||||||
|
target.fillPath(arrangement.getPath(i), font.paint, transform)
|
||||||
|
else: # target is Mask
|
||||||
|
target.fillPath(arrangement.getPath(i), transform)
|
||||||
|
|
||||||
proc strokeText*(
|
proc strokeText*(
|
||||||
image: Image,
|
target: Image | Mask,
|
||||||
font: Font,
|
|
||||||
text: string,
|
|
||||||
color: SomeColor,
|
|
||||||
transform: Vec2 | Mat3 = vec2(0, 0),
|
|
||||||
strokeWidth = 1.0,
|
|
||||||
bounds = vec2(0, 0),
|
|
||||||
hAlign = haLeft,
|
|
||||||
vAlign = vaTop
|
|
||||||
) =
|
|
||||||
## Typesets and strokes the text. Optional parameters:
|
|
||||||
## transform: translation or matrix to apply
|
|
||||||
## bounds: width determines wrapping and hAlign, height for vAlign
|
|
||||||
## hAlign: horizontal alignment of the text
|
|
||||||
## vAlign: vertical alignment of the text
|
|
||||||
let arrangement = font.typeset(
|
|
||||||
text,
|
|
||||||
bounds,
|
|
||||||
hAlign,
|
|
||||||
vAlign
|
|
||||||
)
|
|
||||||
for i in 0 ..< arrangement.runes.len:
|
|
||||||
image.strokePath(arrangement.getPath(i), color, transform, strokeWidth)
|
|
||||||
|
|
||||||
proc strokeText*(
|
|
||||||
mask: Mask,
|
|
||||||
font: Font,
|
font: Font,
|
||||||
text: string,
|
text: string,
|
||||||
transform: Vec2 | Mat3 = vec2(0, 0),
|
transform: Vec2 | Mat3 = vec2(0, 0),
|
||||||
|
@ -413,11 +362,11 @@ proc strokeText*(
|
||||||
## bounds: width determines wrapping and hAlign, height for vAlign
|
## bounds: width determines wrapping and hAlign, height for vAlign
|
||||||
## hAlign: horizontal alignment of the text
|
## hAlign: horizontal alignment of the text
|
||||||
## vAlign: vertical alignment of the text
|
## vAlign: vertical alignment of the text
|
||||||
let arrangement = font.typeset(
|
let arrangement = font.typeset(text, bounds, hAlign, vAlign)
|
||||||
text,
|
|
||||||
bounds,
|
|
||||||
hAlign,
|
|
||||||
vAlign
|
|
||||||
)
|
|
||||||
for i in 0 ..< arrangement.runes.len:
|
for i in 0 ..< arrangement.runes.len:
|
||||||
mask.strokePath(arrangement.getPath(i), transform, strokeWidth)
|
when type(target) is Image:
|
||||||
|
target.strokePath(
|
||||||
|
arrangement.getPath(i), font.paint, transform, strokeWidth
|
||||||
|
)
|
||||||
|
else: # target is Mask
|
||||||
|
target.strokePath(arrangement.getPath(i), transform, strokeWidth)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import bumpy, pixie/fontformats/opentype, pixie/fontformats/svgfont,
|
import bumpy, chroma, pixie/fontformats/opentype, pixie/fontformats/svgfont,
|
||||||
pixie/paths, unicode, vmath
|
pixie/paints, pixie/paths, unicode, vmath
|
||||||
|
|
||||||
const
|
const
|
||||||
AutoLineHeight* = -1.float32 ## Use default line height for the font size
|
AutoLineHeight* = -1.float32 ## Use default line height for the font size
|
||||||
|
@ -13,8 +13,9 @@ type
|
||||||
|
|
||||||
Font* = object
|
Font* = object
|
||||||
typeface*: Typeface
|
typeface*: Typeface
|
||||||
size*: float32 ## Font size in pixels.
|
size*: float32 ## Font size in pixels.
|
||||||
lineHeight*: float32 ## The line height in pixels or AutoLineHeight for the font's default line height.
|
lineHeight*: float32 ## The line height in pixels or AutoLineHeight for the font's default line height.
|
||||||
|
paint*: Paint
|
||||||
textCase*: TextCase
|
textCase*: TextCase
|
||||||
noKerningAdjustments*: bool ## Optionally disable kerning pair adjustments
|
noKerningAdjustments*: bool ## Optionally disable kerning pair adjustments
|
||||||
|
|
||||||
|
@ -115,7 +116,7 @@ proc convertTextCase(runes: var seq[Rune], textCase: TextCase) =
|
||||||
rune = rune.toUpper()
|
rune = rune.toUpper()
|
||||||
prevRune = rune
|
prevRune = rune
|
||||||
|
|
||||||
proc canWrap(rune: Rune): bool =
|
proc canWrap(rune: Rune): bool {.inline.} =
|
||||||
rune == Rune(32) or rune.isWhiteSpace()
|
rune == Rune(32) or rune.isWhiteSpace()
|
||||||
|
|
||||||
proc typeset*(
|
proc typeset*(
|
||||||
|
@ -260,28 +261,31 @@ proc typeset*(
|
||||||
result.positions[i].y += yAdjustment
|
result.positions[i].y += yAdjustment
|
||||||
result.selectionRects[i].y += yAdjustment
|
result.selectionRects[i].y += yAdjustment
|
||||||
|
|
||||||
proc getPath*(arrangement: Arrangement, index: int): Path =
|
proc computeBounds*(arrangement: Arrangement): Vec2 =
|
||||||
## Returns the path for index.
|
|
||||||
result = arrangement.font.typeface.getGlyphPath(arrangement.runes[index])
|
|
||||||
result.transform(
|
|
||||||
translate(arrangement.positions[index]) *
|
|
||||||
scale(vec2(arrangement.font.scale))
|
|
||||||
)
|
|
||||||
|
|
||||||
proc computeBounds*(font: Font, text: string): Vec2 =
|
|
||||||
## Computes the width and height of the text in pixels.
|
|
||||||
let arrangement = font.typeset(text)
|
|
||||||
if arrangement.runes.len > 0:
|
if arrangement.runes.len > 0:
|
||||||
for rect in arrangement.selectionRects:
|
for rect in arrangement.selectionRects:
|
||||||
result.x = max(result.x, rect.x + rect.w)
|
result.x = max(result.x, rect.x + rect.w)
|
||||||
let finalRect = arrangement.selectionRects[^1]
|
let finalRect = arrangement.selectionRects[^1]
|
||||||
result.y = finalRect.y + finalRect.h
|
result.y = finalRect.y + finalRect.h
|
||||||
|
|
||||||
|
proc computeBounds*(font: Font, text: string): Vec2 {.inline.} =
|
||||||
|
## Computes the width and height of the text in pixels.
|
||||||
|
font.typeset(text).computeBounds()
|
||||||
|
|
||||||
|
proc getPath*(arrangement: Arrangement, index: int): Path =
|
||||||
|
## Returns the path for the rune index.
|
||||||
|
result = arrangement.font.typeface.getGlyphPath(arrangement.runes[index])
|
||||||
|
result.transform(
|
||||||
|
translate(arrangement.positions[index]) *
|
||||||
|
scale(vec2(arrangement.font.scale))
|
||||||
|
)
|
||||||
|
|
||||||
proc parseOtf*(buf: string): Font =
|
proc parseOtf*(buf: string): Font =
|
||||||
result.typeface = Typeface()
|
result.typeface = Typeface()
|
||||||
result.typeface.opentype = parseOpenType(buf)
|
result.typeface.opentype = parseOpenType(buf)
|
||||||
result.size = 12
|
result.size = 12
|
||||||
result.lineHeight = AutoLineHeight
|
result.lineHeight = AutoLineHeight
|
||||||
|
result.paint = Paint(kind: pkSolid, color: rgbx(0, 0, 0, 255))
|
||||||
|
|
||||||
proc parseTtf*(buf: string): Font =
|
proc parseTtf*(buf: string): Font =
|
||||||
parseOtf(buf)
|
parseOtf(buf)
|
||||||
|
@ -291,3 +295,4 @@ proc parseSvgFont*(buf: string): Font =
|
||||||
result.typeface.svgFont = svgfont.parseSvgFont(buf)
|
result.typeface.svgFont = svgfont.parseSvgFont(buf)
|
||||||
result.size = 12
|
result.size = 12
|
||||||
result.lineHeight = AutoLineHeight
|
result.lineHeight = AutoLineHeight
|
||||||
|
result.paint = Paint(kind: pkSolid, color: rgbx(0, 0, 0, 255))
|
||||||
|
|
|
@ -9,7 +9,7 @@ type
|
||||||
pkGradientRadial
|
pkGradientRadial
|
||||||
pkGradientAngular
|
pkGradientAngular
|
||||||
|
|
||||||
Paint* = ref object
|
Paint* = object
|
||||||
## Paint used to fill paths.
|
## Paint used to fill paths.
|
||||||
case kind*: PaintKind
|
case kind*: PaintKind
|
||||||
of pkSolid:
|
of pkSolid:
|
||||||
|
|
|
@ -1494,18 +1494,19 @@ proc fillPath*(
|
||||||
image: Image,
|
image: Image,
|
||||||
path: SomePath,
|
path: SomePath,
|
||||||
paint: Paint,
|
paint: Paint,
|
||||||
windingRule = wrNonZero,
|
transform: Vec2 | Mat3 = vec2(),
|
||||||
|
windingRule = wrNonZero
|
||||||
) =
|
) =
|
||||||
## Fills a path.
|
## Fills a path.
|
||||||
if paint.kind == pkSolid:
|
if paint.kind == pkSolid:
|
||||||
image.fillPath(path, paint.color)
|
image.fillPath(path, paint.color, transform)
|
||||||
return
|
return
|
||||||
|
|
||||||
let
|
let
|
||||||
mask = newMask(image.width, image.height)
|
mask = newMask(image.width, image.height)
|
||||||
fill = newImage(image.width, image.height)
|
fill = newImage(image.width, image.height)
|
||||||
|
|
||||||
mask.fillPath(parseSomePath(path), windingRule)
|
mask.fillPath(parseSomePath(path), transform, windingRule)
|
||||||
|
|
||||||
case paint.kind:
|
case paint.kind:
|
||||||
of pkSolid:
|
of pkSolid:
|
||||||
|
@ -1606,5 +1607,58 @@ proc strokePath*(
|
||||||
strokeShapes.transform(transform)
|
strokeShapes.transform(transform)
|
||||||
mask.fillShapes(strokeShapes, wrNonZero)
|
mask.fillShapes(strokeShapes, wrNonZero)
|
||||||
|
|
||||||
|
proc strokePath*(
|
||||||
|
image: Image,
|
||||||
|
path: SomePath,
|
||||||
|
paint: Paint,
|
||||||
|
transform: Vec2 | Mat3 = vec2(),
|
||||||
|
strokeWidth = 1.0,
|
||||||
|
lineCap = lcButt,
|
||||||
|
lineJoin = ljMiter
|
||||||
|
) =
|
||||||
|
## Fills a path.
|
||||||
|
if paint.kind == pkSolid:
|
||||||
|
image.strokePath(
|
||||||
|
path, paint.color, transform, strokeWidth, lineCap, lineJoin
|
||||||
|
)
|
||||||
|
return
|
||||||
|
|
||||||
|
let
|
||||||
|
mask = newMask(image.width, image.height)
|
||||||
|
fill = newImage(image.width, image.height)
|
||||||
|
|
||||||
|
mask.strokePath(parseSomePath(path), transform)
|
||||||
|
|
||||||
|
case paint.kind:
|
||||||
|
of pkSolid:
|
||||||
|
discard # Handled above
|
||||||
|
of pkImage:
|
||||||
|
fill.draw(paint.image, paint.imageMat)
|
||||||
|
of pkImageTiled:
|
||||||
|
fill.drawTiled(paint.image, paint.imageMat)
|
||||||
|
of pkGradientLinear:
|
||||||
|
fill.fillLinearGradient(
|
||||||
|
paint.gradientHandlePositions[0],
|
||||||
|
paint.gradientHandlePositions[1],
|
||||||
|
paint.gradientStops
|
||||||
|
)
|
||||||
|
of pkGradientRadial:
|
||||||
|
fill.fillRadialGradient(
|
||||||
|
paint.gradientHandlePositions[0],
|
||||||
|
paint.gradientHandlePositions[1],
|
||||||
|
paint.gradientHandlePositions[2],
|
||||||
|
paint.gradientStops
|
||||||
|
)
|
||||||
|
of pkGradientAngular:
|
||||||
|
fill.fillAngularGradient(
|
||||||
|
paint.gradientHandlePositions[0],
|
||||||
|
paint.gradientHandlePositions[1],
|
||||||
|
paint.gradientHandlePositions[2],
|
||||||
|
paint.gradientStops
|
||||||
|
)
|
||||||
|
|
||||||
|
fill.draw(mask)
|
||||||
|
image.draw(fill, blendMode = paint.blendMode)
|
||||||
|
|
||||||
when defined(release):
|
when defined(release):
|
||||||
{.pop.}
|
{.pop.}
|
||||||
|
|
|
@ -20,7 +20,7 @@ block:
|
||||||
font.size = 64
|
font.size = 64
|
||||||
let image = newImage(200, 100)
|
let image = newImage(200, 100)
|
||||||
image.fill(rgba(255, 255, 255, 255))
|
image.fill(rgba(255, 255, 255, 255))
|
||||||
image.fillText(font, "fill", rgba(0, 0, 0, 255))
|
image.fillText(font, "fill")
|
||||||
image.writeFile("tests/fonts/image_fill.png")
|
image.writeFile("tests/fonts/image_fill.png")
|
||||||
|
|
||||||
block:
|
block:
|
||||||
|
@ -28,7 +28,7 @@ block:
|
||||||
font.size = 64
|
font.size = 64
|
||||||
let image = newImage(200, 100)
|
let image = newImage(200, 100)
|
||||||
image.fill(rgba(255, 255, 255, 255))
|
image.fill(rgba(255, 255, 255, 255))
|
||||||
image.strokeText(font, "stroke", rgba(0, 0, 0, 255))
|
image.strokeText(font, "stroke")
|
||||||
image.writeFile("tests/fonts/image_stroke.png")
|
image.writeFile("tests/fonts/image_stroke.png")
|
||||||
|
|
||||||
block:
|
block:
|
||||||
|
@ -86,7 +86,7 @@ block:
|
||||||
|
|
||||||
let image = newImage(200, 100)
|
let image = newImage(200, 100)
|
||||||
image.fill(rgba(255, 255, 255, 255))
|
image.fill(rgba(255, 255, 255, 255))
|
||||||
image.fillText(font, "asdf", rgba(0, 0, 0, 255))
|
image.fillText(font, "asdf")
|
||||||
|
|
||||||
doDiff(image, "basic1")
|
doDiff(image, "basic1")
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ block:
|
||||||
|
|
||||||
let image = newImage(200, 100)
|
let image = newImage(200, 100)
|
||||||
image.fill(rgba(255, 255, 255, 255))
|
image.fill(rgba(255, 255, 255, 255))
|
||||||
image.fillText(font, "A cow", rgba(0, 0, 0, 255))
|
image.fillText(font, "A cow")
|
||||||
|
|
||||||
doDiff(image, "basic2")
|
doDiff(image, "basic2")
|
||||||
|
|
||||||
|
@ -106,7 +106,7 @@ block:
|
||||||
|
|
||||||
let image = newImage(200, 100)
|
let image = newImage(200, 100)
|
||||||
image.fill(rgba(255, 255, 255, 255))
|
image.fill(rgba(255, 255, 255, 255))
|
||||||
image.fillText(font, "A bit of text HERE", rgba(0, 0, 0, 255))
|
image.fillText(font, "A bit of text HERE")
|
||||||
|
|
||||||
doDiff(image, "basic3")
|
doDiff(image, "basic3")
|
||||||
|
|
||||||
|
@ -117,7 +117,7 @@ block:
|
||||||
|
|
||||||
let image = newImage(200, 100)
|
let image = newImage(200, 100)
|
||||||
image.fill(rgba(255, 255, 255, 255))
|
image.fill(rgba(255, 255, 255, 255))
|
||||||
image.fillText(font, "Line height", rgba(0, 0, 0, 255))
|
image.fillText(font, "Line height")
|
||||||
|
|
||||||
doDiff(image, "basic4")
|
doDiff(image, "basic4")
|
||||||
|
|
||||||
|
@ -127,7 +127,7 @@ block:
|
||||||
|
|
||||||
let image = newImage(200, 100)
|
let image = newImage(200, 100)
|
||||||
image.fill(rgba(255, 255, 255, 255))
|
image.fill(rgba(255, 255, 255, 255))
|
||||||
image.fillText(font, "Another font", rgba(0, 0, 0, 255))
|
image.fillText(font, "Another font")
|
||||||
|
|
||||||
doDiff(image, "basic5")
|
doDiff(image, "basic5")
|
||||||
|
|
||||||
|
@ -137,7 +137,7 @@ block:
|
||||||
|
|
||||||
let image = newImage(200, 100)
|
let image = newImage(200, 100)
|
||||||
image.fill(rgba(255, 255, 255, 255))
|
image.fill(rgba(255, 255, 255, 255))
|
||||||
image.fillText(font, "Different font", rgba(0, 0, 0, 255))
|
image.fillText(font, "Different font")
|
||||||
|
|
||||||
doDiff(image, "basic6")
|
doDiff(image, "basic6")
|
||||||
|
|
||||||
|
@ -147,17 +147,8 @@ block:
|
||||||
|
|
||||||
let image = newImage(200, 100)
|
let image = newImage(200, 100)
|
||||||
image.fill(rgba(255, 255, 255, 255))
|
image.fill(rgba(255, 255, 255, 255))
|
||||||
image.fillText(
|
image.fillText(font, "First line")
|
||||||
font,
|
image.fillText(font, "Second line", vec2(0, font.defaultLineHeight))
|
||||||
"First line",
|
|
||||||
rgba(0, 0, 0, 255)
|
|
||||||
)
|
|
||||||
image.fillText(
|
|
||||||
font,
|
|
||||||
"Second line",
|
|
||||||
rgba(0, 0, 0, 255),
|
|
||||||
vec2(0, font.defaultLineHeight)
|
|
||||||
)
|
|
||||||
|
|
||||||
doDiff(image, "basic7")
|
doDiff(image, "basic7")
|
||||||
|
|
||||||
|
@ -170,7 +161,6 @@ block:
|
||||||
image.fillText(
|
image.fillText(
|
||||||
font,
|
font,
|
||||||
"Wrapping text to new line",
|
"Wrapping text to new line",
|
||||||
rgba(0, 0, 0, 255),
|
|
||||||
bounds = vec2(200, 0)
|
bounds = vec2(200, 0)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -185,7 +175,6 @@ block:
|
||||||
image.fillText(
|
image.fillText(
|
||||||
font,
|
font,
|
||||||
"Supercalifragilisticexpialidocious",
|
"Supercalifragilisticexpialidocious",
|
||||||
rgba(0, 0, 0, 255),
|
|
||||||
bounds = vec2(200, 0)
|
bounds = vec2(200, 0)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -208,7 +197,6 @@ block:
|
||||||
image.fillText(
|
image.fillText(
|
||||||
font,
|
font,
|
||||||
text,
|
text,
|
||||||
rgba(0, 0, 0, 255),
|
|
||||||
bounds = image.wh
|
bounds = image.wh
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -227,7 +215,6 @@ block:
|
||||||
image.fillText(
|
image.fillText(
|
||||||
font,
|
font,
|
||||||
text,
|
text,
|
||||||
rgba(0, 0, 0, 255),
|
|
||||||
bounds = image.wh
|
bounds = image.wh
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -245,7 +232,6 @@ block:
|
||||||
image.fillText(
|
image.fillText(
|
||||||
font,
|
font,
|
||||||
text,
|
text,
|
||||||
rgba(0, 0, 0, 255),
|
|
||||||
bounds = image.wh
|
bounds = image.wh
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -264,7 +250,6 @@ block:
|
||||||
image.fillText(
|
image.fillText(
|
||||||
font,
|
font,
|
||||||
text,
|
text,
|
||||||
rgba(0, 0, 0, 255),
|
|
||||||
bounds = image.wh
|
bounds = image.wh
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -282,7 +267,6 @@ block:
|
||||||
image.fillText(
|
image.fillText(
|
||||||
font,
|
font,
|
||||||
text,
|
text,
|
||||||
rgba(0, 0, 0, 255),
|
|
||||||
bounds = image.wh
|
bounds = image.wh
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -301,7 +285,6 @@ block:
|
||||||
image.fillText(
|
image.fillText(
|
||||||
font,
|
font,
|
||||||
text,
|
text,
|
||||||
rgba(0, 0, 0, 255),
|
|
||||||
bounds = image.wh
|
bounds = image.wh
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -319,7 +302,6 @@ block:
|
||||||
image.fillText(
|
image.fillText(
|
||||||
font,
|
font,
|
||||||
text,
|
text,
|
||||||
rgba(0, 0, 0, 255),
|
|
||||||
bounds = image.wh
|
bounds = image.wh
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -338,7 +320,6 @@ block:
|
||||||
image.fillText(
|
image.fillText(
|
||||||
font,
|
font,
|
||||||
text,
|
text,
|
||||||
rgba(0, 0, 0, 255),
|
|
||||||
bounds = image.wh
|
bounds = image.wh
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -356,7 +337,6 @@ block:
|
||||||
image.fillText(
|
image.fillText(
|
||||||
font,
|
font,
|
||||||
text,
|
text,
|
||||||
rgba(0, 0, 0, 255),
|
|
||||||
bounds = image.wh
|
bounds = image.wh
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -375,7 +355,6 @@ block:
|
||||||
image.fillText(
|
image.fillText(
|
||||||
font,
|
font,
|
||||||
text,
|
text,
|
||||||
rgba(0, 0, 0, 255),
|
|
||||||
bounds = image.wh
|
bounds = image.wh
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -391,7 +370,6 @@ block:
|
||||||
image.fillText(
|
image.fillText(
|
||||||
font,
|
font,
|
||||||
"Shehadcometotheconclusion",
|
"Shehadcometotheconclusion",
|
||||||
rgba(0, 0, 0, 255),
|
|
||||||
bounds = image.wh
|
bounds = image.wh
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -407,7 +385,6 @@ block:
|
||||||
image.fillText(
|
image.fillText(
|
||||||
font,
|
font,
|
||||||
"Shehadcometotheconclusion",
|
"Shehadcometotheconclusion",
|
||||||
rgba(0, 0, 0, 255),
|
|
||||||
bounds = image.wh
|
bounds = image.wh
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -422,7 +399,6 @@ block:
|
||||||
image.fillText(
|
image.fillText(
|
||||||
font,
|
font,
|
||||||
"Shehadcometotheconclusion",
|
"Shehadcometotheconclusion",
|
||||||
rgba(0, 0, 0, 255),
|
|
||||||
bounds = image.wh
|
bounds = image.wh
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -438,7 +414,6 @@ block:
|
||||||
image.fillText(
|
image.fillText(
|
||||||
font,
|
font,
|
||||||
"Shehadcometotheconclusion",
|
"Shehadcometotheconclusion",
|
||||||
rgba(0, 0, 0, 255),
|
|
||||||
bounds = image.wh
|
bounds = image.wh
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -453,7 +428,6 @@ block:
|
||||||
image.fillText(
|
image.fillText(
|
||||||
font,
|
font,
|
||||||
"Wrapping text to the next line",
|
"Wrapping text to the next line",
|
||||||
rgba(0, 0, 0, 255),
|
|
||||||
bounds = image.wh
|
bounds = image.wh
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -469,7 +443,6 @@ block:
|
||||||
image.fillText(
|
image.fillText(
|
||||||
font,
|
font,
|
||||||
"Wrapping text to the next line",
|
"Wrapping text to the next line",
|
||||||
rgba(0, 0, 0, 255),
|
|
||||||
bounds = image.wh
|
bounds = image.wh
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -484,7 +457,6 @@ block:
|
||||||
image.fillText(
|
image.fillText(
|
||||||
font,
|
font,
|
||||||
"HA HT HX HY IA IT IX IY MA MT MX MY NA NT NX NY",
|
"HA HT HX HY IA IT IX IY MA MT MX MY NA NT NX NY",
|
||||||
rgba(0, 0, 0, 255),
|
|
||||||
bounds = image.wh
|
bounds = image.wh
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -499,7 +471,6 @@ block:
|
||||||
image.fillText(
|
image.fillText(
|
||||||
font,
|
font,
|
||||||
"V( V) V- V/ V: v; v? v@ VT VV VW VX VY V] Vu Vz V{",
|
"V( V) V- V/ V: v; v? v@ VT VV VW VX VY V] Vu Vz V{",
|
||||||
rgba(0, 0, 0, 255),
|
|
||||||
bounds = image.wh
|
bounds = image.wh
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -514,7 +485,6 @@ block:
|
||||||
image.fillText(
|
image.fillText(
|
||||||
font,
|
font,
|
||||||
"B, B. BA BJ BT BW BY Bf Bg Bt bw By",
|
"B, B. BA BJ BT BW BY Bf Bg Bt bw By",
|
||||||
rgba(0, 0, 0, 255),
|
|
||||||
bounds = image.wh
|
bounds = image.wh
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -535,7 +505,6 @@ Fourth line
|
||||||
Fifth line
|
Fifth line
|
||||||
Sixth line
|
Sixth line
|
||||||
Seventh line""",
|
Seventh line""",
|
||||||
rgba(0, 0, 0, 255),
|
|
||||||
bounds = image.wh
|
bounds = image.wh
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -555,7 +524,6 @@ Second line
|
||||||
Third line
|
Third line
|
||||||
Fourth line
|
Fourth line
|
||||||
Fifth line""",
|
Fifth line""",
|
||||||
rgba(0, 0, 0, 255),
|
|
||||||
bounds = image.wh
|
bounds = image.wh
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -571,7 +539,6 @@ block:
|
||||||
image.fillText(
|
image.fillText(
|
||||||
font,
|
font,
|
||||||
"TopLeft",
|
"TopLeft",
|
||||||
rgba(0, 0, 0, 255),
|
|
||||||
bounds = image.wh,
|
bounds = image.wh,
|
||||||
hAlign = haLeft,
|
hAlign = haLeft,
|
||||||
vAlign = vaTop
|
vAlign = vaTop
|
||||||
|
@ -580,7 +547,6 @@ block:
|
||||||
image.fillText(
|
image.fillText(
|
||||||
font,
|
font,
|
||||||
"TopCenter",
|
"TopCenter",
|
||||||
rgba(0, 0, 0, 255),
|
|
||||||
bounds = image.wh,
|
bounds = image.wh,
|
||||||
hAlign = haCenter,
|
hAlign = haCenter,
|
||||||
vAlign = vaTop
|
vAlign = vaTop
|
||||||
|
@ -589,7 +555,6 @@ block:
|
||||||
image.fillText(
|
image.fillText(
|
||||||
font,
|
font,
|
||||||
"TopRight",
|
"TopRight",
|
||||||
rgba(0, 0, 0, 255),
|
|
||||||
bounds = image.wh,
|
bounds = image.wh,
|
||||||
hAlign = haRight,
|
hAlign = haRight,
|
||||||
vAlign = vaTop
|
vAlign = vaTop
|
||||||
|
@ -598,7 +563,6 @@ block:
|
||||||
image.fillText(
|
image.fillText(
|
||||||
font,
|
font,
|
||||||
"MiddleLeft",
|
"MiddleLeft",
|
||||||
rgba(0, 0, 0, 255),
|
|
||||||
bounds = image.wh,
|
bounds = image.wh,
|
||||||
hAlign = haLeft,
|
hAlign = haLeft,
|
||||||
vAlign = vaMiddle
|
vAlign = vaMiddle
|
||||||
|
@ -607,7 +571,6 @@ block:
|
||||||
image.fillText(
|
image.fillText(
|
||||||
font,
|
font,
|
||||||
"MiddleCenter",
|
"MiddleCenter",
|
||||||
rgba(0, 0, 0, 255),
|
|
||||||
bounds = image.wh,
|
bounds = image.wh,
|
||||||
hAlign = haCenter,
|
hAlign = haCenter,
|
||||||
vAlign = vaMiddle
|
vAlign = vaMiddle
|
||||||
|
@ -616,7 +579,6 @@ block:
|
||||||
image.fillText(
|
image.fillText(
|
||||||
font,
|
font,
|
||||||
"MiddleRight",
|
"MiddleRight",
|
||||||
rgba(0, 0, 0, 255),
|
|
||||||
bounds = image.wh,
|
bounds = image.wh,
|
||||||
hAlign = haRight,
|
hAlign = haRight,
|
||||||
vAlign = vaMiddle
|
vAlign = vaMiddle
|
||||||
|
@ -625,7 +587,6 @@ block:
|
||||||
image.fillText(
|
image.fillText(
|
||||||
font,
|
font,
|
||||||
"BottomLeft",
|
"BottomLeft",
|
||||||
rgba(0, 0, 0, 255),
|
|
||||||
bounds = image.wh,
|
bounds = image.wh,
|
||||||
hAlign = haLeft,
|
hAlign = haLeft,
|
||||||
vAlign = vaBottom
|
vAlign = vaBottom
|
||||||
|
@ -634,7 +595,6 @@ block:
|
||||||
image.fillText(
|
image.fillText(
|
||||||
font,
|
font,
|
||||||
"BottomCenter",
|
"BottomCenter",
|
||||||
rgba(0, 0, 0, 255),
|
|
||||||
bounds = image.wh,
|
bounds = image.wh,
|
||||||
hAlign = haCenter,
|
hAlign = haCenter,
|
||||||
vAlign = vaBottom
|
vAlign = vaBottom
|
||||||
|
@ -643,7 +603,6 @@ block:
|
||||||
image.fillText(
|
image.fillText(
|
||||||
font,
|
font,
|
||||||
"BottomRight",
|
"BottomRight",
|
||||||
rgba(0, 0, 0, 255),
|
|
||||||
bounds = image.wh,
|
bounds = image.wh,
|
||||||
hAlign = haRight,
|
hAlign = haRight,
|
||||||
vAlign = vaBottom
|
vAlign = vaBottom
|
||||||
|
|
|
@ -9,8 +9,7 @@ const heartShape = """
|
||||||
"""
|
"""
|
||||||
|
|
||||||
block:
|
block:
|
||||||
let
|
let image = newImage(100, 100)
|
||||||
image = newImage(100, 100)
|
|
||||||
image.fillPath(
|
image.fillPath(
|
||||||
heartShape,
|
heartShape,
|
||||||
Paint(
|
Paint(
|
||||||
|
@ -21,8 +20,7 @@ block:
|
||||||
image.writeFile("tests/images/paths/paintSolid.png")
|
image.writeFile("tests/images/paths/paintSolid.png")
|
||||||
|
|
||||||
block:
|
block:
|
||||||
let
|
let image = newImage(100, 100)
|
||||||
image = newImage(100, 100)
|
|
||||||
image.fillPath(
|
image.fillPath(
|
||||||
heartShape,
|
heartShape,
|
||||||
Paint(
|
Paint(
|
||||||
|
@ -34,8 +32,7 @@ block:
|
||||||
image.writeFile("tests/images/paths/paintImage.png")
|
image.writeFile("tests/images/paths/paintImage.png")
|
||||||
|
|
||||||
block:
|
block:
|
||||||
let
|
let image = newImage(100, 100)
|
||||||
image = newImage(100, 100)
|
|
||||||
image.fillPath(
|
image.fillPath(
|
||||||
heartShape,
|
heartShape,
|
||||||
Paint(
|
Paint(
|
||||||
|
@ -47,8 +44,7 @@ block:
|
||||||
image.writeFile("tests/images/paths/paintImageTiled.png")
|
image.writeFile("tests/images/paths/paintImageTiled.png")
|
||||||
|
|
||||||
block:
|
block:
|
||||||
let
|
let image = newImage(100, 100)
|
||||||
image = newImage(100, 100)
|
|
||||||
image.fillPath(
|
image.fillPath(
|
||||||
heartShape,
|
heartShape,
|
||||||
Paint(
|
Paint(
|
||||||
|
@ -66,8 +62,7 @@ block:
|
||||||
image.writeFile("tests/images/paths/gradientLinear.png")
|
image.writeFile("tests/images/paths/gradientLinear.png")
|
||||||
|
|
||||||
block:
|
block:
|
||||||
let
|
let image = newImage(100, 100)
|
||||||
image = newImage(100, 100)
|
|
||||||
image.fillPath(
|
image.fillPath(
|
||||||
heartShape,
|
heartShape,
|
||||||
Paint(
|
Paint(
|
||||||
|
@ -87,8 +82,7 @@ block:
|
||||||
image.writeFile("tests/images/paths/gradientRadial.png")
|
image.writeFile("tests/images/paths/gradientRadial.png")
|
||||||
|
|
||||||
block:
|
block:
|
||||||
let
|
let image = newImage(100, 100)
|
||||||
image = newImage(100, 100)
|
|
||||||
image.fillPath(
|
image.fillPath(
|
||||||
heartShape,
|
heartShape,
|
||||||
Paint(
|
Paint(
|
||||||
|
|
Loading…
Reference in a new issue