HTML and CSS Reference
In-Depth Information
F IGURE 2-5 Transforming a rectangle
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title> canvas transform() Example </title>
<style type="text/css">
canvas {border: 1px solid black;}
</style>
<script type="text/javascript">
window.onload = function(){
var canvas = document.getElementById("canvas");
var context = canvas.getContext("2d");
context.fillStyle = "rgba(255,0,0,.4)";
context.rect(0,0,100,100);
context.fill();
context.setTransform(1,1,1,0,0,0);
context.beginPath();
context.fillStyle = "rgba(0,255,0,.4)";
context.rect(75,75,100,100);
context.fill();
context.setTransform(0,.5,1,.8,0,0);
context.beginPath();
Search WWH ::




Custom Search