本文整理汇总了TypeScript中core/util/canvas.Context2d.bezierCurveTo方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Context2d.bezierCurveTo方法的具体用法?TypeScript Context2d.bezierCurveTo怎么用?TypeScript Context2d.bezierCurveTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core/util/canvas.Context2d
的用法示例。
在下文中一共展示了Context2d.bezierCurveTo方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: _render
protected _render(ctx: Context2d, indices: number[], {sx, sy, sw, sh, _angle}: OvalData): void {
for (const i of indices) {
if (isNaN(sx[i] + sy[i] + sw[i] + sh[i] + _angle[i]))
continue
ctx.translate(sx[i], sy[i])
ctx.rotate(_angle[i])
ctx.beginPath()
ctx.moveTo(0, -sh[i]/2)
ctx.bezierCurveTo( sw[i]/2, -sh[i]/2, sw[i]/2, sh[i]/2, 0, sh[i]/2)
ctx.bezierCurveTo(-sw[i]/2, sh[i]/2, -sw[i]/2, -sh[i]/2, 0, -sh[i]/2)
ctx.closePath()
if (this.visuals.fill.doit) {
this.visuals.fill.set_vectorize(ctx, i)
ctx.fill()
}
if (this.visuals.line.doit) {
this.visuals.line.set_vectorize(ctx, i)
ctx.stroke()
}
ctx.rotate(-_angle[i])
ctx.translate(-sx[i], -sy[i])
}
}
示例2: _render
_render(ctx: Context2d, indices, {sx, sy, sw, sh}) {
for (const i of indices) {
if (isNaN(sx[i]+sy[i]+sw[i]+sh[i]+this._angle[i])) {
continue;
}
ctx.translate(sx[i], sy[i]);
ctx.rotate(this._angle[i]);
ctx.beginPath();
ctx.moveTo(0, -sh[i]/2);
ctx.bezierCurveTo( sw[i]/2, -sh[i]/2, sw[i]/2, sh[i]/2, 0, sh[i]/2);
ctx.bezierCurveTo(-sw[i]/2, sh[i]/2, -sw[i]/2, -sh[i]/2, 0, -sh[i]/2);
ctx.closePath();
if (this.visuals.fill.doit) {
this.visuals.fill.set_vectorize(ctx, i);
ctx.fill();
}
if (this.visuals.line.doit) {
this.visuals.line.set_vectorize(ctx, i);
ctx.stroke();
}
ctx.rotate(-this._angle[i]);
ctx.translate(-sx[i], -sy[i]);
}
}
示例3: _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}`)
}
}
}
示例4: _render
protected _render(ctx: Context2d, indices: number[],
{sx0, sy0, sx1, sy1, scx0, scy0, scx1, scy1}: BezierData): void {
if (this.visuals.line.doit) {
for (const i of indices) {
if (isNaN(sx0[i] + sy0[i] + sx1[i] + sy1[i] + scx0[i] + scy0[i] + scx1[i] + scy1[i]))
continue
ctx.beginPath()
ctx.moveTo(sx0[i], sy0[i])
ctx.bezierCurveTo(scx0[i], scy0[i], scx1[i], scy1[i], sx1[i], sy1[i])
this.visuals.line.set_vectorize(ctx, i)
ctx.stroke()
}
}
}
示例5: _render
_render(ctx: Context2d, indices, {sx0, sy0, sx1, sy1, scx0, scy0, scx1, scy1}) {
if (this.visuals.line.doit) {
for (const i of indices) {
if (isNaN(sx0[i]+sy0[i]+sx1[i]+sy1[i]+scx0[i]+scy0[i]+scx1[i]+scy1[i])) {
continue;
}
ctx.beginPath();
ctx.moveTo(sx0[i], sy0[i]);
ctx.bezierCurveTo(scx0[i], scy0[i], scx1[i], scy1[i], sx1[i], sy1[i]);
this.visuals.line.set_vectorize(ctx, i);
ctx.stroke();
}
}
}