Giter VIP home page Giter VIP logo

jsdotpattern's Introduction

Periodic dot and symbol pattern generator

This is the source code of a javascript tool to generate random periodic dot and symbol patterns for use in map rendering. You can try it out in the online version.

The tool is completely in javascript, no server side components. It makes use of the following javascript libraries:

Adding your own symbols

The content of the symbol library is stored in a javascript object in symbols.js.
This is generated with the shell script symbols_json.sh from the individual SVG files in the symbols subdirectory. You can add your own symbols by putting them there and running the script again. Note this is not very robust so you might have troubles when you add complex SVGs. Have a look at the existing files for the expected structure.

Licensed under AGPLv3.

jsdotpattern's People

Contributors

imagico avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

jsdotpattern's Issues

Mapnik-compatible SVGs

Mapnik cannot make use of SVGs with <use/> to my knowledge. This is annoying, but unlikely to change by 3.0 release. A mode to generate a SVG without would be useful.

This does not matter with currently released versions of Mapnik, which do not support SVGs for polygon-patterns at all, and the output of this tool is extremely unlikely to be used with a point symbolizer.

It is probably OK to use ‣/∇/☐ as initial button.

Currently generate button is described as

This should be done before any of the other buttons is used.

It seems that ‣/∇/☐ buttons also may be used as the first one.

I have no good idea how to improve it (that is why this is issue rather than PR).

BTW, thanks for this tool!

automatic offset calculation is broken for pixel aligned rendering

When loading a symbol offsets are calculated automatically based on the symbol bounding box. This however does not work together with pixel aligned rendering at the moment - you need to manually specify the correct offset to get proper pixel aligned rendering for most symbols.

Faster clipping

Currently I’m playing around with svg_pattern.sh to clip an SVG pattern. The very same pattern has to be clipped to various sizes. It seems like the most slow part is sanitizing, and not clipping. I would like to sanitze only once the SVG pattern. And later clip/cut various sizes of this pattern. Currently I always run svg_pattern.sh with the hole sanitizing process. Would it be possible to clip a pattern without sanitizing? In a separate script? Or add an option to svg_pattern.sh to run it without the sanitizing?

different pattern sizes

The web version supports multiple pattern sizes, but I don't see support for this in the codebase

Not working with recent Inkscape version on MacOS

I am trying to run the svg_pattern.sh, but it generates a lot of errors.

inkscape -g --verb EditSelectAll --verb SelectionUnGroup --verb EditSelectAll --verb SelectionUnGroup --verb EditSelectAll --verb SelectionUnGroup --verb EditSelectAll --verb SelectionUnGroup --verb EditSelectAll --verb ObjectToPath --verb EditSelectAll --verb SelectionCombine --verb FileSave --verb FileClose --verb FileQuit frai.svg
Shortcut::add_shortcut: duplicate shortcut found for: <Primary>comma  Old: SelectionShrinkHalve  New: DialogPreferences !

...

./svg_pattern.sh: line 66: 66238 Segmentation fault: 11  inkscape -g --verb EditSelectAll --verb SelectionIntersect --verb FileSave --verb FileClose --verb FileQuit "$TARGET"

# and now we add this again as a workaround for Mapnik's senseless auto-centering
sed -i -e "s?<desc?<rect width=\"$SIZE\" height=\"$CLIP\" rx=\"0\" x=\"0\" y=\"0\" id=\"rect8566\" style=\"fill:none;fill-opacity:1;stroke:none\" /><desc?" "$TARGET"
+ sed -i -e 's?<desc?<rect width="1296" height="1296" rx="0" x="0" y="0" id="rect8566" style="fill:none;fill-opacity:1;stroke:none" /><desc?' frai.svg

inkscape -z --vacuum-defs -l "$TARGET" -f "$TARGET"
+ inkscape -z --vacuum-defs -l frai.svg -f frai.svg
Warning: Option --without-gui= is deprecated
Unknown option -f

Deselecting default symbol does not work

To reproduce:

  • open a new window with https://imagico.de/map/jsdotpattern.php
  • generate a random dot pattern
  • click render to see the pattern with the default tree symbol
  • select an additional symbol with the + button, it will deselect the "use" indicator at the default symbol
  • render the pattern now with 2 symbols, looks good!
  • deselect the default symbol by clicking the + button, now only your second symbol is selected
  • render the pattern again: it will be only using the default tree symbol, and not the selected symbol

This also happens if you select the "use" button on any symbol and add other symbols. When you remove the previously "use"d symbol, the whole pattern switches back to the default tree.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.