2016-12-17 3 views
2

PaperJs의 최신 버전을 사용하고 있는데 샘플 에서 다음 코드를 실행하면 "NaN"이 출력됩니다.문서마다 PaperJs에 임의의 점을 만들 수 없습니다.

// Make the paper scope global, by injecting it into window: 
paper.install(window); 
window.onload = function() { 
    // Setup directly from canvas id: 
    paper.setup('myCanvas'); 

    // Create a point whose x is between 0 and 50, 
    // and y is between 0 and 100 
    var point = new Point(50, 100) * Point.random(); 

    console.log(point); 
} 

다음 작품 및 모든 내 다른 PaperJs 코드 :

window.onload = function() { 
    paper.setup('myCanvas'); 
    with (paper) { 
     // Create a point whose x is between 0 and 50, 
     // and y is between 0 and 100 
     var point = new Point(50, 100) * Point.random(); 

     console.log(point); 
    } 
} 

The code works online in sketch.paperjs.org하지만 다음 위의 코드 또는를 통해 로컬하려고 할 때 작동하지 않습니다 (또한 "NaN의"를 출력) 공장; 그것은 내가 문서마다 임의의 지점을 만들 수없는 것입니다.

console.log(new Point(50, 100), Point.random()); 

출력 :

Point {x: 50, y: 100} Point {x: 0.8624748098043336, y: 0.8705165661914955} 

documenation :

+1

자바 스크립트가 아닌 paper.js를 사용 하시겠습니까? 곱하기 연산자는 자바 스크립트에서 오버로드 될 수 없기 때문에 'pointA.multiply (pointB);'를 사용해야합니다. –

+0

@ arthur.sw 그랬습니다! 나는 http://paperjs.org/tutorials/getting에 따라 javascript를 직접 사용하여 (type = 'text/paperscript'를 사용하지 않고)'view.size.multiply (Point.random()); -started/using-javascript-directly/감사합니다 !!! – user1477388

+0

ok 확인해 주시면 답변을 게시 할 수 있습니다 :) –

답변