Code Monkey home page Code Monkey logo

pssvg's People

Contributors

startautomating avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  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

Forkers

marbx

pssvg's Issues

Self-host action

As PSSVG has an action, it should use this to build it's examples

Introducing PSSVG

PSSVG is a PowerShell Module for scalable vector graphics. It allows you to build SVG elements using simple PowerShell functions, and it has a function for every element in the SVG standard.

PSSVG

Include example of BPM Animation

Splatting and simple math can make for musically synchonized animations.

Include an example that generates a pattern that repeats based off of a beat.

Scripting Existing SVGs with ConvertTo-PSSVG

ConvertTo-PSSVG

PSSVG would be much more useful if it could easily convert any SVG off of the internet into a PSSVG file.

So, as of PSSVG 0.2.4, you can ConvertTo-PSSVG

What it does

ConvertTo-PSSVG takes an SVG from a file, url, string, or xml document and converts it into a PSSVG script.

For example, if I download the feather icon for anchor and then run

ConvertTo-PSSVG Anchor.svg

It will output:

=<SVG> -width '24' -height '24' -viewBox '0 0 24 24' -fill 'none' -stroke 'currentColor' -strokewidth '2' -strokelinecap 'round' -strokelinejoin 'round' -class 'feather feather-anchor' -Content @(
    =<SVG.circle> -cx '12' -cy '5' -r '3'
    =<SVG.line> -x1 '12' -y1 '22' -x2 '12' -y2 '8'
    =<SVG.path> -d 'M5 12H2a10 10 0 0 0 20 0h-3'
)

How it works

This is actually fairly trivial.

First we get the XML form of the input, then we:

  1. Go thru to the first node
  2. Replace text nodes with their text.
  3. Find the appropriate command
  4. Replace attributes with parameters (if found)
  5. Replace child nodes recursively (effectively goto step 1).

For bonus points, we indent.

What we can do with this

Being able to ConvertTo-PSSVG gives you an easy way to integrate any existing design into your scripts. This can help, say, establish a visual leitmotif.

Hope this Helps

ConvertTo-PSSVG should try to handle slightly malformed XML.

As ConvertTo-PSSVG doesn't control the whole internet, it's important we handle the unexpected.

Thus:

When ConvertTo-PSSVG attempts to reach a RESTful URL and it receives a string, it should:

  1. Trim any leading content before the first tag
  2. Attempt to coerce it to XML.

SVG functions should include examples

Since the /Examples directory contains a number of examples, any given function could include the contents files that reference that command as examples.

PSSVG should correct markdown links

Because PSSVG is built atop of MDN's documentation, it contains various markdown links that would become invalid.

They can be corrected by linking to developer.mozilla.org.

Build Script should include argumentcompleters

In some cases, there are several fixed arguments and one or more types of input (for instance, with -FontWeight).

Making the best PowerShell experience for these parameters requires making an ArgumentCompleter.

Elements should always allow tags as -Content

Even when the standard indicates that the content will be text, there are scenarios where the content should be text and elements.

Thus -Content should be escaped if it does not start with a tag, and all -Content parameters should be untyped.

Write-SVG should output objects

In order to improve the module experience and make PSSVG more useful, one should be able to use the elements created at each step as objects.

These objects should be decorated to allow for formatting.

Attributes with many sets of metadata present problems in generation.

Some SVG attributes have multiple property tables, with different valid values for different elements.

This presents a bit of a blocking problem, since this presents all but the first alphabetical element from having the correct set of attributes.

To work around this, we will need to parse multiple tables and associate them with the elements they apply to.

Expand Example Coverage

Now that examples are automatically included (#16), it's important to expand coverage of the examples so that more commands have them.

Making a Visual Leitmotif for PowerShell with PSSVG

Because Start-Automating is a PowerShell shop, we have to make a lot of logos that visually hint at the relation between this project on PowerShell.

Doing this consistently across projects is a big benefit of building your assets with scripts. Essentially, what we can do is create a reusable part of a design and reuse that part in project after project.

I call this sort of technique a "Visual Leitmotif" (a Leitmotif is a recurrent theme throughout a composition).

The SVG standard provides something that can make this a little easier, a Symbol.

Using PSSVG, we can create our Visual Leitmotif with just a few lines of code.

=<svg> -ViewBox 100,100 -Content @(
    =<svg.symbol> -Id psChevron -Content @(
        =<svg.polygon> -Points (@(
            "40,20"
            "45,20"
            "60,50"
            "35,80"
            "32.5,80"
            "55,50"
        ) -join ' ')
    ) -ViewBox 100, 100

    =<svg.use> -Href '#psChevron' -Fill '#4488ff'
)

The above code produces this little nifty graphic:

PowerShell Cheron SVG

That's a nifty little image we can use again and again.


Here's the ScriptDeck logo, which makes pretty prominent use of the PowerShell Chevron:

ScriptDeck Logo


Here it is again in the GitPub logo:

GitPub Logo


And again in the ugit logo:
ugit Logo


And again in PSDevOps PSDevOps logo:
PSDevOps Logo


And, of course, in an updated PSSVG logo:
PSSVG logo


As a design technique, visual leitmotifs are a great way to remind people of a central brand without drawing too much attention to it.

With scripting, it's easy to establish that visual leitmotif and reuse it moving forward.

Just get it right once and include or copy and paste between project to project.

Hope this Helps

SVG.Element should have a formatter

SVG.Elements should have a formatter.

A very ideal version of this would show colorized XML for the SVG content.

Luckily, EZOut already has one. We should be able to make some minor modifications to this to produce an ideal experience.

Add SVG.Spiral

SVG.Spiral should inherit from SVG.Path and create a spiral.

It should exclude the parameters: D, Fill

Fill should always be transparent.

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.