We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I've created a polygon react component:
import * as React from 'react'; import { Point } from '../../model'; import { range } from 'lodash'; import { degreesToRadians } from '../../util/trigonometry'; export interface PolygonProps { sides: number; size: number; center?: Point; className?: string; rotate?: number; } export const getPoints = ({ sides, size, center, rotate }: { sides: number; size: number; center: Point; rotate: number; }): Point[] => { return range(0, sides).map((n) => { const degrees = (360 / sides) * n - rotate; const radians = degreesToRadians(degrees); return new Point({ x: center.x + size * Math.cos(radians), y: center.y + size * Math.sin(radians) }); }); }; export const Polygon: React.SFC<PolygonProps> = ({ sides, size = 25, center = new Point({ x: 0, y: 0 }), rotate = 0, className }) => { const points = getPoints({ sides, size, center, rotate }) .map((p) => p.toArray()) .join(' '); return <polygon points={points} className={className} />; };
I've just blogged about it here.
Do you think this is something worth putting into the vx?
It can create any equal sided polygon. I've been using vx recently and it might be useful to others or maybe not :).
vx
The text was updated successfully, but these errors were encountered:
nice! yeah happy to take a look at PR.
Sorry, something went wrong.
@hshoff I have created a PR #355
@hshoff whenever you have time, no rush from me.
landed in #355
No branches or pull requests
I've created a polygon react component:
I've just blogged about it here.
Do you think this is something worth putting into the vx?
It can create any equal sided polygon. I've been using
vx
recently and it might be useful to others or maybe not :).The text was updated successfully, but these errors were encountered: