Skip to content

Instantly share code, notes, and snippets.

@tanatana
Created October 10, 2014 13:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tanatana/387fe9b98eac7509f5f9 to your computer and use it in GitHub Desktop.
Save tanatana/387fe9b98eac7509f5f9 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>canvas problem with iOS7.1 on HDPI device</title>
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
var $img = $("#originalImage");
$img.on("load", function(){
var img = document.getElementById("originalImage");
var canvas1 = document.getElementById("canvas1");
var ctx = canvas1.getContext("2d");
ctx.drawImage(img,0,0,320,320,0,0,320,320);
ctx.drawImage(canvas1,20,20,160,160,80,80,160,160);
var canvas2 = document.getElementById("canvas2");
var ctx2 = canvas2.getContext("2d");
ctx2.drawImage(img,0,0,320,320,0,0,640,640);
ctx2.drawImage(canvas2,40,40,320,320,160,160,320,320);
});
});
</script>
</head>
<body>
<h1>original image</h1>
<img id="originalImage" src="images/test.png">
<h1>normal</h1>
<canvas id="canvas1" width="320" height="320"></canvas>
<h1>retina support</h1>
<canvas id="canvas2" width="640" height="640" style="width: 320px; height: 320px;"> </canvas>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment