本文整理汇总了TypeScript中core/util/canvas.Context2d.quadraticCurveTo方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Context2d.quadraticCurveTo方法的具体用法?TypeScript Context2d.quadraticCurveTo怎么用?TypeScript Context2d.quadraticCurveTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core/util/canvas.Context2d
的用法示例。
在下文中一共展示了Context2d.quadraticCurveTo方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: _render_seq
_render_seq(ctx: Context2d, seq: (Draw | number)[]): void {
let c: Draw = "M"
let p = [0, 0]
let i = 0
while (i < seq.length) {
if (isString(seq[i])) {
c = seq[i] as Draw
i += 1
}
switch (c) {
case "M": {
const [x, y] = seq.slice(i, i+2) as number[]
ctx.moveTo(x, y)
p = [x, y]
i += 2
break
}
case "L": {
const [x, y] = seq.slice(i, i+2) as number[]
ctx.lineTo(x, y)
p = [x, y]
i += 2
break
}
case "C": {
const [cx0, cy0, cx1, cy1, x, y] = seq.slice(i, i+6) as number[]
ctx.bezierCurveTo(cx0, cy0, cx1, cy1, x, y)
p = [x, y]
i += 6
break
}
case "Q": {
const [cx0, cy0, x, y] = seq.slice(i, i+4) as number[]
ctx.quadraticCurveTo(cx0, cy0, x, y)
p = [x, y]
i += 4
break
}
case "A": {
const [rx, ry, x_rotation, large_arc, sweep, x, y] = seq.slice(i, i+7) as number[]
const [px, py] = p
const segments = arc_to_bezier(px, py, rx, ry, -x_rotation, large_arc, 1 - sweep, x, y)
for (const [cx0, cy0, cx1, cy1, x, y] of segments)
ctx.bezierCurveTo(cx0, cy0, cx1, cy1, x, y)
p = [x, y]
i += 7
break
}
default:
throw new Error(`unexpected command: ${c}`)
}
}
}
示例2: _render
protected _render(ctx: Context2d, indices: number[], {sx0, sy0, sx1, sy1, scx, scy}: QuadraticData): void {
if (this.visuals.line.doit) {
for (const i of indices) {
if (isNaN(sx0[i] + sy0[i] + sx1[i] + sy1[i] + scx[i] + scy[i]))
continue
ctx.beginPath()
ctx.moveTo(sx0[i], sy0[i])
ctx.quadraticCurveTo(scx[i], scy[i], sx1[i], sy1[i])
this.visuals.line.set_vectorize(ctx, i)
ctx.stroke()
}
}
}
示例3: _render
_render(ctx: Context2d, indices, {sx0, sy0, sx1, sy1, scx, scy}) {
if (this.visuals.line.doit) {
for (const i of indices) {
if (isNaN(sx0[i]+sy0[i]+sx1[i]+sy1[i]+scx[i]+scy[i])) {
continue;
}
ctx.beginPath();
ctx.moveTo(sx0[i], sy0[i]);
ctx.quadraticCurveTo(scx[i], scy[i], sx1[i], sy1[i]);
this.visuals.line.set_vectorize(ctx, i);
ctx.stroke();
}
}
}