SVG gaps when transform used

Started by
0 comments, last by hybrid_ham 11 years, 4 months ago
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.

[attachment=12544: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 tongue.png
[source lang="php"]echo '<path id="donda_across" d="
M 0 0 L 1000 0
M 0 10 L 1000 10
M 0 20 L 1000 20
M 0 30 L 1000 30
M 0 40 L 1000 40
M 0 50 L 1000 50
M 0 60 L 1000 60
M 0 70 L 1000 70
M 0 80 L 1000 80
M 0 90 L 1000 90
M 0 100 L 1000 100
M 0 110 L 1000 110
M 0 120 L 1000 120
M 0 130 L 1000 130
M 0 140 L 1000 140
M 0 150 L 1000 150
M 0 160 L 1000 160
M 0 170 L 1000 170
M 0 180 L 1000 180
M 0 190 L 1000 190
M 0 200 L 1000 200
M 0 210 L 1000 210
M 0 220 L 1000 220
M 0 230 L 1000 230
M 0 240 L 1000 240
M 0 250 L 1000 250
M 0 260 L 1000 260
M 0 270 L 1000 270
M 0 280 L 1000 280
M 0 290 L 1000 290
M 0 300 L 1000 300
M 0 310 L 1000 310
M 0 320 L 1000 320
M 0 330 L 1000 330
M 0 340 L 1000 340
M 0 350 L 1000 350
M 0 360 L 1000 360
M 0 370 L 1000 370
M 0 380 L 1000 380
M 0 390 L 1000 390
M 0 400 L 1000 400
M 0 410 L 1000 410
M 0 420 L 1000 420
M 0 430 L 1000 430
M 0 440 L 1000 440
M 0 450 L 1000 450
M 0 460 L 1000 460
M 0 470 L 1000 470
M 0 480 L 1000 480
M 0 490 L 1000 490
M 0 500 L 1000 500

M 0 0 L 0 1000
M 10 0 L 10 1000
M 20 0 L 20 1000
M 30 0 L 30 1000
M 40 0 L 40 1000
M 50 0 L 50 1000
M 60 0 L 60 1000
M 70 0 L 70 1000
M 80 0 L 80 1000
M 90 0 L 90 1000
M 100 0 L 100 1000
M 110 0 L 110 1000
M 120 0 L 120 1000
M 130 0 L 130 1000
M 140 0 L 140 1000
M 150 0 L 150 1000
M 160 0 L 160 1000
M 170 0 L 170 1000
M 180 0 L 180 1000
M 190 0 L 190 1000
M 200 0 L 200 1000
M 210 0 L 210 1000
M 220 0 L 220 1000
M 230 0 L 230 1000
M 240 0 L 240 1000
M 250 0 L 250 1000
M 260 0 L 260 1000
M 270 0 L 270 1000
M 280 0 L 280 1000
M 290 0 L 290 1000
M 300 0 L 300 1000
M 310 0 L 310 1000
M 320 0 L 320 1000
M 330 0 L 330 1000
M 340 0 L 340 1000
M 350 0 L 350 1000
M 360 0 L 360 1000
M 370 0 L 370 1000
M 380 0 L 380 1000
M 390 0 L 390 1000
M 400 0 L 400 1000
M 410 0 L 410 1000
M 420 0 L 420 1000
M 430 0 L 430 1000
M 440 0 L 440 1000
M 450 0 L 450 1000
M 460 0 L 460 1000
M 470 0 L 470 1000
M 480 0 L 480 1000
M 490 0 L 490 1000
M 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.
Advertisement
Hrm, no answers, guess SVG isn't a hot topic but it should be smile.png 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.

This topic is closed to new replies.

Advertisement