mirror of
https://github.com/servo/servo.git
synced 2025-09-09 06:28:22 +01:00
Implements drawImage for html image as ImageSource
This commit is contained in:
parent
184d214e26
commit
88954e3e18
86 changed files with 1380 additions and 251 deletions
41
tests/ref/2dcontext/drawimage_canvas_5.html
Normal file
41
tests/ref/2dcontext/drawimage_canvas_5.html
Normal file
|
@ -0,0 +1,41 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
</head>
|
||||
<style>
|
||||
html, body {
|
||||
margin: 0;
|
||||
}
|
||||
</style>
|
||||
<body>
|
||||
<canvas id="dest" height="100" width="100"></canvas>
|
||||
<script>
|
||||
|
||||
var sourceWidth = 50;
|
||||
var sourceHeight = 50;
|
||||
var smoothingEnabled = false;
|
||||
var destCanvas = document.getElementById('dest');
|
||||
var sourceCanvas = document.createElement('canvas');
|
||||
sourceCanvas.width = sourceWidth;
|
||||
sourceCanvas.height = sourceHeight;
|
||||
|
||||
var sourceCtx = sourceCanvas.getContext('2d');
|
||||
sourceCtx.fillStyle = "#00FFFF";
|
||||
sourceCtx.fillRect(0, 0, sourceWidth, sourceHeight);
|
||||
sourceCtx.fillStyle = "#000000";
|
||||
sourceCtx.fillRect(5,5,40,40);
|
||||
|
||||
var destCtx = destCanvas.getContext('2d');
|
||||
destCtx.fillStyle = "#FF0000";
|
||||
destCtx.fillRect(0, 0, destCanvas.width, destCanvas.height);
|
||||
destCtx.imageSmoothingEnabled = smoothingEnabled;
|
||||
|
||||
// The source canvas will copied to the 50,50 position of the destination canvas
|
||||
// over an area of 50x25 pixels
|
||||
// The copied image will be distorted along the x axis
|
||||
destCtx.drawImage(sourceCanvas, 50, 50, 50, 20);
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Loading…
Add table
Add a link
Reference in a new issue