mirror of
https://github.com/pezkuwichain/pezkuwi-ui.git
synced 2026-06-14 23:01:02 +00:00
c3f57c19e8
* Move ui-identicon -> react-identicon * ui-identicon import fix * Update README package links * Update doc sidebar links * Adjust react-qr signatures, CHANGELOG
24 lines
899 B
TypeScript
24 lines
899 B
TypeScript
// Copyright 2016 Dan Finlay
|
|
// Copyright 2017-2019 @polkadot/react-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 { Seeder } from '../types';
|
|
|
|
import newCircle from '../svg/circle';
|
|
import { SHAPE_COUNT } from '../defaults';
|
|
|
|
export default function circle (seeder: Seeder, fill: string, diameter: number, count: number): Element {
|
|
const center = diameter / 2;
|
|
const angle = seeder() * 360;
|
|
const radius = (((SHAPE_COUNT - count) / SHAPE_COUNT) * (diameter / 2)) + ((diameter / 8) * seeder());
|
|
const offset = (diameter / 4) * (seeder() + ((count + 1) / SHAPE_COUNT));
|
|
const cx = (offset * Math.sin(angle)) + center;
|
|
const cy = (offset * Math.cos(angle)) + center;
|
|
const svg = newCircle(radius, cx, cy);
|
|
|
|
svg.setAttributeNS('', 'fill', fill);
|
|
|
|
return svg;
|
|
}
|