main
js 48 lines 1.01 KB
Raw
1 /**
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 * @typechecks
7 *
8 * Example usage:
9 * <Circle
10 * radius={10}
11 * stroke="green"
12 * strokeWidth={3}
13 * fill="blue"
14 * />
15 *
16 */
17
18 'use strict';
19
20 var assign = Object.assign;
21 var React = require('react');
22 var ReactART = require('react-art');
23
24 var createReactClass = require('create-react-class');
25
26 var Path = ReactART.Path;
27 var Shape = ReactART.Shape;
28
29 /**
30 * Circle is a React component for drawing circles. Like other ReactART
31 * components, it must be used in a <Surface>.
32 */
33 var Circle = createReactClass({
34 displayName: 'Circle',
35
36 render: function render() {
37 var radius = this.props.radius;
38
39 var path = Path()
40 .moveTo(0, -radius)
41 .arc(0, radius * 2, radius)
42 .arc(0, radius * -2, radius)
43 .close();
44 return React.createElement(Shape, assign({}, this.props, {d: path}));
45 },
46 });
47
48 module.exports = Circle;