Skip to content

Commit

Permalink
fix: pixelDensity
Browse files Browse the repository at this point in the history
  • Loading branch information
lajbel committed Sep 5, 2024
1 parent f8bca8c commit 45e1ba6
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/app/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -859,7 +859,7 @@ export const initApp = (opt: {
const docEvents: EventList<DocumentEventMap> = {};
const winEvents: EventList<WindowEventMap> = {};

const pd = opt.pixelDensity || window.devicePixelRatio || 1;
const pd = opt.pixelDensity || 1;

canvasEvents.mousemove = (e) => {
const mousePos = new Vec2(e.offsetX, e.offsetY);
Expand Down
2 changes: 1 addition & 1 deletion src/gfx/gfxApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export type AppGfxCtx = ReturnType<typeof initAppGfx>;

export const initAppGfx = (gopt: KAPLAYOpt, ggl: GfxCtx) => {
const defShader = makeShader(ggl, DEF_VERT, DEF_FRAG);
const pixelDensity = window.devicePixelRatio || window.devicePixelRatio;
const pixelDensity = gopt.pixelDensity ?? 1;
const gscale = gopt.scale ?? 1;
const { gl } = ggl;

Expand Down
2 changes: 1 addition & 1 deletion src/kaplay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ const kaplay = <

canvas.style.cssText = styles.join(";");

pixelDensity = gopt.pixelDensity || window.devicePixelRatio;
pixelDensity = gopt.pixelDensity || 1;

canvas.width *= pixelDensity;
canvas.height *= pixelDensity;
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3862,7 +3862,7 @@ export interface KAPLAYOpt<
*/
font?: string;
/**
* Device pixel scale (defaults to window.devicePixelRatio, high pixel density will hurt performance).
* Device pixel scale (defaults to 1, high pixel density will hurt performance).
*
* @since v3000.0
*/
Expand Down

0 comments on commit 45e1ba6

Please sign in to comment.