npm run format
This commit is contained in:
@@ -21,9 +21,7 @@ export function useCanvas2D(canvasRef: Ref<HTMLCanvasElement | null>, options?:
|
||||
const applySmoothing = () => {
|
||||
if (ctx.value) {
|
||||
const pixelPerfect = options?.pixelPerfect;
|
||||
const isPixelPerfect = typeof pixelPerfect === 'boolean'
|
||||
? pixelPerfect
|
||||
: pixelPerfect?.value ?? settingsStore.pixelPerfect;
|
||||
const isPixelPerfect = typeof pixelPerfect === 'boolean' ? pixelPerfect : (pixelPerfect?.value ?? settingsStore.pixelPerfect);
|
||||
ctx.value.imageSmoothingEnabled = !isPixelPerfect;
|
||||
}
|
||||
};
|
||||
@@ -53,12 +51,7 @@ export function useCanvas2D(canvasRef: Ref<HTMLCanvasElement | null>, options?:
|
||||
ctx.value.strokeRect(Math.floor(x), Math.floor(y), width, height);
|
||||
};
|
||||
|
||||
const drawImage = (
|
||||
img: HTMLImageElement | HTMLCanvasElement,
|
||||
x: number,
|
||||
y: number,
|
||||
alpha = 1
|
||||
) => {
|
||||
const drawImage = (img: HTMLImageElement | HTMLCanvasElement, x: number, y: number, alpha = 1) => {
|
||||
if (!ctx.value) return;
|
||||
const prevAlpha = ctx.value.globalAlpha;
|
||||
ctx.value.globalAlpha = alpha;
|
||||
@@ -87,10 +80,7 @@ export function useCanvas2D(canvasRef: Ref<HTMLCanvasElement | null>, options?:
|
||||
};
|
||||
|
||||
// Centralized force redraw handler
|
||||
const createForceRedrawHandler = <T extends { x: number; y: number }>(
|
||||
items: T[],
|
||||
drawCallback: () => void
|
||||
) => {
|
||||
const createForceRedrawHandler = <T extends { x: number; y: number }>(items: T[], drawCallback: () => void) => {
|
||||
return () => {
|
||||
ensureIntegerPositions(items);
|
||||
applySmoothing();
|
||||
@@ -113,11 +103,7 @@ export function useCanvas2D(canvasRef: Ref<HTMLCanvasElement | null>, options?:
|
||||
};
|
||||
|
||||
// Helper to attach load/error listeners to images that aren't yet loaded
|
||||
const attachImageListeners = (
|
||||
sprites: Sprite[],
|
||||
onLoad: () => void,
|
||||
tracked: WeakSet<HTMLImageElement>
|
||||
) => {
|
||||
const attachImageListeners = (sprites: Sprite[], onLoad: () => void, tracked: WeakSet<HTMLImageElement>) => {
|
||||
sprites.forEach(sprite => {
|
||||
const img = sprite.img as HTMLImageElement | undefined;
|
||||
if (img && !tracked.has(img)) {
|
||||
|
||||
Reference in New Issue
Block a user