Security News
The Push to Ban Ransom Payments Is Gaining Momentum
Ransomware costs victims an estimated $30 billion per year and has gotten so out of control that global support for banning payments is gaining momentum.
liedenticon
Advanced tools
Readme
Transform a string into a unique image.
Liedenticon is a ripoff of extension of Identicon with a few major differences.
Liedenticon separates image generation into two separate classes. One to generate SVGs and another to generate PNGs.
import { SVG, PNG } from "Lidenticons";
By default the SVG module will generate an svg string to be embedded in a document.
console.log(new SVG("...")); //logs "<svg ..."
Passing a truthy paramater to the "toString" method will create a string that can be used directly as the source attribute of an image.
console.log(new SVG("...").toString(true)); //logs "data:image/svg+xml;utf8,<svg ..."
Passing a second truthy paramater returns the base 64 encoded string.
console.log(new SVG("...").toString(true, true)); //logs "data:image/svg+xml;base64,..."
The PNG module will generate a base64 string by default with a pre-amble attached.
console.log(new SVG("...")); //logs "data:image/svg+png;base64,..."
Passing a falsy parameter to "toString" method will drop the pre-amble.
console.log(new SVG("...").toString(false)); //logs "..."
Both the SVG and PNG modules both inherit from an internal class called Grahic. It should be easy to extend this object and support other fomats by implementing a "renderImage" and a "toString" method.
import Graphics from "Liedenticon/graphic";
class NewFormat extends Graphics {
renderImage(hash, size, padding, background, foreground) {
//...
}
toString() {
//...
}
}
In addition to using an array for colors, Liedenticon supports 1, 2, 3, 4, 6, and 8 digit hex color codes. 2, 4, and 8 digit colors support alpha channels
We've replaced the "margin" option "padding" as it this more closely fits this definition used by most web developers.
Padding also supports values given as percentage strings.
const svg = new SVG("...", { padding: "20%" });
lidenticons/graphic
Kind: global class
Extends: lidenticons/graphic
A hash represented as an SVG
Param | Type | Description |
---|---|---|
hash | string | unique string |
options | object | graphicical options |
Example
import {SVG} from "Liedenticon";
const svg = document.createElement("SVG");
document.appendChild(svg);
svg.outerHTML = new SVG("efb8c90a13f7a1fdc4910");
lidenticons/graphic
Kind: global class
Extends: lidenticons/graphic
A hash represented as an PNG
Param | Type | Description |
---|---|---|
hash | string | unique string |
options | object | graphicical options |
Example
import {PNG} from "Liedenticon";
const img = document.createElement("IMG");
img.src = new PNG("efb8c90a13f7a1fdc4910");
document.appendChild(img);
FAQs
Unknown package
The npm package liedenticon receives a total of 0 weekly downloads. As such, liedenticon popularity was classified as not popular.
We found that liedenticon demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Ransomware costs victims an estimated $30 billion per year and has gotten so out of control that global support for banning payments is gaining momentum.
Application Security
New SEC disclosure rules aim to enforce timely cyber incident reporting, but fear of job loss and inadequate resources lead to significant underreporting.
Security News
The Python Software Foundation has secured a 5-year sponsorship from Fastly that supports PSF's activities and events, most notably the security and reliability of the Python Package Index (PyPI).