helloswyg / autoshapes-example

🎨 Programmatically generated shapes to automatically spice up for your JS / React sites!
https://helloswyg.github.io/autoshapes-example/
MIT License
2 stars 0 forks source link

autoshapes-example

Sandbox for playing with auto-generated SVG shapes on a web page.

Basic usage of shapelib

Shapes are available in different categories (kinds)

plain js:

import shapelib
shapelib.core.drawShape({element, ...shapeProps, ...styleProps})

react:

import { ShapeComponent } from shapelib;

const yourComponent(props) => {
    return (
        # ...
        <ShapeComponent ...shapeProps ...styleProps/>
        # ...
    )
}

shapeProps

shapeProps are properties that define the type and form of a shap (as opposed to colors/style etc.)

interface shapeProps{
    kind: string,
    complexity: number,
    smoothness: number, 
    variability: number,
    seed: number,
}

styleProps

styleProps are properties that define colors, fill, stroke and other stylistic properties. These props can also be used to introduce scaling and rotations.

these propserties are passed directly to the underlying SVG.js library. See the SVG.js Documentation for allowed properties.

For example:

<ShapeComponent ...shapeProps stroke={{ color: gradient.url(), width: 3, opacity: 0.8 }}/>

TBD:

Low level interface