如何在纸张js中找到线条的角度?

时间:2015-05-02 06:53:23

标签: paperjs

在纸张Js中使用线点找到角度和长度,以及如何使用这些矢量值找到线条的矢量值我们找到角度,但在这里我遇到了一些问题。

2 个答案:

答案 0 :(得分:1)

我知道这是一个古老的问题,但是您可以:

import { Choice } from './choice.model';


export class DisplayView {
    id: number;
    title: string;
    type: string;
    public isFirst: boolean;
    public choices: Choice[];

    constructor(values: Object = {}) {
        Object.assign(this, values);
      }
}

答案 1 :(得分:-2)

var pathforward=new paper.Path({strokeColor:"red",strokeWidth:2}); var point = pathforward.getPointAt(pathforward.length);
            var vector  = point.subtract(pathforward.getPointAt(pathforward.length-25));
                var x1 = pathforward.segments[0].point.x;
                var y1 = pathforward.segments[0].point.y;
                var x2 = pathforward.segments[1].point.x;
                var y2 = pathforward.segments[1].point.y;
                var m =(y2-y1) / (x2-x1);
                var angleDeg = Math.floor(Math.atan2(y2-y1, x2 -x1) * 180 / Math.PI);

              alert( angleDeg + '\xb0');