At 09:57 AM 4/27/2007, you wrote: >We create SVG base on database using C++. Polygon may be filled with >patterns. There are around 20 predefined patterns. All the patterns >only have one color but that color can be different from polygon to >polygon (e.g. Polgon1 may have pattern1 in red but polygon2 may have >the same pattern in green). Some of the patterns are complex. All are >8x8. A patterns may look like this: > >1 0 1 0 1 0 1 0 >0 1 0 1 0 1 0 1 >1 0 1 0 1 0 1 0 >0 1 0 1 0 0 0 1 >1 0 1 0 1 0 1 0 >0 1 0 1 0 1 0 1 >1 0 1 0 1 0 1 0 >0 0 0 1 0 1 0 1 > >Where 1s show where the color should show. I can create the pattern >using one rectangle around each 1 or combine rectangle when possible. > >My question is if there is better was to do? Thanks.
Take a look at the following and see if that helps any. cheers, David Dailey <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" onload="start(evt)"> <script><![CDATA[ var xmlns='http://www.w3.org/2000/svg'; xlinkns='http://www.w3.org/1999/xlink'; D=document var count=0 function start(evt){ var cw=9 //pattern cellwidth var C=document.getElementById("simplecell") var Pat=document.getElementById("OP") Root=D.documentElement var T=D.getElementById("T") Lines=T.firstChild.nodeValue.split("\n") var r=Colors[count++%Colors.length] for (var i in Lines){ Data=Lines[i].split(" ") for (var j in Data){ if (Data[j]==1) { var Q=C.cloneNode("false") Q.setAttributeNS(null,"fill",r) Q.setAttributeNS(null,"x",j*cw) Q.setAttributeNS(null,"y",i*cw) Pat.appendChild(Q) } } } } var Colors=new Array("#faa","#faf","#8af","#aff","#bf9","#a8f","#fa8") //]]> </script> <pattern id="OP" patternUnits="userSpaceOnUse" x="0" y="0" width="72" height="72" > </pattern> <rect id="simplecell" x="0" y="0" width="9" height="9"/> <rect id="Canvas" x="0%" y="0%" width="100%" height="100%" fill="url(#OP)"/> <g onclick="start(evt)"> <rect x="190" y="5" width="250" height="60" fill="lightgrey"/> <text x="200" y="50" font-size="50" fill="#622" font-weight="bold">CHANGE</text> </g> <text id="T" visibility="hidden">1 0 1 0 1 0 1 0 0 1 0 1 0 1 0 1 1 0 1 0 1 0 1 0 0 1 0 1 0 0 0 1 1 0 1 0 1 0 1 0 0 1 0 1 0 1 0 1 1 0 1 0 1 0 1 0 0 0 0 1 0 1 0 1</text> </svg> ----- To unsubscribe send a message to: [EMAIL PROTECTED] -or- visit http://groups.yahoo.com/group/svg-developers and click "edit my membership" ---- Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/svg-developers/ <*> Your email settings: Individual Email | Traditional <*> To change settings online go to: http://groups.yahoo.com/group/svg-developers/join (Yahoo! ID required) <*> To change settings via email: mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/

