Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?xml version="1.0" standalone="no"?>
- <svg xmlns="http://www.w3.org/2000/svg"
- xmlns:xlink="http://www.w3.org/1999/xlink"
- version="1.1" baseProfile="full" onload="init()" >
- <defs>
- <filter id="fDropShadow" x="0" y="0" width="200%" height="200%">
- <feOffset result="offOut" in="SourceGraphic" dx="20" dy="20" />
- <feColorMatrix result = "matrixOut" in = "offOut" type = "matrix" values = "0.2 0 0 0 0 0 0.2 0 0 0 0 0 0.2 0 0 0 0 0 1 0"/>
- <feGaussianBlur result="blurOut" in="matrixOut" stdDeviation="10" />
- <feBlend in="SourceGraphic" in2="blurOut" mode="normal" />
- </filter>
- <g id="tvFace" >
- <path fill="#D8D8D8" stroke="#000000" stroke-miterlimit="10" d="M84,143.689c0,0-23.798,4.178-30.129,27.415 c-5.371,19.711,16.142-19.703,52.334-18.951c36.192,0.75,52.795-3.837,79.795,12.412c27,16.25-1.25-31.103-21.5-27.175 C144.25,141.316,84,143.689,84,143.689z"/>
- <path fill="#D8D8D8" stroke="#000000" stroke-miterlimit="10" d="M45.924,88.232c0,0,9.039,2.68,4.436,14.507 c0,0-19.909,11.993-21.74,35.493l4.168,7l-1.008,8l-4.992-1l1.165-4.833l-3.494,10.333l-7.155-1.541l1.166-4.791l-1.166,2.916 L1,148.815C1,148.815,10.858,90.398,45.924,88.232z"/>
- <path fill="#D8D8D8" stroke="#000000" stroke-miterlimit="10" d="M171,144.44c13.92-8.738,18.036-17.752,18.036-17.752 c1.875-17.125-9.286-76.373-9.286-76.373h-0.322c0,0-41.125-17.041-123.125,6.229L39.949,70.065c0,0-1.95,48.167,11.217,82 C51.167,152.064,116.25,164.814,171,144.44"/>
- <ellipse transform="matrix(-0.1096 -0.994 0.994 -0.1096 -16.5655 157.7639)" stroke="#000000" stroke-miterlimit="10" cx="62.381" cy="86.302" rx="8.624" ry="4.438"/>
- <ellipse transform="matrix(-0.1096 -0.994 0.994 -0.1096 73.8318 225.4342)" stroke="#000000" stroke-miterlimit="10" cx="137.892" cy="79.646" rx="8.624" ry="4.437"/>
- <path stroke="#000000" stroke-miterlimit="10" d="M62.375,109.19c0,0,80.625-6.25,87-11.813c0,0,12.375,33.313,0,35.313 s-80.125,8-80.125,8S87.625,124.19,62.375,109.19z"/>
- <polygon fill="#FFFFFF" stroke="#000000" stroke-miterlimit="10" points="62.875,109.601 72.998,121.565 80.098,108.02 "/>
- <polygon fill="#FFFFFF" stroke="#000000" stroke-miterlimit="10" points="80.625,108.164 90.748,120.128 97.848,106.583 "/>
- <polygon fill="#FFFFFF" stroke="#000000" stroke-miterlimit="10" points="97.635,106.409 108.257,117.932 114.775,104.098 "/>
- <polygon fill="#FFFFFF" stroke="#000000" stroke-miterlimit="10" points="115.242,104.431 125.973,115.852 132.359,101.957 "/>
- <polygon fill="#FFFFFF" stroke="#000000" stroke-miterlimit="10" points="132.193,101.822 143.497,112.678 149.16,98.473 "/>
- <path fill="none" stroke="#000000" stroke-miterlimit="10" d="M39.848,70.223c0,0,62.673-20.45,124.652-8.992 c0,0,9.095,64.809,9.015,73.159c-0.013,1.329,0.44,8.731-1.359,9.299"/>
- <line fill="none" stroke="#000000" stroke-miterlimit="10" x1="179.75" y1="50.315" x2="164.5" y2="61.232"/>
- <path fill="none" stroke="#000000" stroke-miterlimit="10" d="M128.5,50.315c0,0,6.584-40.583,39.584-48.083 s22.833,21.334,16.333,30.167"/>
- <circle fill="#FFFFFF" stroke="#000000" stroke-miterlimit="10" cx="183.751" cy="34.732" r="4.833"/>
- <path fill="none" stroke="#000000" stroke-miterlimit="10" d="M78.167,55.773c0,0,3.5-48.375-29.833-40.708 c0,0-17.167,5.167-23.333,24.5"/>
- <circle fill="#FFFFFF" stroke="#000000" stroke-miterlimit="10" cx="25" cy="41.232" r="4.333"/>
- <path fill="#D8D8D8" stroke="#000000" stroke-miterlimit="10" d="M178,72.732c0,0-9.054,2.68-4.443,14.507 c0,0,19.942,11.993,21.776,35.493l-4.176,7l1.01,8l5-1L196,131.898l3.5,10.333l7.167-1.542l-1.167-4.792l1.167,2.917l16.333-5.5 C223,133.315,213.125,74.898,178,72.732z"/>
- <path fill="#F16465" stroke="#000000" stroke-miterlimit="10" d="M120,121.565c0,0-46-5.713-49.664,19.027l43.931-4.11L120,121.565 z"/>
- <path fill="#F16465" stroke="#000000" stroke-miterlimit="10" d="M100.065,137.812c0,0,47.888-4.708,49.31-5.122 c0,0,1.545-0.218,3.929-2.641c0,0,1.143-2.052,1.338-4.017c0,0,0.293-3.824,0.171-5.409c-0.123-1.585-0.342-3.455-0.342-3.455 l-0.466-2.946c0,0-45.379-3.208-53.004,18.842"/>
- <ellipse transform="matrix(-0.3957 0.9184 -0.9184 -0.3957 213.9308 57.6762)" stroke="#000000" stroke-miterlimit="10" cx="87.99" cy="99.219" rx="2.451" ry="0.625"/>
- <ellipse transform="matrix(0.5446 0.8387 -0.8387 0.5446 130.1501 -45.7421)" stroke="#000000" stroke-miterlimit="10" cx="107.194" cy="96.97" rx="2.451" ry="0.625"/>
- </g>
- <g id='buttons'>
- <rect id="xkcd" x='0px' y='0px' width='200px' height='50px' fill='#AAAAAA' stroke='#D8D8D8' stroke-width='2px' >
- <animate attributeName='fill' from='#ffffff' to='#cccccc' dur='0.3s' begin='xkcd.mouseover' fill='freeze'/>
- <animate attributeName='fill' from='#cccccc' to='#aaaaaa' dur='0.3s' begin='xkcd.mouseout' fill='freeze'/>
- </rect>
- <a target="_blank" xlink:href="http://www.xkcd.com" >
- <text x="60px" y="32px" font-size='25'>
- XKCD
- </text>
- </a>
- <rect id='moarCircles' x='400px' y='0px' width='200px' height='50px' fill='#aaaaaa' stroke='#D8D8D8' stroke-width='2px' onclick='circleGenerator(1)'>
- <animate attributeName='fill' from='#ffffff' to='#cccccc' dur='0.3s' begin='moarCircles.mouseover' fill='freeze'/>
- <animate attributeName='fill' from='#cccccc' to='#aaaaaa' dur='0.3s' begin='moarCircles.mouseout' fill='freeze'/>
- </rect>
- <text x="410px" y="32px" font-size='25' onclick='circleGenerator(1)'>
- Click for circles!
- </text>
- </g>
- <style type="text/css">
- <![CDATA[
- text{
- fill:black;
- font-family:sans-serif;
- }
- #tvFace{
- overflow:visible;
- }
- ]]>
- </style>
- </defs>
- <script type="text/javascript">
- <![CDATA[
- var svgns="http://www.w3.org/2000/svg";
- var xlinkns="http://www.w3.org/1999/xlink";
- function softColorGen(){
- var rgbArray=new Array();
- for(j=0;j<3;j++){
- rgbArray[j]=Math.ceil(Math.random()*85)+170;
- }
- return 'rgb('+rgbArray.toString()+')';
- }
- function circleCreator(numOfCircles){
- var cirArry = new Array();
- for(i=0;i<numOfCircles;i++){
- var whichSide=Math.round(Math.random());
- var cirEle = document.createElementNS(svgns,'circle');
- var randRad = (Math.random()*90)+10;
- cirEle.setAttributeNS(null,'r',randRad+'px');
- if(whichSide==0){
- cirEle.setAttributeNS(null,'cx','0%');
- }else{
- cirEle.setAttributeNS(null,'cx','100%');
- }
- cirEle.setAttributeNS(null,'cy',Math.random()*100+'%');
- cirEle.setAttributeNS(null,'fill','none');
- cirEle.setAttributeNS(null,'stroke',softColorGen()+'');
- cirEle.setAttributeNS(null,'stroke-width',Math.random()*10+5);
- var animEle = document.createElementNS(svgns,'animate');
- animEle.setAttributeNS(null,'attributeName','cx');
- if(whichSide == 0){
- animEle.setAttributeNS(null,'from','-'+randRad+20+'px');
- animEle.setAttributeNS(null,'to','110%');
- }else{
- animEle.setAttributeNS(null,'from','110%');
- animEle.setAttributeNS(null,'to','-'+randRad+20+'px');
- }
- animEle.setAttributeNS(null,'dur',Math.random()*17+3+'s');
- animEle.setAttributeNS(null,'repeatCount','indefinite');
- animEle.setAttributeNS(null,'begin','indefinite');
- cirEle.appendChild(animEle);
- var defsEle = document.createElementNS(svgns,'defs');
- var filterEle = document.createElementNS(svgns,'filter');
- filterEle.setAttributeNS(null,'id','filter'+i);
- filterEle.setAttributeNS(null,'x','-75%');
- filterEle.setAttributeNS(null,'y','-75%');
- filterEle.setAttributeNS(null,'width','400%');
- filterEle.setAttributeNS(null,'height','400%');
- var fgbEle=document.createElementNS(svgns,'feGaussianBlur');
- fgbEle.setAttributeNS(null,'in','SourceGraphic');
- fgbEle.setAttributeNS(null,'stdDeviation','' + Math.floor(((randRad*(-1.0)+100)/10.0)));
- filterEle.appendChild(fgbEle);
- defsEle.appendChild(filterEle);
- document.getElementsByTagName('svg')[0].appendChild(defsEle);
- cirEle.setAttributeNS(null,'filter','url(#filter'+i+')');
- cirArry[i]=cirEle;
- }
- return cirArry;
- }
- function circleGenerator(numOfCircles){
- var cirArray = new Array();
- cirArray = circleCreator(numOfCircles);
- var swapOccurred;
- do{
- swapOccurred=false;
- for(i=0;i<cirArray.length-1;i++){
- var cur=parseFloat(cirArray[i].r.baseVal.value);
- var next=parseFloat(cirArray[i+1].r.baseVal.value);
- if(cur>next){
- var cirEleTemp = cirArray[i];
- cirArray[i]=cirArray[i+1];
- cirArray[i+1]=cirEleTemp;
- swapOccurred=true;
- }
- }
- }while(swapOccurred);
- for(i=0;i<cirArray.length;i++){
- document.getElementsByTagName('svg')[0].appendChild(cirArray[i]);
- var lastAnim=document.getElementsByTagName('animate').length-1;
- console.log(document.getElementsByTagName('animate')[lastAnim]);
- document.getElementsByTagName('animate')[lastAnim].beginElement();
- }
- }
- function makeContent(){
- var useEle = document.createElementNS(svgns,'use');
- useEle.setAttributeNS(null,'x','200');
- useEle.setAttributeNS(null,'y','200');
- useEle.setAttribute('xlink:href','#tvFace');
- document.getElementsByTagName('svg')[0].appendChild(useEle);
- }
- function generatePage(){
- circleGenerator(7);
- //creates rect for the content to be placed on and a dropshadow is applied.
- var rect1Ele = document.createElementNS(svgns,'rect');
- rect1Ele.setAttributeNS(null,'x','10%');
- rect1Ele.setAttributeNS(null,'y','10%');
- rect1Ele.setAttributeNS(null,'rx','20');
- rect1Ele.setAttributeNS(null,'ry','20');
- rect1Ele.setAttributeNS(null,'width','80%');
- rect1Ele.setAttributeNS(null,'height','80%');
- rect1Ele.setAttributeNS(null,'fill','white');
- rect1Ele.setAttributeNS(null,'stroke-width','2px');
- rect1Ele.setAttributeNS(null,'filter','url(#fDropShadow)');
- document.getElementsByTagName('svg')[0].appendChild(rect1Ele);
- //another rectangle identical to the first is made but without a dropdshadow. this was done due to rendering issues with the dropshadow.
- var rect2Ele = document.createElementNS(svgns,'rect');
- rect2Ele.setAttributeNS(null,'x','10%');
- rect2Ele.setAttributeNS(null,'y','10%');
- rect2Ele.setAttributeNS(null,'rx','20');
- rect2Ele.setAttributeNS(null,'ry','20');
- rect2Ele.setAttributeNS(null,'width','80%');
- rect2Ele.setAttributeNS(null,'height','80%');
- rect2Ele.setAttributeNS(null,'fill','white');
- rect2Ele.setAttributeNS(null,'stroke-width','2px');
- rect2Ele.setAttributeNS(null,'stroke','#d8d8d8');
- document.getElementsByTagName('svg')[0].appendChild(rect2Ele);
- //creates <text>s
- var text1Ele = document.createElementNS(svgns,'text')
- text1Ele.setAttributeNS(null,'x','40%');
- text1Ele.setAttributeNS(null,'y','20%');
- text1Ele.setAttributeNS(null,'width','60%');
- text1Ele.setAttributeNS(null,'font-size','25');
- var textNode1 = document.createTextNode("This Could Have Been an Interesting Title");
- text1Ele.appendChild(textNode1);
- document.getElementsByTagName('svg')[0].appendChild(text1Ele);
- var rect3Ele = document.createElementNS(svgns,'rect');
- rect3Ele.setAttributeNS(null,'x','10%');
- rect3Ele.setAttributeNS(null,'y','30%');
- rect3Ele.setAttributeNS(null,'width','80%');
- rect3Ele.setAttributeNS(null,'height','10%');
- rect3Ele.setAttributeNS(null,'fill','white');
- rect3Ele.setAttributeNS(null,'stroke-width','2px');
- rect3Ele.setAttributeNS(null,'stroke','#d8d8d8');
- document.getElementsByTagName('svg')[0].appendChild(rect3Ele);
- var svg2Ele = document.createElementNS(svgns, 'svg');
- //<svg xmlns="http://www.w3.org/2000/svg" reserveAspectRatio="xMidYMid meet" viewBox="0 0 402 52" width="100%" height="10%">
- //svg2Ele.setAttributeNS(null,'reserveAspectRatio','xMidYMax meet');
- svg2Ele.setAttributeNS(null,'viewBox','0 0 602 52');
- svg2Ele.setAttributeNS(null,'width','80%');
- svg2Ele.setAttributeNS(null,'height','10%');
- svg2Ele.setAttributeNS(null,'y','30%');
- svg2Ele.setAttributeNS(null,'x','10%')
- var use1Ele = document.createElementNS(svgns,'use');
- use1Ele.setAttributeNS(null,'x','0');
- use1Ele.setAttributeNS(null,'y','0');
- use1Ele.setAttributeNS(xlinkns,'xlink:href','#buttons');
- svg2Ele.appendChild(use1Ele);
- document.getElementsByTagName('svg')[0].appendChild(svg2Ele);
- var switchEle = document.createElementNS(svgns,'switch');
- var forObjEle = document.createElementNS(svgns,'foreignObject');
- forObjEle.setAttributeNS(null,'x','20%');
- forObjEle.setAttributeNS(null,'y','50%');
- forObjEle.setAttributeNS(null,'width','60%');
- forObjEle.setAttributeNS(null,'height','30%');
- var bodyEle = document.createElementNS(svgns,'body');
- bodyEle.setAttributeNS(null,'xmlns','http://www.w3.org/1999/xhtml');
- var divEle = document.createElementNS(svgns,'div');
- var text2Ele = document.createTextNode("I couldn't really think of actual content so I decided to focus on learning some things about SVG and getting some experience with it.");
- divEle.appendChild(text2Ele);
- bodyEle.appendChild(divEle);
- forObjEle.appendChild(bodyEle);
- document.getElementsByTagName('svg')[0].appendChild(forObjEle);
- document.getElementsByTagName('foreignObject')[0].removeAttributeNS(null,'xmlns');
- //the tv creature is displayed
- var svgEle=document.createElementNS(svgns,'svg');
- svgEle.setAttributeNS(null,'reserveAspectRatio','xMaxYMin meet');
- svgEle.setAttributeNS(null,'viewBox','0 0 224 197');
- svgEle.setAttributeNS(null,'x','80%');
- svgEle.setAttributeNS(null,'y','11%');
- svgEle.setAttributeNS(null,'width','10%');
- svgEle.setAttributeNS(null,'height','20%');
- var use2Ele = document.createElementNS(svgns,'use');
- use2Ele.setAttributeNS(null,'x','0');
- use2Ele.setAttributeNS(null,'y','0');
- use2Ele.setAttributeNS(xlinkns,'xlink:href','#tvFace');
- svgEle.appendChild(use2Ele);
- document.getElementsByTagName('svg')[0].appendChild(svgEle);
- }
- function init(){
- generatePage();
- }
- ]]>
- </script>
- </svg>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement