google chrome - Why do my svg look so bad? -


my svg looks bad in google chrome , firefox too, svg borders have poor quality:

enter image description here

meanwhile, in illustrator svg looks awesome:

enter image description here

i have saved .svg file configuration:

enter image description here

what happened?

if svg has lot of horizontal and/or vertical lines, can improve appearance aligning coordinates pixel grid. i'll give example:

effects of pixel alignment in svgs

here 3 svg images made of rounded rectangles. (the source code these images pasted below.)

  • in (a), rectangle coordinates aren't aligned pixel grid @ all. result, of lines clear , sharp while others fuzzy , bit darker.

  • in (b), rectangle coordinates snapped integer values, giving them uniform appearance. however, fuzzy now, because antialiasing spreads each line across width of 2 pixels.

  • in (c), coordinates snapped integer values and given additional offset of 0.5 pixels in x , y directions. should able see definite improvement here.

if you're working in illustrator, try viewing artwork @ 100% in "pixel preview" mode.

i recommend not using stroke widths smaller 1 pixel. if want simulate thinner lines, try reducing opacity instead.

<svg width="200" height="150" viewbox="0 0 200 150">    <!-- (original drawing) -->    <rect x="0" y="0" width="200" height="150" fill="#47f" stroke="none" />    <g fill="none" stroke="#fff" stroke-width="1.2">      <rect x="20.1" y="20.1" width="160" height="110" rx="50" ry="50"/>      <rect x="25.3071" y="25.3071" width="149.5857" height="99.5857" rx="44.7929" ry="44.7929"/>      <rect x="30.5143" y="30.5143" width="139.1714" height="89.1714" rx="39.5857" ry="39.5857"/>      <rect x="35.7215" y="35.7215" width="128.7571" height="78.7571" rx="34.3785" ry="34.3785"/>      <rect x="40.9286" y="40.9286" width="118.3428" height="68.3428" rx="29.1714" ry="29.1714"/>    </g>    <text x="100" y="80" text-anchor="middle" font-family="sans-serif" font-size="20" fill="#fff">(a)</text>  </svg>  <svg width="200" height="150" viewbox="0 0 200 150">    <!-- (lines snapped integer coordinates) -->    <rect x="0" y="0" width="200" height="150" fill="#47f" stroke="none" />    <g fill="none" stroke="#fff" stroke-width="1.2">      <rect x="20" y="20" width="160" height="110" rx="50" ry="50"/>      <rect x="25" y="25" width="150" height="100" rx="45" ry="45"/>      <rect x="30" y="30" width="140" height="90" rx="40" ry="40"/>      <rect x="35" y="35" width="130" height="80" rx="35" ry="35"/>      <rect x="40" y="40" width="120" height="70" rx="30" ry="30"/>    </g>    <text x="100" y="80" text-anchor="middle" font-family="sans-serif" font-size="20" fill="#fff">(b)</text>  </svg>  <svg width="200" height="150" viewbox="0 0 200 150">    <text x="100" y="80" text-anchor="middle" font-family="sans-serif" font-size="20" fill="#fff">(a)</text>    <!-- (lines snapped integer coordinates 0.5px offset) -->    <rect x="0" y="0" width="200" height="150" fill="#47f" stroke="none" />    <g fill="none" stroke="#fff" stroke-width="1.2">      <rect x="20.5" y="20.5" width="160" height="110" rx="50" ry="50"/>      <rect x="25.5" y="25.5" width="150" height="100" rx="45" ry="45"/>      <rect x="30.5" y="30.5" width="140" height="90" rx="40" ry="40"/>      <rect x="35.5" y="35.5" width="130" height="80" rx="35" ry="35"/>      <rect x="40.5" y="40.5" width="120" height="70" rx="30" ry="30"/>    </g>    <text x="100" y="80" text-anchor="middle" font-family="sans-serif" font-size="20" fill="#fff">(c)</text>  </svg>


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -