Jump to content
Sign in to follow this  
Forssux

Import a png transform to svg

Recommended Posts

Hi There,

 

My favourite web based map creator (mapbox) changed from using png to svg.

Is there a script/function to read  1,2  or 4 pixel based color/form reader and transform this to squares/cirkels?

 

Or is there a way to create this halftone easily

 

Thanks in advance

 

halftone_40_medium.png

Share this post


Link to post
Share on other sites

See for example HalftonePro here. - Though you can also do your own patterns in AD and export them as SVG if needed. Or just build your own patterns directly in SVG code.

<svg xmlns="http://www.w3.org/2000/svg" width="200" height="200" viewBox="0 0 200 200">
  <defs>
    <linearGradient id="Gradient1">
      <stop offset="5%" stop-color="white"/>
      <stop offset="95%" stop-color="green"/>
    </linearGradient>
    <linearGradient id="Gradient2" x1="0" x2="0" y1="0" y2="1">
      <stop offset="5%" stop-color="black"/>
      <stop offset="95%" stop-color="green"/>
    </linearGradient>

    <pattern id="Pattern" x="0" y="0" width=".15" height=".15">
      <rect x="0" y="0" width="20" height="20" fill="green"/>
      <rect x="0" y="0" width="25" height="25" fill="url(#Gradient2)"/>
      <circle cx="25" cy="25" r="10" fill="url(#Gradient1)" fill-opacity="0.5"/>
    </pattern>
  </defs>

  <rect fill="url(#Pattern)" stroke="black" width="200" height="200"/>
</svg>

 


☛ Affinity Designer 1.8.3 ◆ Affinity Photo 1.8.3 ◆ OSX El Capitan

Share this post


Link to post
Share on other sites
6 hours ago, v_kyr said:

See for example HalftonePro here. - Though you can also do your own patterns in AD and export them as SVG if needed. Or just build your own patterns directly in SVG code.


<svg xmlns="http://www.w3.org/2000/svg" width="200" height="200" viewBox="0 0 200 200">
  <defs>
    <linearGradient id="Gradient1">
      <stop offset="5%" stop-color="white"/>
      <stop offset="95%" stop-color="green"/>
    </linearGradient>
    <linearGradient id="Gradient2" x1="0" x2="0" y1="0" y2="1">
      <stop offset="5%" stop-color="black"/>
      <stop offset="95%" stop-color="green"/>
    </linearGradient>

    <pattern id="Pattern" x="0" y="0" width=".15" height=".15">
      <rect x="0" y="0" width="20" height="20" fill="green"/>
      <rect x="0" y="0" width="25" height="25" fill="url(#Gradient2)"/>
      <circle cx="25" cy="25" r="10" fill="url(#Gradient1)" fill-opacity="0.5"/>
    </pattern>
  </defs>

  <rect fill="url(#Pattern)" stroke="black" width="200" height="200"/>
</svg>

 

 

 

Hi Thank you for the advice, I definitely have a look at the solutions you gave me.
The code you wrote didn't open in AD or in mapbox but I could see final result fine in chrome.

Pity it didn't resemble the file I included, but I certainly start messing around with the code itself

Kind Regards
Guy Forssman

Share this post


Link to post
Share on other sites

Sadly AD doesn't support the full SVG standard, but every browser (Firefox, Chrome etc.) mostly does. You can edit such things online to see immediately the results, see for example JSFiddle or CodePen.

pattern_sample.jpg.9ab1ddcc66f07cb8bdffed4ba287cff9.jpg

<svg xmlns="http://www.w3.org/2000/svg" width="200" height="200" viewBox="0 0 200 200">
  <defs>
    <pattern id="Pattern" x="0" y="0" width=".15" height=".15">
      <rect x="0" y="0" width="5" height="5" fill="#7CBF97"/>
      <rect x="5" y="0" width="5" height="5" fill="#DEDEDE"/>
      <rect x="10" y="0" width="5" height="5" fill="#B4D0C2"/>
      <rect x="15" y="0" width="5" height="5" fill="#7CBF97"/>
      <rect x="20" y="0" width="5" height="5" fill="#B4D0C2"/>
      <rect x="0" y="5" width="5" height="5" fill="#B4D0C2"/>
      <rect x="5" y="5" width="10" height="10" fill="#7CBF97"/>
      <rect x="15" y="5" width="5" height="5" fill="#B4D0C2"/>
      <rect x="20" y="5" width="5" height="5" fill="#7CBF97"/>
      <rect x="25" y="5" width="5" height="5" fill="#B4D0C2"/>
      <rect x="0" y="10" width="5" height="5" fill="#7CBF97"/>
      <rect x="5" y="10" width="5" height="5" fill="#DEDEDE"/>
      <rect x="10" y="10" width="5" height="5" fill="#B4D0C2"/>
      <rect x="15" y="10" width="5" height="5" fill="#7CBF97"/>
      <rect x="0" y="15" width="5" height="5" fill="#7CBF97"/>
      <rect x="5" y="15" width="5" height="5" fill="#B4D0C2"/>
      <rect x="10" y="15" width="5" height="5" fill="#DEDEDE"/>
      <rect x="15" y="15" width="5" height="5" fill="#7CBF97"/>
      <rect x="0" y="20" width="5" height="5" fill="#B4D0C2"/>
      <rect x="5" y="20" width="10" height="10" fill="#7CBF97"/>
      <rect x="15" y="20" width="5" height="5" fill="#B4D0C2"/>
      <rect x="20" y="20" width="5" height="5" fill="#7CBF97"/>
      <rect x="25" y="20" width="5" height="5" fill="#B4D0C2"/>
      <rect x="0" y="25" width="5" height="5" fill="#7CBF97"/>
      <rect x="5" y="25" width="5" height="5" fill="#DEDEDE"/>
      <rect x="10" y="25" width="5" height="5" fill="#B4D0C2"/>
      <rect x="15" y="25" width="5" height="5" fill="#7CBF97"/>
      <rect x="20" y="25" width="5" height="5" fill="#B4D0C2"/>
      <rect x="20" y="15" width="10" height="10" fill="#7CBF97"/>
    </pattern>
  </defs>

  <rect fill="url(#Pattern)" stroke="black" width="200" height="200"/>
</svg>

In the above example you would have to adjust rect colors etc. for your pattern so it to comes close to what you might need!

 


☛ Affinity Designer 1.8.3 ◆ Affinity Photo 1.8.3 ◆ OSX El Capitan

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...

Important Information

Please note the Annual Company Closure section in the Terms of Use. These are the Terms of Use you will be asked to agree to if you join the forum. | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.