npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@dev-to-be-curious/rand-svg-path-generator

v1.6.2

Published

Tool to randomly generate a svg composed of a path and checkpoints

Downloads

382

Readme

rand-svg-path-generator

rand-svg-path-generator a TypeScript tool to randomly generate a svg composed of a path and checkpoints

Installation

Use the node package manager (npm) to install foobar.

npm i @dev-to-be-curious/rand-svg-path-generator

Usage

There are two ways to generate your map: either by integrating your checkpoint data directly into the map generation settings, or through an api.

Basic usage

// Import module
import { Map } from "@dev-to-be-curious/rand-svg-path-generator";

// Setup general settings containing the checkpoints data
let settings = {
    width: 0, // set 0 for max screen width
    height: 0, // set 0 for max screen height
    margin: {
        top: 20,
        right: 30,
        bottom: 30,
        left: 30
    },
    delta_y: 150, // Max variation of y position between two checkpoints
    checkpoints: {
        radius: 15, // Default radius of a checkpoint (objectives will be half size)
        randomizer: {
            maxAlpha: 60, // Max angle value for y position generation using trigonometry
            distance: 150 // Distance between two checkpoints
        }
    },
    apiUrl: '',
    data: [{
        "type": "start",
        "label": "Start",
        "status": "FINISHED" // Status can be: LOCKED | TODO | CURRENT | FINISHED
    },
    {
        "label": "Customer-focused",
        "status": "FINISHED",
        "childrens": [{
                "label": "Public-key",
                "type": "children",
                "status": "FINISHED"
            },
            {
                "label": "Automated",
                "type": "children",
                "status": "FINISHED"
            }
        ]
    },
    {
        "label": "Distributed",
        "status": "TODO",
        "childrens": [{
                "label": "Configurable",
                "type": "children",
                "status": "FINISHED"
            },
            {
                "label": "Compatible",
                "type": "children",
                "status": "FINISHED"
            },
            {
                "label": "Persistent",
                "type": "children",
                "status": "CURRENT"
            }
        ]
    },
    {
        "type": "end",
        "label": "Stop",
        "status": "LOCKED"
    }
]
};

// Instantiate a new Map
const map = new Map(settings);

// Example of default style manipulation
// You can also manipulate style throught css
map.path.styles.checkpoints.end.fill = 'orange';


// Generate map by api
map.generateMap();

Warning !

If you use status please add the following svg in your assets folder : locked.svg, todo.svg, current.svg and finished.svg.

Set svg in your assets folder at /@dev-to-be-curious/rspg/.

From API

// Import module
import { Map } from "@dev-to-be-curious/rand-svg-path-generator";

// Setup general settings
let settings = {
    width: 0,
    height: 0,
    margin: {
        top: 20,
        right: 30,
        bottom: 30,
        left: 30
    },
    delta_y: 150,
    checkpoints: {
        radius: 15,
        randomizer: {
            maxAlpha: 60,
            distance: 150
        }
    },
    apiUrl: 'http://127.0.0.1:3000',
    data: []
};

// Instantiate a new Map
const map = new Map(settings);

// Example of default style manipulation
// You can also manipulate style throught css
map.path.styles.checkpoints.end.fill = 'orange';


// Generate map by api
map.generateMapByApi(settings.apiUrl);

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

Copyright © 01-18-2021, Félicien Fouillet - DevToBeCurious

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subje-ct to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

The Software is provided “as is”, without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. In no event shall the authors or copyright holders X be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or the use or other dealings in the Software.

Except as contained in this notice, the name of Félicien Fouillet or DevToBeCurious shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written their authorization.