本文整理汇总了TypeScript中core/util/canvas.Context2d.closePath方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Context2d.closePath方法的具体用法?TypeScript Context2d.closePath怎么用?TypeScript Context2d.closePath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core/util/canvas.Context2d
的用法示例。
在下文中一共展示了Context2d.closePath方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: _render
_render(ctx: Context2d, indices, {sxs, sys}) {
// @sxss and @syss are used by _hit_point and sxc, syc
// This is the earliest we can build them, and only build them once
this.renderer.sxss = this._build_discontinuous_object(sxs);
this.renderer.syss = this._build_discontinuous_object(sys);
for (const i of indices) {
const [sx, sy] = [sxs[i], sys[i]];
if (this.visuals.fill.doit) {
this.visuals.fill.set_vectorize(ctx, i);
for (let j = 0, end = sx.length; j < end; j++) {
if (j === 0) {
ctx.beginPath();
ctx.moveTo(sx[j], sy[j]);
continue;
} else if (isNaN(sx[j] + sy[j])) {
ctx.closePath();
ctx.fill();
ctx.beginPath();
continue;
} else {
ctx.lineTo(sx[j], sy[j]);
}
}
ctx.closePath();
ctx.fill();
}
if (this.visuals.line.doit) {
this.visuals.line.set_vectorize(ctx, i);
for (let j = 0, end = sx.length; j < end; j++) {
if (j === 0) {
ctx.beginPath();
ctx.moveTo(sx[j], sy[j]);
continue;
} else if (isNaN(sx[j] + sy[j])) {
ctx.closePath();
ctx.stroke();
ctx.beginPath();
continue;
} else {
ctx.lineTo(sx[j], sy[j]);
}
}
ctx.closePath();
ctx.stroke();
}
}
}
示例2: _render
protected _render(ctx: Context2d, indices: number[], {sxs, sys}: PatchesData): void {
// this.sxss and this.syss are used by _hit_point and sxc, syc
// This is the earliest we can build them, and only build them once
this.sxss = this._build_discontinuous_object(sxs as any) // XXX
this.syss = this._build_discontinuous_object(sys as any) // XXX
for (const i of indices) {
const [sx, sy] = [sxs[i], sys[i]]
if (this.visuals.fill.doit) {
this.visuals.fill.set_vectorize(ctx, i)
for (let j = 0, end = sx.length; j < end; j++) {
if (j == 0) {
ctx.beginPath()
ctx.moveTo(sx[j], sy[j])
continue
} else if (isNaN(sx[j] + sy[j])) {
ctx.closePath()
ctx.fill()
ctx.beginPath()
continue
} else
ctx.lineTo(sx[j], sy[j])
}
ctx.closePath()
ctx.fill()
}
if (this.visuals.line.doit) {
this.visuals.line.set_vectorize(ctx, i)
for (let j = 0, end = sx.length; j < end; j++) {
if (j == 0) {
ctx.beginPath()
ctx.moveTo(sx[j], sy[j])
continue
} else if (isNaN(sx[j] + sy[j])) {
ctx.closePath()
ctx.stroke()
ctx.beginPath()
continue
} else
ctx.lineTo(sx[j], sy[j])
}
ctx.closePath()
ctx.stroke()
}
}
}
示例3: _one_diamond
function _one_diamond(ctx: Context2d, r: number): void {
ctx.moveTo(0, r)
ctx.lineTo(r/1.5, 0)
ctx.lineTo(0, -r)
ctx.lineTo(-r/1.5, 0)
ctx.closePath()
}
示例4: _normal
_normal(ctx: Context2d, _i: number): void {
ctx.beginPath()
ctx.moveTo(0.5*this.size, this.size)
ctx.lineTo(0, 0)
ctx.lineTo(-0.5*this.size, this.size)
ctx.closePath()
}
示例5: _render
protected _render(ctx: Context2d, indices: number[], {sxs, sys}: MultiPolygonsData): void {
if (this.visuals.fill.doit || this.visuals.line.doit) {
for (const i of indices) {
ctx.beginPath()
for (let j = 0, endj = sxs[i].length; j < endj; j++) {
for (let k = 0, endk = sxs[i][j].length; k < endk; k++) {
const _sx = sxs[i][j][k]
const _sy = sys[i][j][k]
for (let l = 0, endl = _sx.length; l < endl; l++) {
if (l == 0) {
ctx.moveTo(_sx[l], _sy[l])
continue
} else
ctx.lineTo(_sx[l], _sy[l])
}
ctx.closePath()
}
}
if (this.visuals.fill.doit) {
this.visuals.fill.set_vectorize(ctx, i)
ctx.fill("evenodd")
}
if (this.visuals.line.doit) {
this.visuals.line.set_vectorize(ctx, i)
ctx.stroke()
}
}
}
}
示例6: _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])
}
}
示例7: _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]);
}
}
示例8: _render
protected _render(ctx: Context2d, indices: number[], {sx, sy, svx, svy, _scale}: HexTileData): void {
for (const i of indices) {
if (isNaN(sx[i] + sy[i] + _scale[i]))
continue;
ctx.translate(sx[i], sy[i])
ctx.beginPath();
for (let j = 0; j < 6; j++) {
ctx.lineTo(svx[j]*_scale[i], svy[j]*_scale[i])
}
ctx.closePath()
ctx.translate(-sx[i], -sy[i])
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();
}
}
}
示例9: _paint_empty
// this overrides the standard _paint_empty to make the inner canvas transparent
protected _paint_empty(ctx: Context2d, frame_box: FrameBox): void {
const ow = this.layout._width.value
const oh = this.layout._height.value
const [left, top, iw, ih] = frame_box
ctx.clearRect(0, 0, ow, oh)
ctx.beginPath()
ctx.moveTo(0, 0)
ctx.lineTo(0, oh)
ctx.lineTo(ow, oh)
ctx.lineTo(ow, 0)
ctx.lineTo(0, 0)
ctx.moveTo(left, top)
ctx.lineTo(left+iw, top)
ctx.lineTo(left+iw, top+ih)
ctx.lineTo(left, top+ih)
ctx.lineTo(left, top)
ctx.closePath()
if (this.model.border_fill_color != null) {
ctx.fillStyle = this.model.border_fill_color
ctx.fill()
}
}
示例10: _render
protected _render(ctx: Context2d, indices: number[],
{sx, sy, _start_angle, _angle, sinner_radius, souter_radius}: AnnularWedgeData): void {
const direction = this.model.properties.direction.value();
for (const i of indices) {
if (isNaN(sx[i] + sy[i] + sinner_radius[i] + souter_radius[i] + _start_angle[i] + _angle[i]))
continue;
ctx.translate(sx[i], sy[i]);
ctx.rotate(_start_angle[i]);
ctx.moveTo(souter_radius[i], 0);
ctx.beginPath();
ctx.arc(0, 0, souter_radius[i], 0, _angle[i], direction);
ctx.rotate(_angle[i]);
ctx.lineTo(sinner_radius[i], 0);
ctx.arc(0, 0, sinner_radius[i], 0, -_angle[i], !direction);
ctx.closePath();
ctx.rotate(-_angle[i]-_start_angle[i]);
ctx.translate(-sx[i], -sy[i]);
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();
}
}
}