File tree Expand file tree Collapse file tree 2 files changed +11
-4
lines changed Expand file tree Collapse file tree 2 files changed +11
-4
lines changed Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " compodraw" ,
3
- "version" : " 1.0.0 " ,
3
+ "version" : " 1.0.1 " ,
4
4
"description" : " Compose with JSX or XML then draw to Canvas API" ,
5
5
"main" : " build/compodraw.js" ,
6
6
"types" : " types/index.d.ts" ,
Original file line number Diff line number Diff line change @@ -5,12 +5,19 @@ import { Instruct } from "../interfaces";
5
5
*
6
6
* @param composed Typically a group of instructions
7
7
* @param canvasDOM Targeted canvas element
8
+ * @param isResponsive Set to false if canvas behaves weird
8
9
*/
9
- export function draw ( composed : Instruct , canvasDOM : HTMLCanvasElement ) : void {
10
+ export function draw (
11
+ composed : Instruct ,
12
+ canvasDOM : HTMLCanvasElement ,
13
+ isResponsive : boolean = true
14
+ ) : void {
10
15
if ( ! canvasDOM ) return ;
11
16
12
- canvasDOM . width = canvasDOM . clientWidth * window . devicePixelRatio ;
13
- canvasDOM . height = canvasDOM . clientHeight * window . devicePixelRatio ;
17
+ if ( isResponsive ) {
18
+ canvasDOM . width = canvasDOM . clientWidth * window . devicePixelRatio ;
19
+ canvasDOM . height = canvasDOM . clientHeight * window . devicePixelRatio ;
20
+ }
14
21
15
22
if ( typeof canvasDOM . getContext === "function" ) {
16
23
const canvasCtx = canvasDOM . getContext ( "2d" ) ;
You can’t perform that action at this time.
0 commit comments