File tree Expand file tree Collapse file tree 2 files changed +57
-0
lines changed Expand file tree Collapse file tree 2 files changed +57
-0
lines changed Original file line number Diff line number Diff line change 1+ const size = 600 ;
2+ const count = 8 ;
3+ const color = "grey" ;
4+
5+ const angle = 2 * Math . PI / count ;
6+ const distance = size / 3 ;
7+
8+ const points : { x : number , y : number } [ ] = [ ] ;
9+ for ( let i = 0 ; i < count ; i += 1 ) {
10+ points . push ( {
11+ x : Math . sin ( i * angle ) * distance ,
12+ y : Math . cos ( i * angle ) * distance ,
13+ } ) ;
14+ }
15+
16+ const paths = points . map < string > ( ( point , i ) => {
17+ if ( i === 0 ) {
18+ return `M${ point . x } ,${ point . y } ` ;
19+ }
20+ return `L${ point . x } ,${ point . y } ` ;
21+ } ) ;
22+ paths . push ( "Z" ) ;
23+
24+ console . log ( `
25+ <svg width="${ size } " height="${ size } " viewBox="0 0 ${ size } ${ size } " xmlns="http://www.w3.org/2000/svg">
26+ <g transform="translate(${ size / 2 } , ${ size / 2 } )">
27+ <path
28+ stroke="none"
29+ stroke-width="0"
30+ fill="${ color } "
31+ d="${ paths . join ( "\n" ) } "
32+ />
33+ </g>
34+ </svg>
35+ ` ) ;
36+
37+ // const r = (a, b) => Math.min(a, b) + (Math.abs(a - b) * Math.random());
You can’t perform that action at this time.
0 commit comments