Repository navigation
Expand file tree
/
Copy pathspiral.jsx
More file actions
47 lines (40 loc) · 1.4 KB
/
Copy pathspiral.jsx
File metadata and controls
47 lines (40 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import React, {Component} from 'react';
import Cell from "./cell";
class Spiral extends Component {
render() {
let Maxwidth = window.innerWidth;
let MaxHeight = window.innerHeight;
let width,height;
let maxPrime = this.props.maxPrime;
if( Maxwidth>MaxHeight ){
let ratio = Maxwidth/MaxHeight;
height = maxPrime;
width = ratio*height;
}else{
let ratio = MaxHeight/Maxwidth;
width = maxPrime;
height = ratio*width;
}
// console.log(width,height);
let radius = (Math.min(width,height))/300;
return (
<div className={'bg-dark'}>
{/*sdfsdfsdfsdfsdfsdf*/}
<svg viewBox={"0 0 "+2*width+" "+2*height} xmlns="http://www.w3.org/2000/svg">
{this.props.primes.map( (cell,cellidx)=>{
return (
<circle
id={cellidx}
cx={cell*Math.cos(cell)+width}
cy={cell*Math.sin(cell)+height}
r={radius}
stroke="black" stroke-width="0.5" fill='#51c4b5'
/>
);
} )}
</svg>
</div>
);
}
}
export default Spiral;