SVG Share Code



  • Re: Share Code

    <svg onload='go()' viewBox='0 0 600 600' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'>
    
    <rect x='0' y='0' width='600' height='600' fill='white' stroke='black' stroke-width='1' onclick='go()' />
    
    <script><![CDATA[
    // onload='go()' onclick='go()' function go(){}
    
    x = 300
    y = 300
    colors = 'red yellow blue lime purple cyan fuchsia orange navy green hotpink cornflowerblue teal pink lawngreen'
    color  = colors.split(' ')
    
    function go(){
    for (i=0;i<3;i++)                     // number of times
    {
    for (j=0;j<1000;j+=2)                  // radial lines
    {
    c=Math.PI*j/180
    a=x+Math.cos(c*c*j)*290               // controls width
    b=y+Math.sin(c)*290                   // controls height
    l = document.createElementNS('http://www.w3.org/2000/svg','line')   
    l.setAttribute('x1',x)
    l.setAttribute('y1',y)
    l.setAttribute('x2',a)
    l.setAttribute('y2',b)
    cola = Math.floor(Math.random()*color.length)
    l.setAttribute('stroke',color[cola])
    l.setAttribute('stroke-width',2)
    l.setAttribute('stroke-linecap','round')
    document.documentElement.appendChild(l)
    }}
    }
    ]]></script>
    </svg>
    




  • @MoonDawg Second line "rect" set up for onclick to change color.


Log in to reply
 

Looks like your connection to Vivaldi Forum was lost, please wait while we try to reconnect.