使用Paper JS在Javascript中定义的函数

时间:2015-08-21 12:41:51

标签: javascript paperjs

更新 使colorChange函数全局解决问题

当按钮“红色”时,我正在尝试更改路径的颜色。单击使用colorChange函数。无论我的逻辑如何,错误都表示'功能' colorChange'没有定义' 。像path()这样的内部纸张js函数正在工作,但我的功能不是。

<head>
<!-- Load the Paper.js library -->
<script type="text/javascript" src="js/paper.js"></script>
<!-- Load external PaperScript and associate it with myCanvas -->
<script type="text/paperscript" src="js/myScript.js" canvas="myCanvas"></script>
<!-- CSS -->
<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body>
    <button onClick='colorChange(id)' id='red'>Red</button> // Using it here
    <canvas id="myCanvas" resize="true"></canvas>
</body>

这里是myScript.js for canvas ID =&#39; myCanvas&#39; :

var myPath={};

var colorChange=function(id){  //function I defined doesn't work
    myPath=new Path();
    myPath.strokeColor=id;
}

function onMouseDown(event){   //this works
    myPath=new Path();
    myPath.add(event.point);
}

1 个答案:

答案 0 :(得分:0)

$clients = Client::lists('name', 'id'); 标记移到页面底部,而不是标题中。这应该使它工作。