Jump to content

  • Log In with Google      Sign In   
  • Create Account


SVG gaps when transform used


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 hybrid_ham   Members   -  Reputation: 109

Like
0Likes
Like

Posted 01 December 2012 - 11:23 AM

Hello all! Lurker, first time poster. Web dev by trade, hobbyist programmer for fun, working on my first "real" game so everything is new.
I chose SVG for my graphics to advance my learning on that for web and because I'm comfortable with all the web languages. Since I know little about 3d programming and my math is "the suck" beyond trigonometry a 2d game seemed more my style, I can at least visualize it. What I have so far is just HTML 5, PHP, Javascript, and SVG. Those are what the screen you see is from, a web browser. Not a big fan of frameworks and all that so I expect all of this to stay core.

Looking for some insight or workarounds that anyone has noted for the SVG gaps that are wrecking my display. In this image, my lines are drawn in red at the 10 pixel points and the blue lines are my background showing through because there are some weird gaps happening in all browsers. The red lines I think aren't matching my 10px x 10px boxes because I have scaling on the object and those are paths but better to deal with the blue lines first. Is the standard just to overdraw everything and cover up the gaps or has someone found some better way of approaching it? It seems like drawing things larger than needed is just wasted computer work to me but it's all I can really come up with right now.

lines.png

Relative code that you might want to see that creates the lines.
[source lang="php"]// This is the view source generated by the PHP that you would see starting drawing on the top left then heading off to the right<g id="main_field_shell" transform="translate(220.0,0.0) scale(80.0,80.0)"><g id="main_field_innershell" transform="scale(1.0,0.45) rotate(45)" style="border:none; padding:0px; margin:0px;"><rect id="0.0" x="0" y="0" width="10" height="10" class="grey">title>0.0</title><desc>nowalk</desc></rect><rect id="1.0" x="9" y="0" width="10" height="10" class="white"><title>1.0</title><desc>nowalk</desc></rect><rect id="2.0" x="19" y="0" width="10" height="10" class="black"><title>2.0</title><desc>nowalk</desc></rect><rect id="3.0" x="29" y="0" width="10" height="10" class="pink"><title>3.0</title><desc>nowalk</desc></rect>... etc</g></g>[/source]

The lines for the red areas are instead drawn with a path in SVG and not generated in any real dynamic way yet, just some echos so that I can rip all this out later and put it into includes making it easy to comment out with a single line during testing. No one would want to see big red lines and markers anyway but me Posted Image
[source lang="php"]echo '<path id="donda_across" d="M 0 0 L 1000 0M 0 10 L 1000 10M 0 20 L 1000 20M 0 30 L 1000 30M 0 40 L 1000 40M 0 50 L 1000 50M 0 60 L 1000 60M 0 70 L 1000 70M 0 80 L 1000 80M 0 90 L 1000 90M 0 100 L 1000 100M 0 110 L 1000 110M 0 120 L 1000 120M 0 130 L 1000 130M 0 140 L 1000 140M 0 150 L 1000 150M 0 160 L 1000 160M 0 170 L 1000 170M 0 180 L 1000 180M 0 190 L 1000 190M 0 200 L 1000 200M 0 210 L 1000 210M 0 220 L 1000 220M 0 230 L 1000 230M 0 240 L 1000 240M 0 250 L 1000 250M 0 260 L 1000 260M 0 270 L 1000 270M 0 280 L 1000 280M 0 290 L 1000 290M 0 300 L 1000 300M 0 310 L 1000 310M 0 320 L 1000 320M 0 330 L 1000 330M 0 340 L 1000 340M 0 350 L 1000 350M 0 360 L 1000 360M 0 370 L 1000 370M 0 380 L 1000 380M 0 390 L 1000 390M 0 400 L 1000 400M 0 410 L 1000 410M 0 420 L 1000 420M 0 430 L 1000 430M 0 440 L 1000 440M 0 450 L 1000 450M 0 460 L 1000 460M 0 470 L 1000 470M 0 480 L 1000 480M 0 490 L 1000 490M 0 500 L 1000 500M 0 0 L 0 1000M 10 0 L 10 1000M 20 0 L 20 1000M 30 0 L 30 1000M 40 0 L 40 1000M 50 0 L 50 1000M 60 0 L 60 1000M 70 0 L 70 1000M 80 0 L 80 1000M 90 0 L 90 1000M 100 0 L 100 1000M 110 0 L 110 1000M 120 0 L 120 1000M 130 0 L 130 1000M 140 0 L 140 1000M 150 0 L 150 1000M 160 0 L 160 1000M 170 0 L 170 1000M 180 0 L 180 1000M 190 0 L 190 1000M 200 0 L 200 1000M 210 0 L 210 1000M 220 0 L 220 1000M 230 0 L 230 1000M 240 0 L 240 1000M 250 0 L 250 1000M 260 0 L 260 1000M 270 0 L 270 1000M 280 0 L 280 1000M 290 0 L 290 1000M 300 0 L 300 1000M 310 0 L 310 1000M 320 0 L 320 1000M 330 0 L 330 1000M 340 0 L 340 1000M 350 0 L 350 1000M 360 0 L 360 1000M 370 0 L 370 1000M 380 0 L 380 1000M 390 0 L 390 1000M 400 0 L 400 1000M 410 0 L 410 1000M 420 0 L 420 1000M 430 0 L 430 1000M 440 0 L 440 1000M 450 0 L 450 1000M 460 0 L 460 1000M 470 0 L 470 1000M 480 0 L 480 1000M 490 0 L 490 1000M 500 0 L 500 1000" ';echo 'stroke="#880000" fill-opacity="0" stroke-linecap="round" stroke-width="0.10">';[/source]

Oh, no remarks on the UI graphics needed, this is my testing, not a final version and the game is far from done.

Edited by hybrid_ham, 01 December 2012 - 11:40 AM.


Sponsor:

#2 hybrid_ham   Members   -  Reputation: 109

Like
0Likes
Like

Posted 02 December 2012 - 07:49 AM

Hrm, no answers, guess SVG isn't a hot topic but it should be Posted Image The future is calling ... dun dun dun.
I found the issue with the red lines. The moveto(M) lineto(L) were going from 0-10 and that is actually 11, doh.
I'm going to do the offset of 1px each direction since no one has any other ideas on the real problem, the blue lines.

Edited by hybrid_ham, 02 December 2012 - 08:03 AM.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS