add drawCircle
This commit is contained in:
parent
ac890c9abd
commit
f8bdaf73ea
@ -184,7 +184,6 @@ export class Gamelib {
|
|||||||
|
|
||||||
const maxSize = Math.max(sprite.width, sprite.height);
|
const maxSize = Math.max(sprite.width, sprite.height);
|
||||||
const newSprite = new OffscreenCanvas(maxSize, maxSize);
|
const newSprite = new OffscreenCanvas(maxSize, maxSize);
|
||||||
console.log(newSprite);
|
|
||||||
const newSpriteCx = newSprite.getContext("2d");
|
const newSpriteCx = newSprite.getContext("2d");
|
||||||
|
|
||||||
newSpriteCx.imageSmoothingEnabled = false;
|
newSpriteCx.imageSmoothingEnabled = false;
|
||||||
@ -221,6 +220,15 @@ export class Gamelib {
|
|||||||
cx.fillRect(x, y, width, height);
|
cx.fillRect(x, y, width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
drawCircle(x, y, r, color) {
|
||||||
|
const cx = this.cx;
|
||||||
|
|
||||||
|
cx.fillStyle = color;
|
||||||
|
cx.beginPath();
|
||||||
|
cx.arc(x, y, r, 0, 2 * Math.PI, false);
|
||||||
|
cx.fill();
|
||||||
|
}
|
||||||
|
|
||||||
drawLine(x0, y0, x1, y1, thickness, color) {
|
drawLine(x0, y0, x1, y1, thickness, color) {
|
||||||
const cx = this.cx;
|
const cx = this.cx;
|
||||||
|
|
||||||
@ -269,8 +277,6 @@ export class Gamelib {
|
|||||||
.filter((val) => val)
|
.filter((val) => val)
|
||||||
.join(" ");
|
.join(" ");
|
||||||
|
|
||||||
console.log(cx.font);
|
|
||||||
|
|
||||||
cx.textAlign = style.align ?? "left";
|
cx.textAlign = style.align ?? "left";
|
||||||
cx.textBaseline = style.baseline ?? "alphabetic";
|
cx.textBaseline = style.baseline ?? "alphabetic";
|
||||||
cx.direction = style.direction ?? "ltr";
|
cx.direction = style.direction ?? "ltr";
|
||||||
@ -367,6 +373,10 @@ export class GamelibAdapter {
|
|||||||
this.gamelib.drawRect(x, y, width, height, color);
|
this.gamelib.drawRect(x, y, width, height, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
drawCircle(x, y, r, color) {
|
||||||
|
this.gamelib.drawCircle(x, y, r, color);
|
||||||
|
}
|
||||||
|
|
||||||
drawLine(x0, y0, x1, y1, thickness, color) {
|
drawLine(x0, y0, x1, y1, thickness, color) {
|
||||||
this.gamelib.drawLine(x0, y0, x1, y1, thickness, color);
|
this.gamelib.drawLine(x0, y0, x1, y1, thickness, color);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user