Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

296
Visualizações
Paper.js - Rotate segment points around a radius size

I have an imported SVG in my paper.js project.

What i'm trying to do is to rotate each of the svg's segment points around a set radius, animating it with the onFrame() method.

I know how to position each segments point's x and y position but i cant really figure out how to position it in a 'rotation'.

What i have now :

enter image description here

var words = project.importSVG(document.querySelector("svg"));
words.visible = true; // Turn off the effect of display:none;;
words.position = view.center;

var letterR = words.children.letter_r;
var letterR_outside = letterR.children.letter_r_outside;
letterR_outside.selected = true;


var rotate_point = view.center;

function onFrame(event) {

  var _delta = Math.sin(event.time);

  //   console.log(Math.round(50 * Math.cos(theta[0])) * _delta);
  //   letterR_outside.segments[0].point.x = Math.round(_radius * Math.cos(theta[0]));
  //   letterR_outside.segments[0].point.y = Math.round(_radius * Math.sin(theta[0]));


  for (var i = 0; i < letterR_outside.segments.length; i++) {
    var segment = letterR_outside.segments[i];
    // segment.point.x += _delta;
    segment.point.rotate(3, rotate_point);
  }

}

Example of what i'm trying to achieve by rotating each points around a radius. [i made the black circles visible to show the rotation circle of each points] enter image description here

I'm not exactly sure how to approach this. Any help is greatly appreciated

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Calling the point.rotate() does nothing because it returns a clone of the point and doesn't modify it directly.
See the documentation:

Rotates the point by the given angle around an optional center point. The object itself is not modified. ...

So you might want to reasign the value:

segment.point = segment.point.rotate(3, rotate_point);
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda