This app combines two that I have previously discussed..
Although it can be used for images it is best with videos, where the two effects combine to mask poor video quality and give a sort of 3 dimensional quality.
Here is the interface with an image loaded:
To view a video clip Click
This is the code:
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head profile=”http://gmpg.org/xfn/11″>
<title>Bevel</title>
<style>
body {margin-left:0;margin-right:0;font:normal normal normal 15px Arial;}
#svg1 {position: absolute; left: 40px; top: 40px;}
a{ text-decoration: }:link { color: rgb(0, 0, 255) }:visited {color :rgb(100, 0,100) }:hover { }:active { }
#svg2, #frame{position: absolute; left: 10px; top: 10px; width: 700px; height: 680px; }
#frame{background: #771111}
#img1{position: absolute; left: 0; top: 0; width: 100%}
#b1{position: absolute; left: 1000px}
#b2{position: absolute; left: 1000px; top: 35px}
#b3{position: absolute; left: 1060px; top: 35px}
#b4{position: absolute; left: 1110px; top: 35px}
#b5{position: absolute; left: 1200px; top: 35px}
#fil{position: absolute; left: 1060px}
#s1{position: absolute; left: 1260px}
#ta{position: absolute; left: 0; top: 0; width:100%; height: 100%; visibility : hidden}
</style>
</head>
<body>
<div id=”frame”></div>
<svg id = “svg1”></svg>
<svg id = “svg2″></svg>
<input type=”button” id=”b1″ name=”b1″ value=”Draw” onclick=’drw();’/> <input type=”file” id=”fil” name=”files” onchange=’ld();’/> <input type=”button” id=”b2″ name=”b2″ value=”Save” onclick=’sve();’/> <input type=”button” id=”b3″ name=”b3″ value=”New” onclick=’location.reload();’/> <input type=”button” id=”b4″ name=”b4″ value=”Pause/Play” onclick=’ps();’/> <input type=”button” id=”b5″ name=”b5″ value=”Controls On/Off” onclick=’ctl();’/>
<select id=”s1″ name=”s1″>
<option>Choose Folder</option>
<option></option>
<option>A-E/</option>
<option>F-J/</option>
<option>K-O/</option>
<option>P-R/</option>
<option>S-T/</option>
<option>SVG/</option>
<option>Nails/</option>
<option>Animated GIF/</option>
<option>../Debut/Wondershare/MP4/</option>
<option>../mediaplayer-viral/FLV/WebM/</option>
<option>file:///media/removable/TOSHIBA%20EXT/Debut/Wondershare/MP4/</option>
<option>../videos/</option>
</select>
<textarea id=”ta” name=”ta” ondblclick=’document.getElementById(“ta”).style.visibility=”hidden”;’ ></textarea>
<script type=”text/javascript”>
var ht; var r = 0; var g = 0; var b = 0; var lft=0; var tp = 0; var wd; var op; var fldr; var fname; var ht2; var wd2; var paus = false; var ctrl = false;
function ctl() {
if (ctrl) {
document.getElementById(“svg1”).style.visibility = “hidden”;
document.getElementById(“svg2”).style.visibility = “hidden”;
ctrl = false;
} else {
document.getElementById(“svg1”).style.visibility = “visible”;
document.getElementById(“svg2”).style.visibility = “visible”;
ctrl = true;
}
}
function ps() {
if (paus) {
document.getElementById(“img1”).play();
paus = false;
} else {
document.getElementById(“img1″).pause();
paus = true;
}
}
function sve() {
var savstr = ‘<html> <input type=”button” id=”b4″ name=”b4″ style=”position: absolute; left: 1010px” value=”Pause/Play” onclick=”ps();” /> <input type=”button” id=”b5″ name=”b5″ style=”position: absolute; left: 1100px” value=”Controls On/Off” onclick=”ctl();”/> <select id=”vol” size=”22″ style=”position: absolute; left: 1010px; top: 40px” onchange=\’vlm();\’></select><dlv id=”frame” style=”position: absolute; left: 10px; top: 10px; width:’ + (wd2 + 60) + ‘px; height:’ + (ht2 + 60) + ‘px; background: #771111″ >’ + document.getElementById(“frame”).innerHTML + ‘ </div> <svg id=”svg1″ style=”position: absolute; left: 30px; top: 30px; width:’ + (wd2) + ‘px; height:’ + (ht2) + ‘px” >’ + document.getElementById(“svg1″).innerHTML + ‘ </svg> <svg id=”svg2″ style=”position: absolute; left: 0; top: 0; width:’ + (wd2 + 60) + ‘px; height:’ + (ht2 + 60) + ‘px” >’ + document.getElementById(“svg2”).innerHTML + ‘ </svg> <script>\nvar paus = true; var ctrl = true; document.getElementById(“img1”).volume = .5;\nfor (var i = 0; i <= 20; i ++) {\nif (i == 0) document.getElementById(“vol”).innerHTML = “<option>Choose Volume</option>”;\nif (i > 0) document.getElementById(“vol”).innerHTML += “<option>” + (.05 * i).toFixed(2) + “</option>”;\n}\nfunction ctl() {\nif (ctrl) {\ndocument.getElementById(“svg1”).style.visibility = “hidden”;\ndocument.getElementById(“svg2”).style.visibility = “hidden”;\nctrl = false;\n } else {\ndocument.getElementById(“svg1”).style.visibility = “visible”;\ndocument.getElementById(“svg2”).style.visibility = “visible”;\nctrl = true;\n}\n}\n function ps() {\nif (paus) {\ndocument.getElementById(“img1”).play();\npaus=false;\n} else {\ndocument.getElementById(“img1”).pause();\npaus = true;\n}\n}\nfunction vlm() {\ndocument.getElementById(“img1”).volume = parseFloat(document.getElementById(“vol”).value);\n}\n<\/script>\n </html>’;
document.getElementById(“ta”).value = savstr;
document.getElementById(“ta”).style.visibility=”visible”;
document.getElementById(“ta”).focus();
document.getElementById(“ta”).select();
success = document.execCommand(“copy”);
}
function ld() {
fldr = document.getElementById(“s1”).value;
fname = document.getElementById(“fil”).value;
fname = fldr + fname.substr(fname.lastIndexOf(“\\”) + 1);
if (fname.indexOf(“webm”) > -1 || fname.indexOf(“mp4”) > -1) document.getElementById(“frame”).innerHTML = ‘<div id= “vid” style = “position: absolute; left: 30px; top: 30px; width: 640px”><video id=”img1″ autoplay = “true” loop=”true” controls=”true” width=”100%” ><source src=”‘ + fname + ‘”></video></div>’;
if (fldr == “SVG/”) document.getElementById(“frame”).innerHTML = ‘http://'%20+%20fname%20+%20'‘;
if (fldr != “SVG/” && fname.indexOf(“webm”) == -1 && fname.indexOf(“mp4”) == -1) document.getElementById(“frame”).innerHTML = ‘<img id=”img1″ src=”‘ + fname + ‘” style = “position: absolute; left: 30px; top: 30px; width: 640px” />’;
//alert(document.getElementById(“frame”).innerHTML);
}
function drw() {
ht = img1.clientHeight;
wd = img1.clientWidth;
if (fname.indexOf(“svg”) == -1) {
if (img1.clientWidth / img1.clientHeight >= 1.5) {
if (document.getElementById(“frame”).innerHTML.indexOf(“vid”) > -1) {
document.getElementById(“vid”).style.width = “900px”;
document.getElementById(“vid”).style.height = 900 * (ht/wd) + “px”;
} else if (document.getElementById(“frame”).innerHTML.indexOf(“vid”) == -1) {
document.getElementById(“img1”).style.width = “900px”;
document.getElementById(“img1”).style.height = 900 * (ht/wd) + “px”;
}
} else if (img1.clientWidth >img1.clientHeight) {
if (document.getElementById(“frame”).innerHTML.indexOf(“vid”) > -1) {
document.getElementById(“vid”).style.width = “800px”;
document.getElementById(“vid”).style.height = 800 * (ht/wd) + “px”;
} else if (document.getElementById(“frame”).innerHTML.indexOf(“vid”) == -1) {
document.getElementById(“img1”).style.width = “800px”;
document.getElementById(“img1”).style.height = 800 * (ht/wd) + “px”;
}
} else if (fname.indexOf(“svg”) == -1) {
if (document.getElementById(“frame”).innerHTML.indexOf(“vid”) > -1) {
document.getElementById(“vid”).style.height = “600px”;
document.getElementById(“vid”).style.width = 600 * (wd/ht) + “px”;
} else if (document.getElementById(“frame”).innerHTML.indexOf(“vid”) == -1) {
document.getElementById(“img1”).style.height = “600px”;
document.getElementById(“img1”).style.width = 600 * (wd/ht) + “px”;
}
}
}
if (document.getElementById(“frame”).innerHTML.indexOf(“vid”) > -1) {
ht =parseInt(document.getElementById(“vid”).style.height.substr(0, document.getElementById(“vid”).style.height.length – 2));
wd = parseInt(document.getElementById(“vid”).style.width.substr(0, document.getElementById(“vid”).style.width.length – 2));
ht2 =parseInt(document.getElementById(“vid”).style.height.substr(0, document.getElementById(“vid”).style.height.length – 2));
wd2 = parseInt(document.getElementById(“vid”).style.width.substr(0, document.getElementById(“vid”).style.width.length – 2));
} else {
ht = img1.clientHeight;
ht2 = img1.clientHeight;
wd = img1.clientWidth;
wd2 = img1.clientWidth;
}
//alert(wd2);
document.getElementById(“svg1”).style.width = wd + “px”;
document.getElementById(“svg1”).style.height = ht + “px”;
document.getElementById(“svg1″).innerHTML = ‘<defs><pattern id=”noise” width=”2″ height=”2″ patternUnits=”userSpaceOnUse”><rect x=”1″ y=”1″ width=”1″ height=”1″ style=”fill:#000000; fill-opacity:1; stroke:none”></rect></pattern></defs> <rect x=”0″ y = “0” width=”‘ + wd + ‘” height=”‘ + ht + ‘” fill=”url(#noise)” stroke=”none” /> ‘;
document.getElementById(“svg2”).innerHTML = ‘<rect x = “0” y = “0” width = “‘ + (wd + 60) + ‘” height= “‘ + (ht + 60) + ‘” fill = “none” stroke=”rgb(0,0,0)” stroke-width=”1″ stroke-opacity=”.5″ />’;
for (var i = 1; i < 30; i ++) {
lft ++
tp ++;
wd -= 2;
ht -=2;
r += 8;
g += 8;
b += 8;
if ( i < 27) {
op = .5;
} else {
op = .6;
}
document.getElementById(“svg2″).innerHTML += ‘<rect id=”rect1” x = “‘ + lft + ‘” y = “‘ + tp + ‘” width = “‘ + (wd + 60) + ‘” height= “‘ + (ht + 60) + ‘” fill = “none” stroke=”rgb(‘ + r + ‘,’ + g + ‘,’ + b + ‘)” stroke-width=”1″ stroke-opacity=”‘ + op + ‘” />’;
}
document.getElementById(“frame”).style.height = (ht2 + 60) + “px”;
document.getElementById(“frame”).style.width = (wd2 + 60) + “px”;
document.getElementById(“svg2”).style.height = (ht2 + 60) + “px”;
document.getElementById(“svg2”).style.width = (wd2 + 60) + “px”;
}
</script>
</body></html>
The big t string is placed in a textarea, which can be saved to a html file.
Here is the file for the video shown:
<html> <input type=”button” id=”b4″ name=”b4″ style=”position: absolute; left: 1010px” value=”Pause/Play” onclick=”ps();” /> <input type=”button” id=”b5″ name=”b5″ style=”position: absolute; left: 1100px” value=”Controls On/Off” onclick=”ctl();”/> <select id=”vol” size=”22″ style=”position: absolute; left: 1010px; top: 40px” onchange=’vlm();’></select><dlv id=”frame” style=”position: absolute; left: 10px; top: 10px; width:860px; height:660px; background: #771111″ ><div id=”vid” style=”position: absolute; left: 30px; top: 30px; width: 800px; height: 600px;”><video id=”img1″ autoplay=”true” loop=”true” controls=”true” style=”width: 800px; height: 600px;”><source src=”../Debut/Wondershare/MP4/HHHClip.webm”></video></div> </div> <svg id=”svg1″ style=”position: absolute; left: 30px; top: 30px; width:800px; height:600px” ><defs><pattern id=”noise” width=”2″ height=”2″ patternUnits=”userSpaceOnUse”><rect x=”1″ y=”1″ width=”1″ height=”1″ style=”fill:#000000; fill-opacity:1; stroke:none”></rect></pattern></defs> <rect x=”0″ y=”0″ width=”800″ height=”600″ fill=”url(#noise)” stroke=”none”></rect> </svg> <svg id=”svg2″ style=”position: absolute; left: 0; top: 0; width:860px; height:660px” ><rect x=”0″ y=”0″ width=”860″ height=”660″ fill=”none” stroke=”rgb(0,0,0)” stroke-width=”1″ stroke-opacity=”.5″></rect><rect id=”rect1″ x=”1″ y=”1″ width=”858″ height=”658″ fill=”none” stroke=”rgb(8,8,8)” stroke-width=”1″ stroke-opacity=”0.5″></rect><rect id=”rect1″ x=”2″ y=”2″ width=”856″ height=”656″ fill=”none” stroke=”rgb(16,16,16)” stroke-width=”1″ stroke-opacity=”0.5″></rect><rect id=”rect1″ x=”3″ y=”3″ width=”854″ height=”654″ fill=”none” stroke=”rgb(24,24,24)” stroke-width=”1″ stroke-opacity=”0.5″></rect><rect id=”rect1″ x=”4″ y=”4″ width=”852″ height=”652″ fill=”none” stroke=”rgb(32,32,32)” stroke-width=”1″ stroke-opacity=”0.5″></rect><rect id=”rect1″ x=”5″ y=”5″ width=”850″ height=”650″ fill=”none” stroke=”rgb(40,40,40)” stroke-width=”1″ stroke-opacity=”0.5″></rect><rect id=”rect1″ x=”6″ y=”6″ width=”848″ height=”648″ fill=”none” stroke=”rgb(48,48,48)” stroke-width=”1″ stroke-opacity=”0.5″></rect><rect id=”rect1″ x=”7″ y=”7″ width=”846″ height=”646″ fill=”none” stroke=”rgb(56,56,56)” stroke-width=”1″ stroke-opacity=”0.5″></rect><rect id=”rect1″ x=”8″ y=”8″ width=”844″ height=”644″ fill=”none” stroke=”rgb(64,64,64)” stroke-width=”1″ stroke-opacity=”0.5″></rect><rect id=”rect1″ x=”9″ y=”9″ width=”842″ height=”642″ fill=”none” stroke=”rgb(72,72,72)” stroke-width=”1″ stroke-opacity=”0.5″></rect><rect id=”rect1″ x=”10″ y=”10″ width=”840″ height=”640″ fill=”none” stroke=”rgb(80,80,80)” stroke-width=”1″ stroke-opacity=”0.5″></rect><rect id=”rect1″ x=”11″ y=”11″ width=”838″ height=”638″ fill=”none” stroke=”rgb(88,88,88)” stroke-width=”1″ stroke-opacity=”0.5″></rect><rect id=”rect1″ x=”12″ y=”12″ width=”836″ height=”636″ fill=”none” stroke=”rgb(96,96,96)” stroke-width=”1″ stroke-opacity=”0.5″></rect><rect id=”rect1″ x=”13″ y=”13″ width=”834″ height=”634″ fill=”none” stroke=”rgb(104,104,104)” stroke-width=”1″ stroke-opacity=”0.5″></rect><rect id=”rect1″ x=”14″ y=”14″ width=”832″ height=”632″ fill=”none” stroke=”rgb(112,112,112)” stroke-width=”1″ stroke-opacity=”0.5″></rect><rect id=”rect1″ x=”15″ y=”15″ width=”830″ height=”630″ fill=”none” stroke=”rgb(120,120,120)” stroke-width=”1″ stroke-opacity=”0.5″></rect><rect id=”rect1″ x=”16″ y=”16″ width=”828″ height=”628″ fill=”none” stroke=”rgb(128,128,128)” stroke-width=”1″ stroke-opacity=”0.5″></rect><rect id=”rect1″ x=”17″ y=”17″ width=”826″ height=”626″ fill=”none” stroke=”rgb(136,136,136)” stroke-width=”1″ stroke-opacity=”0.5″></rect><rect id=”rect1″ x=”18″ y=”18″ width=”824″ height=”624″ fill=”none” stroke=”rgb(144,144,144)” stroke-width=”1″ stroke-opacity=”0.5″></rect><rect id=”rect1″ x=”19″ y=”19″ width=”822″ height=”622″ fill=”none” stroke=”rgb(152,152,152)” stroke-width=”1″ stroke-opacity=”0.5″></rect><rect id=”rect1″ x=”20″ y=”20″ width=”820″ height=”620″ fill=”none” stroke=”rgb(160,160,160)” stroke-width=”1″ stroke-opacity=”0.5″></rect><rect id=”rect1″ x=”21″ y=”21″ width=”818″ height=”618″ fill=”none” stroke=”rgb(168,168,168)” stroke-width=”1″ stroke-opacity=”0.5″></rect><rect id=”rect1″ x=”22″ y=”22″ width=”816″ height=”616″ fill=”none” stroke=”rgb(176,176,176)” stroke-width=”1″ stroke-opacity=”0.5″></rect><rect id=”rect1″ x=”23″ y=”23″ width=”814″ height=”614″ fill=”none” stroke=”rgb(184,184,184)” stroke-width=”1″ stroke-opacity=”0.5″></rect><rect id=”rect1″ x=”24″ y=”24″ width=”812″ height=”612″ fill=”none” stroke=”rgb(192,192,192)” stroke-width=”1″ stroke-opacity=”0.5″></rect><rect id=”rect1″ x=”25″ y=”25″ width=”810″ height=”610″ fill=”none” stroke=”rgb(200,200,200)” stroke-width=”1″ stroke-opacity=”0.5″></rect><rect id=”rect1″ x=”26″ y=”26″ width=”808″ height=”608″ fill=”none” stroke=”rgb(208,208,208)” stroke-width=”1″ stroke-opacity=”0.5″></rect><rect id=”rect1″ x=”27″ y=”27″ width=”806″ height=”606″ fill=”none” stroke=”rgb(216,216,216)” stroke-width=”1″ stroke-opacity=”0.6″></rect><rect id=”rect1″ x=”28″ y=”28″ width=”804″ height=”604″ fill=”none” stroke=”rgb(224,224,224)” stroke-width=”1″ stroke-opacity=”0.6″></rect><rect id=”rect1″ x=”29″ y=”29″ width=”802″ height=”602″ fill=”none” stroke=”rgb(232,232,232)” stroke-width=”1″ stroke-opacity=”0.6″></rect> </svg> <script>
var paus = true; var ctrl = true; document.getElementById(“img1”).volume = .5;
for (var i = 0; i <= 20; i ++) {
if (i == 0) document.getElementById(“vol”).innerHTML = “<option>Choose Volume</option>”;
if (i > 0) document.getElementById(“vol”).innerHTML += “<option>” + (.05 * i).toFixed(2) + “</option>”;
}
function ctl() {
if (ctrl) {
document.getElementById(“svg1”).style.visibility = “hidden”;
document.getElementById(“svg2”).style.visibility = “hidden”;
ctrl = false;
} else {
document.getElementById(“svg1”).style.visibility = “visible”;
document.getElementById(“svg2”).style.visibility = “visible”;
ctrl = true;
}
}
function ps() {
if (paus) {
document.getElementById(“img1”).play();
paus=false;
} else {
document.getElementById(“img1”).pause();
paus = true;
}
}
</script>
</html>
The string that creates that file is the following:
var savstr = ‘<html> <input type=”button” id=”b4″ name=”b4″ style=”position: absolute; left: 1010px” value=”Pause/Play” onclick=”ps();” /> <input type=”button” id=”b5″ name=”b5″ style=”position: absolute; left: 1100px” value=”Controls On/Off” onclick=”ctl();”/> <select id=”vol” size=”22″ style=”position: absolute; left: 1010px; top: 40px” onchange=\’vlm();\’></select><dlv id=”frame” style=”position: absolute; left: 10px; top: 10px; width:’ + (wd2 + 60) + ‘px; height:’ + (ht2 + 60) + ‘px; background: #771111″ >’ + document.getElementById(“frame”).innerHTML + ‘ </div> <svg id=”svg1″ style=”position: absolute; left: 30px; top: 30px; width:’ + (wd2) + ‘px; height:’ + (ht2) + ‘px” >’ + document.getElementById(“svg1″).innerHTML + ‘ </svg> <svg id=”svg2″ style=”position: absolute; left: 0; top: 0; width:’ + (wd2 + 60) + ‘px; height:’ + (ht2 + 60) + ‘px” >’ + document.getElementById(“svg2”).innerHTML + ‘ </svg> <script>\nvar paus = true; var ctrl = true; document.getElementById(“img1”).volume = .5;\nfor (var i = 0; i <= 20; i ++) {\nif (i == 0) document.getElementById(“vol”).innerHTML = “<option>Choose Volume</option>”;\nif (i > 0) document.getElementById(“vol”).innerHTML += “<option>” + (.05 * i).toFixed(2) + “</option>”;\n}\nfunction ctl() {\nif (ctrl) {\ndocument.getElementById(“svg1”).style.visibility = “hidden”;\ndocument.getElementById(“svg2”).style.visibility = “hidden”;\nctrl = false;\n } else {\ndocument.getElementById(“svg1”).style.visibility = “visible”;\ndocument.getElementById(“svg2”).style.visibility = “visible”;\nctrl = true;\n}\n}\n function ps() {\nif (paus) {\ndocument.getElementById(“img1”).play();\npaus=false;\n} else {\ndocument.getElementById(“img1”).pause();\npaus = true;\n}\n}\nfunction vlm() {\ndocument.getElementById(“img1”).volume = parseFloat(document.getElementById(“vol”).value);\n}\n<\/script>\n </html>’;
Another thing I want to discuss is the sizing, which is different for portrait or landscape images or wide videos, and also if the width is more than 1.5 times the height, created in the function drw().
For videos and wider images:
if (img1.clientWidth / img1.clientHeight >= 1.5) {
if (document.getElementById(“frame”).innerHTML.indexOf(“vid”) > -1) {
document.getElementById(“vid”).style.width = “900px”;
document.getElementById(“vid”).style.height = 900 * (ht/wd) + “px”;
} else if (document.getElementById(“frame”).innerHTML.indexOf(“vid”) == -1) {
document.getElementById(“img1”).style.width = “900px”;
document.getElementById(“img1”).style.height = 900 * (ht/wd) + “px”;
}
}
For landscape images:
else if (img1.clientWidth >img1.clientHeight) {
if (document.getElementById(“frame”).innerHTML.indexOf(“vid”) > -1) {
document.getElementById(“vid”).style.width = “800px”;
document.getElementById(“vid”).style.height = 800 * (ht/wd) + “px”;
} else if (document.getElementById(“frame”).innerHTML.indexOf(“vid”) == -1) {
document.getElementById(“img1”).style.width = “800px”;
document.getElementById(“img1”).style.height = 800 * (ht/wd) + “px”;
}
For portrait images and narrow videos:
else if (fname.indexOf(“svg”) == -1) {
if (document.getElementById(“frame”).innerHTML.indexOf(“vid”) > -1) {
document.getElementById(“vid”).style.height = “600px”;
document.getElementById(“vid”).style.width = 600 * (wd/ht) + “px”;
} else if (document.getElementById(“frame”).innerHTML.indexOf(“vid”) == -1) {
document.getElementById(“img1”).style.height = “600px”;
document.getElementById(“img1”).style.width = 600 * (wd/ht) + “px”;
}
}
The frame and svg element are set wider and higher than the image by 30 pixels on each side:
document.getElementById(“frame”).style.height = (ht2 + 60) + “px”;
document.getElementById(“frame”).style.width = (wd2 + 60) + “px”;
document.getElementById(“svg2”).style.height = (ht2 + 60) + “px”;
document.getElementById(“svg2”).style.width = (wd2 + 60) + “px”;
Finally, the video is equipped with a control, but it is inaccessible due to being covered by the svg. Therefore, the is a button that temporarily hides the svg so the control can be used:
function ctl() {
if (ctrl) {
document.getElementById(“svg1”).style.visibility = “hidden”;
document.getElementById(“svg2”).style.visibility = “hidden”;
ctrl = false;
} else {
document.getElementById(“svg1”).style.visibility = “visible”;
document.getElementById(“svg2”).style.visibility = “visible”;
ctrl = true;
}
}