-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Delegate canvas resizing to renderers * Fix positionning of canvas inside SketchRenderer
- Loading branch information
1 parent
9c71bdc
commit c8d771b
Showing
8 changed files
with
191 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,34 @@ | ||
/** | ||
* @typedef {object} MountParams2DRenderer | ||
* @property {CanvasRenderingContext2D} context | ||
*/ | ||
|
||
/** | ||
* @param {object} params | ||
* @param {number} params.id | ||
* @param {HTMLDivElement} params.container | ||
* @param {HTMLCanvasElement} params.canvas | ||
* @param {number} params.width | ||
* @param {number} params.height | ||
* @param {number} params.pixelRatio | ||
* @returns {MountParams2DRenderer} | ||
*/ | ||
export let onMountPreview = ({ canvas }) => { | ||
return { | ||
context: canvas.getContext('2d'), | ||
}; | ||
}; | ||
|
||
/** | ||
* @param {object} params | ||
* @param {HTMLCanvasElement} params.canvas | ||
* @param {number} params.width | ||
* @param {number} params.height | ||
* @param {number} params.pixelRatio | ||
*/ | ||
export let onResizePreview = ({ canvas, width, height, pixelRatio }) => { | ||
canvas.width = width * pixelRatio; | ||
canvas.height = height * pixelRatio; | ||
canvas.style.width = `${width}px`; | ||
canvas.style.height = `${height}px`; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.