mirror of
https://github.com/servo/servo.git
synced 2025-08-19 20:35:34 +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
36
tests/ref/2dcontext/drawimage_html_image_6.html
Normal file
36
tests/ref/2dcontext/drawimage_html_image_6.html
Normal file
|
@ -0,0 +1,36 @@
|
|||
<!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 = 100;
|
||||
var sourceHeight = 100;
|
||||
var smoothingEnabled = false;
|
||||
var destCanvas = document.getElementById('dest');
|
||||
var sourceImg = document.createElement('img');
|
||||
sourceImg.src = '../2x2.png'
|
||||
sourceImg.width = sourceWidth;
|
||||
sourceImg.height = sourceHeight;
|
||||
|
||||
var destCtx = destCanvas.getContext('2d');
|
||||
destCtx.fillStyle = "#FF0000";
|
||||
destCtx.fillRect(0, 0, destCanvas.width, destCanvas.height);
|
||||
destCtx.imageSmoothingEnabled = smoothingEnabled;
|
||||
|
||||
// 8 arguments, both destination and source origins are 0, 0
|
||||
// An area of 32x32 pixels of the source image will be copied to
|
||||
// an area of 32x32 pixels of the destination canvas
|
||||
destCtx.drawImage(sourceImg, 0, 0, 32, 32, 0, 0, 32, 32);
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Loading…
Add table
Add a link
Reference in a new issue