Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

Fix Blurry Canvas on Mobile Phones

function createCanvas(width, height, set2dTransform = true) {
  const ratio = Math.ceil(window.devicePixelRatio);
  const canvas = document.createElement('canvas');
  canvas.width = width * ratio;
  canvas.height = height * ratio;
  canvas.style.width = `${width}px`;
  canvas.style.height = `${height}px`;
  if (set2dTransform) {
    canvas.getContext('2d').setTransform(ratio, 0, 0, ratio, 0, 0);
  }
  return canvas;
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: joomla add javascript 
Javascript :: dsicrod.js bot answer to himself 
Javascript :: refresh mathjax 
Javascript :: javascript function, for loops, linear time complexity 
Javascript :: axios get request with body 
Javascript :: { "rules": { ".read": true, ".write": true } } 
Javascript :: js find :invalid inside div 
Javascript :: javascript localstorage reference 
Javascript :: how to check if a string contains a specific word in javascript 
Javascript :: state changes when changing route useContext next 
Javascript :: jtml cdn enter 
Javascript :: show dropdown upwards and downward 
Javascript :: Render raw html in response with Express 
Javascript :: for of exemple 
Javascript :: how to square a number in html 
Javascript :: Caret.editorconfig 
Javascript :: straforma in string js 
Javascript :: javascript categories input object example 
Javascript :: Script test to be oneOf 
Javascript :: How to extract dynamic variable from < bracket in javascript 
Javascript :: check variable is array or not in javascript 
Javascript :: vue2-editor save image 
Javascript :: ameca face expression code xcode 
Javascript :: Timestamp Format: 23.12.2015 08:34:50 
Javascript :: javascript remove null object 
Javascript :: sqlite get row id after insert nodejs 
Javascript :: returns string of names, seperated by commas and an ampersand namesObj in javascript 
Javascript :: how to connect two model in mongoose 
Javascript :: 00979fb28f7cc517ff28c035bb8ef10698d0d991304e9901ba214ad0cada69ef:script- 
Javascript :: javaScript Bezier Curve After Effects expression 
ADD CONTENT
Topic
Content
Source link
Name
4+1 =