Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated the drag-drop and Invert Filter.
Also added rotate buttons and implemented their funcionality.
- Loading branch information
Showing
3 changed files
with
124 additions
and
1 deletion.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
<!DOCTYPE html> | ||
<html xmlns="http://www.w3.org/1999/xhtml"> | ||
<head> | ||
<title></title> | ||
</head> | ||
<body> | ||
|
||
<script type="text/javascript" src="pixastic.core.js"></script> | ||
<script type="text/javascript" src="brightness.js"></script> | ||
<script type="text/javascript" src="invert.js"></script> | ||
<script type="text/javascript" src="blur.js"></script> | ||
<script type="text/javascript" src="glow.js"></script> | ||
|
||
<div id="mainDiv"> | ||
<img id="imgBG" src="dropHere.png" onclick="save()" style=" border:1px solid #000"/> | ||
|
||
</div> | ||
<div> | ||
<img src="rotate_cw.png" onclick="RotatePlus()"/> | ||
<img src="rotate_ccw.png" onclick="RotateMinus()"/> | ||
</div> | ||
<script> | ||
var dropbox = document.getElementById('imgBG'); | ||
var mainDiv = document.getElementById('mainDiv'); | ||
var Filters = {}; | ||
arr = []; | ||
|
||
//dropbox.style.height = "500px"; | ||
// Setup drag and drop handlers. | ||
dropbox.addEventListener('dragenter', stopDefault, false); | ||
dropbox.addEventListener('dragover', stopDefault, false); | ||
dropbox.addEventListener('dragleave', stopDefault, false); | ||
dropbox.addEventListener('drop', onDrop, false); | ||
|
||
function stopDefault(e) { | ||
e.stopPropagation(); | ||
e.preventDefault(); | ||
} | ||
|
||
|
||
function onDrop(e) { | ||
e.stopPropagation(); | ||
e.preventDefault(); | ||
|
||
var readFileSize = 0; | ||
var files = e.dataTransfer.files; | ||
|
||
|
||
file = files[0]; | ||
readFileSize += file.fileSize; | ||
|
||
|
||
// Only process image files. | ||
var imageType = /image.*/; | ||
|
||
if (!file.type.match(imageType)) { | ||
return; | ||
} | ||
|
||
|
||
var reader = new FileReader(); | ||
|
||
|
||
reader.onerror = function (e) { | ||
alert('Error code: ' + e.target.error); | ||
}; | ||
|
||
|
||
// Create a closure to capture the file information. | ||
reader.onload = (function (aFile) { | ||
return function (evt) { | ||
dropbox.src = evt.target.result; | ||
dropbox.style.height = "300px"; | ||
Filters.dropbox = dropbox; | ||
Generate(); | ||
} | ||
})(file); | ||
|
||
// Read in the image file as a data url. | ||
reader.readAsDataURL(file); | ||
|
||
} | ||
|
||
function Generate() { | ||
Invert(); | ||
} | ||
|
||
function Invert() { | ||
var res = '<img id="imgInvert" src="' + dropbox.src + '" />'; | ||
mainDiv.innerHTML += res; | ||
|
||
var imgInvert = document.getElementById("imgInvert"); | ||
|
||
if (imgInvert.complete) { // make sure the image is fully loaded | ||
var newimg = Pixastic.process( | ||
imgInvert, | ||
"invert", null | ||
) | ||
imgInvert = newimg; | ||
} | ||
imgInvert.style.height = "300px"; | ||
//imgInvert.style.width = dropbox.style.width; | ||
Filters.Invert = imgInvert; | ||
} | ||
|
||
var Rad = 0; | ||
function RotatePlus() { | ||
Rad += 90; | ||
document.getElementById("imgBG").style.webkitTransform = "rotate(" + Rad + "deg)"; // for Chrome | ||
document.getElementById("imgBG").style.MozTransform = "rotate(" + Rad + "deg)"; // for FF | ||
Filters.Invert.style.webkitTransform = "rotate(" + Rad + "deg)"; // for Chrome | ||
Filters.Invert.style.MozTransform = "rotate(" + Rad + "deg)"; // for FF | ||
} | ||
function RotateMinus() { | ||
Rad -= 90; | ||
document.getElementById("imgBG").style.webkitTransform = "rotate(" + Rad + "deg)"; // for Chrome | ||
document.getElementById("imgBG").style.MozTransform = "rotate(" + Rad + "deg)"; // for FF | ||
Filters.Invert.style.webkitTransform = "rotate(" + Rad + "deg)"; // for Chrome | ||
Filters.Invert.style.MozTransform = "rotate(" + Rad + "deg)"; // for FF | ||
} | ||
</script> | ||
</body> | ||
</html> |