本文整理汇总了TypeScript中core/util/canvas.Context2d.drawImage方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Context2d.drawImage方法的具体用法?TypeScript Context2d.drawImage怎么用?TypeScript Context2d.drawImage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core/util/canvas.Context2d
的用法示例。
在下文中一共展示了Context2d.drawImage方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: _render
protected _render(ctx: Context2d, indices: number[], {image_data, sx, sy, sw, sh}: _ImageData): void {
const old_smoothing = ctx.getImageSmoothingEnabled()
ctx.setImageSmoothingEnabled(false)
ctx.globalAlpha = this.model.global_alpha
for (const i of indices) {
if (image_data[i] == null)
continue
if (isNaN(sx[i] + sy[i] + sw[i] + sh[i]))
continue
const y_offset = sy[i]
ctx.translate(0, y_offset)
ctx.scale(1, -1)
ctx.translate(0, -y_offset)
ctx.drawImage(image_data[i], sx[i]|0, sy[i]|0, sw[i], sh[i])
ctx.translate(0, y_offset)
ctx.scale(1, -1)
ctx.translate(0, -y_offset)
}
ctx.setImageSmoothingEnabled(old_smoothing)
}
示例2: _render
_render(ctx: Context2d, indices, {image_data, sx, sy, sw, sh}) {
const old_smoothing = ctx.getImageSmoothingEnabled();
ctx.setImageSmoothingEnabled(false);
for (const i of indices) {
if ((image_data[i] == null)) {
continue;
}
if (isNaN(sx[i]+sy[i]+sw[i]+sh[i])) {
continue;
}
const y_offset = sy[i];
ctx.translate(0, y_offset);
ctx.scale(1, -1);
ctx.translate(0, -y_offset);
ctx.drawImage(image_data[i], sx[i]|0, sy[i]|0, sw[i], sh[i]);
ctx.translate(0, y_offset);
ctx.scale(1, -1);
ctx.translate(0, -y_offset);
}
return ctx.setImageSmoothingEnabled(old_smoothing);
}
示例3: _draw_image
_draw_image(ctx: Context2d) {
const image = this.model._computed_image_dimensions();
ctx.save();
ctx.setImageSmoothingEnabled(false);
ctx.globalAlpha = this.model.scale_alpha;
ctx.drawImage(this.image, 0, 0, image.width, image.height);
if (this.visuals.bar_line.doit) {
this.visuals.bar_line.set_value(ctx);
ctx.strokeRect(0, 0, image.width, image.height);
}
return ctx.restore();
}
示例4: _render_image
_render_image(ctx: Context2d, i, image, sx, sy, sw, sh, angle) {
if (isNaN(sw[i])) { sw[i] = image.width; }
if (isNaN(sh[i])) { sh[i] = image.height; }
const { anchor } = this.model;
[sx, sy] = this._final_sx_sy(anchor, sx[i], sy[i], sw[i], sh[i]);
ctx.save();
ctx.globalAlpha = this.model.global_alpha;
if (angle[i]) {
ctx.translate(sx, sy);
ctx.rotate(angle[i]);
ctx.drawImage(image, 0, 0, sw[i], sh[i]);
ctx.rotate(-angle[i]);
ctx.translate(-sx, -sy);
} else {
ctx.drawImage(image, sx, sy, sw[i], sh[i]);
}
return ctx.restore();
}