本文整理汇总了TypeScript中core/util/canvas.Context2d.clip方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Context2d.clip方法的具体用法?TypeScript Context2d.clip怎么用?TypeScript Context2d.clip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core/util/canvas.Context2d
的用法示例。
在下文中一共展示了Context2d.clip方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: _paint_levels
_paint_levels(ctx: Context2d, levels, clip_region = null) {
ctx.save();
if ((clip_region != null) && (this.model.plot.output_backend === "canvas")) {
ctx.beginPath();
ctx.rect.apply(ctx, clip_region);
ctx.clip();
}
const indices = {};
for (let i = 0; i < this.model.plot.renderers.length; i++) {
const renderer = this.model.plot.renderers[i];
indices[renderer.id] = i;
}
const sortKey = renderer_view => indices[renderer_view.model.id];
for (const level of levels) {
const renderer_views = sortBy(values(this.levels[level]), sortKey);
for (const renderer_view of renderer_views) {
renderer_view.render();
}
}
return ctx.restore();
}
示例2: _paint_levels
protected _paint_levels(ctx: Context2d, levels: string[], clip_region?: FrameBox): void {
ctx.save()
if (clip_region != null) {
ctx.beginPath()
ctx.rect.apply(ctx, clip_region)
ctx.clip()
}
const indices: {[key: string]: number} = {}
for (let i = 0; i < this.model.plot.renderers.length; i++) {
const renderer = this.model.plot.renderers[i]
indices[renderer.id] = i
}
const sortKey = (renderer_view: RendererView) => indices[renderer_view.model.id]
for (const level of levels) {
const renderer_views = sortBy(values(this.levels[level]), sortKey)
for (const renderer_view of renderer_views) {
renderer_view.render()
}
}
ctx.restore()
}
示例3: _render
_render(ctx: Context2d, indices, {_url, image, sx, sy, sw, sh, _angle}) {
// TODO (bev): take actual border width into account when clipping
const { frame } = this.renderer.plot_view;
ctx.rect(
frame._left.value+1, frame._top.value+1,
frame._width.value-2, frame._height.value-2,
);
ctx.clip();
let finished = true;
for (const i of indices) {
if (isNaN(sx[i]+sy[i]+_angle[i])) {
continue;
}
if (this.retries[i] === -1) {
continue;
}
if ((image[i] == null)) {
finished = false;
continue;
}
this._render_image(ctx, i, image[i], sx, sy, sw, sh, _angle);
}
if (finished && !this._images_rendered) {
this._images_rendered = true;
return this.notify_finished();
}
}