P5-1451: Add photo-wallpaper type

This commit is contained in:
Ruslan Getmansky
2017-11-30 14:45:28 +02:00
parent 59f8dfd8bc
commit f01921e024
6 changed files with 94 additions and 18 deletions
+36
View File
@@ -0,0 +1,36 @@
<!DOCTYPE html>
<html lang="en">
<head>
</head>
<body>
<label>Width: <input type="text" id="width" name="width" value="500" /></label>
<label>Height: <input type="text" id="height" name="height" value="400" /></label>
<canvas id="image-editor" width="800" height="600"></canvas>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/fabric.js/1.7.11/fabric.js"></script>
<script src="../../dist/js/main.js"></script>
<script type="text/javascript">
var width = document.getElementById('width');
var height = document.getElementById('height');
var editor = new ImageEditor('image-editor', {
type: 'wallpaper',
dimensions: {width: 800, height: 600}
});
function loadImage() {
var image_url = '//images-dev.photowall.com/products/46955.jpg?h=450&repeat[tw]=45&repeat[th]=35&repeat[mw]=' + width.value + '&repeat[mh]=' + height.value;
editor.loadImage(image_url, function() {
editor.crop(width.value, height.value, 'cm');
});
}
//add event listeners
width.addEventListener('keyup', loadImage);
height.addEventListener('keyup', loadImage);
loadImage();
</script>
</body>
</html>