Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

icodi

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

icodi

  • 0.1.4
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

logo

Icodi - Deterministic Random SVG Icon Generator

Gem Version Build Status Maintainability


Generate repeatable random SVG icons from any string, similar to GitHub identicons.


Table of Contents

Installation

$ gem install icodi

Demo

Visit the Icodi Playground to experiment with the parameters.

Examples

Grid: 5x5, Mirror: X (default settings)

strip1

Grid: 6x6, Mirror: Y, Stroke: 4

strip2

Grid: 8x8, Stroke: 7, Density: 0.3

strip3

Grid: 7x7, Mirror: X/Y, Stroke: 3, Density: 0.8

strip4

Grid: 5x5, Jitter: 0.9, Stroke: 2

strip4

Increasing Stroke: 0.1 - 5.0

strip5

Increasing Density: 0.3 - 0.8

strip6

Increasing Jitter: 0 - 1.0

strip6

Mirror Styles: X, Y, Both, None

strip7

Usage

This is the general usage pattern:

require 'icodi'

# initialize with optional text and options
icon = Icodi.new text, options

# get the SVG string
icon.render

# or save to SVG file
icon.save 'logo'

Generate a random icon with the default options, and save it to icon.svg:

icon = Icodi.new
icon.save 'icon'

Generate persistent random icon (same input generates the same output):

icon = Icodi.new "any string"
icon.save 'icon'

Options

Options can be provided as the first or second argument:

Icodi.new "any string", pixels: 8, density: 0.3
Icodi.new pixels: 8, density: 0.3, stroke: 2
ParameterDefaultTypeDescription
pixels5IntegerGrid size.
mirror:xSymbolMirroring mode: :x, :y, :both or :none.
colorDeterministic RandomStringA color string for the pixels.
density0.5FloatA value between 0 and 1 representing the chance for a pixel to be drawn. Lower values mean less pixels.
stroke0.1FloatWidth of the border around each pixel. Note that each pixel is a 10x10 box, so a stroke of 1 means it will take 10% of the box. Higher values generate more overlap between the pixels.
jitter0FloatA value between 0 and 1 representing the chance for a pixel to be dislocated by half of its size in a random direction.
background#fffStringA named SVG color string (blue, yellow etc.) or RGB color (for example #dddddd).
idicodiStringThe ID to assign the SVG object. Normally this should not matter, but if you intend to embed this icon in an HTML, or in another SVG, this can be useful.
template:defaultSymbol/StringSVG template to use. Can be :default, :html or a path to a file. Read more on Victor SVG Templates.

Using with Sinatra

To create a Sinatra server that serves Icodi images, see the config.ru example code.

Contributing / Support

If you experience any issue, have a question or a suggestion, or if you wish to contribute, feel free to open an issue.


FAQs

Package last updated on 06 Mar 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc