mirror of
https://github.com/pezkuwichain/pezkuwi-ui.git
synced 2026-05-30 22:11:03 +00:00
e77b1a365c
* 2019 * Bump deps
32 lines
1.1 KiB
TypeScript
32 lines
1.1 KiB
TypeScript
// Copyright 2016 Dan Finlay
|
|
// Copyright 2017-2019 @polkadot/ui-identicon authors & contributors
|
|
// This software may be modified and distributed under the terms
|
|
// of the Apache-2.0 license. See the LICENSE file for details.
|
|
|
|
import colors from './colors';
|
|
import newContainer from './container';
|
|
import newSeeder from './seeder';
|
|
import newShape from './shape/circle';
|
|
import newElement from './svg/element';
|
|
import { SHAPE_COUNT } from './defaults';
|
|
|
|
export default function identicon (seed: string, diameter: number = 256, className: string = '', style?: { [index: string]: string }): HTMLElement {
|
|
const seeder = newSeeder(seed);
|
|
const colorGen = colors(seeder);
|
|
const outer = newContainer(diameter, 'white', className, style);
|
|
const container = newContainer(diameter, colorGen());
|
|
const svg = newElement(diameter);
|
|
|
|
outer.appendChild(container);
|
|
container.appendChild(svg);
|
|
|
|
for (let count = 0; count < SHAPE_COUNT; count++) {
|
|
const fill = colorGen();
|
|
const shape = newShape(seeder, fill, diameter, count);
|
|
|
|
svg.appendChild(shape);
|
|
}
|
|
|
|
return outer;
|
|
}
|