context miterLimit
This commit is contained in:
parent
2edcfac64f
commit
58ccbf025a
3 changed files with 18 additions and 7 deletions
|
@ -11,6 +11,7 @@ type
|
|||
image*: Image
|
||||
fillStyle*, strokeStyle*: Paint
|
||||
lineWidth*: float32
|
||||
miterLimit*: float32
|
||||
lineCap*: LineCap
|
||||
lineJoin*: LineJoin
|
||||
font*: Font
|
||||
|
@ -24,6 +25,7 @@ type
|
|||
ContextState = object
|
||||
fillStyle, strokeStyle: Paint
|
||||
lineWidth: float32
|
||||
miterLimit: float32
|
||||
lineCap: LineCap
|
||||
lineJoin: LineJoin
|
||||
font: Font
|
||||
|
@ -41,6 +43,7 @@ proc newContext*(image: Image): Context =
|
|||
result.image = image
|
||||
result.mat = mat3()
|
||||
result.lineWidth = 1
|
||||
result.miterLimit = 10
|
||||
result.fillStyle = Paint(kind: pkSolid, color: rgbx(0, 0, 0, 255))
|
||||
result.strokeStyle = Paint(kind: pkSolid, color: rgbx(0, 0, 0, 255))
|
||||
|
||||
|
@ -52,6 +55,7 @@ proc state(ctx: Context): ContextState =
|
|||
result.fillStyle = ctx.fillStyle
|
||||
result.strokeStyle = ctx.strokeStyle
|
||||
result.lineWidth = ctx.lineWidth
|
||||
result.miterLimit = ctx.miterLimit
|
||||
result.lineCap = ctx.lineCap
|
||||
result.lineJoin = ctx.lineJoin
|
||||
result.font = ctx.font
|
||||
|
@ -85,6 +89,7 @@ proc restore*(ctx: Context) =
|
|||
ctx.fillStyle = state.fillStyle
|
||||
ctx.strokeStyle = state.strokeStyle
|
||||
ctx.lineWidth = state.lineWidth
|
||||
ctx.miterLimit = state.miterLimit
|
||||
ctx.lineCap = state.lineCap
|
||||
ctx.lineJoin = state.lineJoin
|
||||
ctx.font = state.font
|
||||
|
@ -118,7 +123,8 @@ proc stroke(ctx: Context, image: Image, path: Path) {.inline.} =
|
|||
ctx.mat,
|
||||
ctx.lineWidth,
|
||||
ctx.lineCap,
|
||||
ctx.lineJoin
|
||||
ctx.lineJoin,
|
||||
ctx.miterLimit
|
||||
)
|
||||
|
||||
proc fillText(ctx: Context, image: Image, text: string, at: Vec2) {.inline.} =
|
||||
|
@ -155,7 +161,8 @@ proc strokeText(ctx: Context, image: Image, text: string, at: Vec2) {.inline.} =
|
|||
ctx.lineWidth,
|
||||
hAlign = ctx.textAlign,
|
||||
lineCap = ctx.lineCap,
|
||||
lineJoin = ctx.lineJoin
|
||||
lineJoin = ctx.lineJoin,
|
||||
miterLimit = ctx.miterLimit
|
||||
)
|
||||
|
||||
proc beginPath*(ctx: Context) {.inline.} =
|
||||
|
|
|
@ -442,7 +442,8 @@ proc strokeText*(
|
|||
transform: Vec2 | Mat3 = vec2(0, 0),
|
||||
strokeWidth = 1.0,
|
||||
lineCap = lcButt,
|
||||
lineJoin = ljMiter
|
||||
lineJoin = ljMiter,
|
||||
miterLimit = defaultMiterLimit
|
||||
) =
|
||||
## Strokes the text arrangement.
|
||||
for spanIndex, (start, stop) in arrangement.spans:
|
||||
|
@ -470,7 +471,8 @@ proc strokeText*(
|
|||
hAlign = haLeft,
|
||||
vAlign = vaTop,
|
||||
lineCap = lcButt,
|
||||
lineJoin = ljMiter
|
||||
lineJoin = ljMiter,
|
||||
miterLimit = defaultMiterLimit
|
||||
) {.inline.} =
|
||||
## Typesets and strokes the text. Optional parameters:
|
||||
## transform: translation or matrix to apply
|
||||
|
|
|
@ -36,7 +36,9 @@ type
|
|||
|
||||
SomePath* = Path | string | seq[seq[Vec2]]
|
||||
|
||||
const epsilon = 0.0001 * PI ## Tiny value used for some computations.
|
||||
const
|
||||
epsilon = 0.0001 * PI ## Tiny value used for some computations.
|
||||
defaultMiterLimit*: float32 = 4
|
||||
|
||||
when defined(release):
|
||||
{.push checks: off.}
|
||||
|
@ -1546,7 +1548,7 @@ proc strokePath*(
|
|||
strokeWidth = 1.0,
|
||||
lineCap = lcButt,
|
||||
lineJoin = ljMiter,
|
||||
miterLimit: float32 = 4,
|
||||
miterLimit = defaultMiterLimit,
|
||||
dashes: seq[float32] = @[],
|
||||
) =
|
||||
## Strokes a path.
|
||||
|
@ -1569,7 +1571,7 @@ proc strokePath*(
|
|||
strokeWidth = 1.0,
|
||||
lineCap = lcButt,
|
||||
lineJoin = ljMiter,
|
||||
miterLimit: float32 = 4,
|
||||
miterLimit = defaultMiterLimit,
|
||||
dashes: seq[float32] = @[]
|
||||
) =
|
||||
## Strokes a path.
|
||||
|
|
Loading…
Reference in a new issue