SVG marker - can I set length and angle?

后端 未结 2 2066
被撕碎了的回忆
被撕碎了的回忆 2021-01-17 09:35

I\'m trying to draw 6 sticks starting from the centre of the circle with an angle (60 degrees)

\"Desired

2条回答
  •  生来不讨喜
    2021-01-17 10:21

    Here's a demo I made for you.

    The main function used is to find a point on a circle, as below:

    function findPoint(cx, cy, rad, cornerGrad){
      var cornerRad = cornerGrad * Math.PI / 180;
      var nx = Math.cos(cornerRad)*rad + cx;
      var ny = Math.sin(cornerRad)*rad + cy;
      return { x: nx, y: ny };
    }
    

提交回复
热议问题