add ring for each planet

Arnaud
Marchand Arnaud ago%!(EXTRA string=2 years)
parent 72809cd1c1
commit a5ca1394d1
  1. 38
      js/TEST_F.JS

@ -69,10 +69,32 @@ let ring = [];
function drawSystem(wayPoints) { function drawSystem(wayPoints) {
if(wayPoints) { if(wayPoints) {
wayPoints.forEach(wayPoint => { wayPoints.forEach(wayPoint => {
drawWaypoint(wayPoint); drawRingWaypoint(wayPoint);
}); });
wayPoints.forEach(wayPoint => {
drawWaypoint(wayPoint);
})
} }
drawRing(); }
function drawRingWaypoint(wayPoint)
{
let distanceX = wayPoint.x / offset.x;
let distanceY = wayPoint.y / offset.y;
let pythagoreX = distanceX * distanceX;
let pythagoreY = Math.pow(distanceY, 2);
console.log(pythagoreX, pythagoreY)
//pythagoreX = pythagoreX/offset.x;
//pythagoreY = pythagoreY/offset.y;
let pythagorePlanet = Math.sqrt(pythagoreX + pythagoreY);
console.log(pythagorePlanet);
let circle = new fabric.Circle({
radius: pythagorePlanet, fill: 'transparent', left: (canvas.width/2) - pythagorePlanet, top: (canvas.height/2)-pythagorePlanet
});
circle.set({ strokeWidth: 0.5, stroke: 'rgba(10,53,66,2)' });
canvas.add(circle);
} }
function drawRing() function drawRing()
@ -80,6 +102,7 @@ function drawRing()
for(let i = 0; i < 4; i++){ for(let i = 0; i < 4; i++){
let random = Math.random() * (250 - 100) + 100; let random = Math.random() * (250 - 100) + 100;
// create a circle // create a circle
console.log(canvas.width)
let circle = new fabric.Circle({ let circle = new fabric.Circle({
radius: random, fill: 'transparent', left: (canvas.width/2)-random, top: (canvas.height/2)-random radius: random, fill: 'transparent', left: (canvas.width/2)-random, top: (canvas.height/2)-random
}); });
@ -110,13 +133,12 @@ function drawRing()
} }
function drawWaypoint(wayPoint) { function drawWaypoint(wayPoint) {
fabric.Image.fromURL('http://127.0.0.1:5500/img/planets/planetproto.png', function(planet) { let radius = 5;
planet.set({left: wayPoint.x/offset.x + w/2}); let circle = new fabric.Circle({
planet.set({top: wayPoint.y/offset.y+ h/2}); radius: radius, fill: 'white', left: (wayPoint.x/2 + canvas.width/2) -radius, top: (wayPoint.y/2 + canvas.height/2)-radius
planet.set({selectable: false});
canvas.add(planet);
}); });
planets.push(wayPoint); circle.set({ strokeWidth: 0.5, stroke: 'rgba(255,255,255,255)' });
canvas.add(circle);
} }
function movePlanets() { function movePlanets() {
planets.forEach(waypoint => { planets.forEach(waypoint => {

Loading…
Cancel
Save