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

vue-pattern-placeholder

v1.0.34

Published

Adds canvas patterns as placeholder images

Downloads

18

Readme

Vue-pattern-placeholder

This plugin provides a placeholder component for Vue.js. It uses canvas to render patterns from input string like URL.

NPM version Dependencies Maintenance PRs Welcome MIT license

Table of contents

Demo

Sample images

Recent updates

  • 2019-05-04 Import format changed, refer to usage section.

Installation

To install this plugin, open terminal in your Vue project directory and type:

npm i --save-dev vue-pattern-placeholder

This command will install the plugin in your project node_modules dir and add it as a project development dependency in project's package.json file.

If you need this plugin as a generic dependency, type this command instead:

npm i --save-dev vue-pattern-placeholder

Usage

To import a component, write:

import patternPlaceholder from 'vue-pattern-placeholder'

Add it to the components property

components: {
    patternPlaceholder
},

Now you can use it in your template:

<patternPlaceholder
  :width="150" :height="150"
  :input="''+item_data.media_id"
  label="150x150"
  label_style="900 30px Arial" label_color="#000"
  :hue_range="[70, 170]"
  :lightness_range="[0, 100]"
/>

I recommend to start playing with hue_range and lightness_range properties to reach the best look.

API

For now, none of the parameters are required.

| Option | Data-type(s) | Description | Default | |-----------------|--------------|-----------------------------------------------------------------------------|---------------------| | width | Number | width of an image | 250 | | height | Number | height of an image | 250 | | input | String | this text will be converted to a pattern | Hi there! :-) | | label | String | text label to show | No label | | label_style | String | canvas font style. Example: 900 30px Arial | 20px Helvetica bold | | label_color | String | color of a label. Example: #777 | #777 | | metric | String | metric, used to create a pattern. Examples: Euclidean, Manhattan, Minkovski | Manhattan | | debug | Boolean | allows to show center points for a Voronoi pattern | false | | hue_range | Array | sets a color range in degrees. Example: [0, 359] | [0, 359] | | lightness_range | Array | lightness range for pattern pieces in percents. Example: [0, 100] | [0, 100] |

Warning

Please be aware that this project is still in a testing stage. Use at your own risk. Ideas and bug reports are welcome.

Inspiration

I thought about converting text to an image and I remembered Voronoi patterns: these are easy to implement and look very nice.

Voronoi pattern animation

Then I had an idea:

  • take a string, process it using a SHA-256 hash function
  • extract hash bytes
  • use pairs of bytes, converting each to a float value between 0 and 1 to place X and Y points
  • count pattern segments, use numbers to set each one's hue in HSV color palette
  • calculate pattern areas
  • use areas to determine lightness of a pattern segment in HSV

TODO

  • [x] Overlay text
  • [x] Fix wrong color representation in overlay text
  • [x] Autoreload fix (probably needs a destructor)
  • [x] Fix empty canvas on width / height change
  • [x] Fixed beforeDestroy bug
  • [x] Added demo
  • [ ] Consider integrating label style and color into one parameter
  • [ ] Label style settings in key-value format
  • [ ] Extend hue setting to a list of several possible hues

Acknowledgements

Thanks to AnatolV from RosettaCode for a nice Voronoi diagram implementation.

Thanks to emn178 for js-sha256 library. It is easy to use and helps a lot.