所以我每次用户按键时都会尝试绘制一个形状,但是我得到了奇怪的控制台错误。
paper-full.js:14632 Uncaught SyntaxError: Identifier directly after number (8:42)
at t (paper-full.js:14632)
at E (paper-full.js:14632)
at y (paper-full.js:14632)
at g (paper-full.js:14632)
at U (paper-full.js:14632)
at z (paper-full.js:14632)
at ue (paper-full.js:14632)
at oe (paper-full.js:14632)
at ae (paper-full.js:14632)
at te (paper-full.js:14632)
我对paper.js不熟悉。我的HTML,脚本代码似乎是正确的,如果有人伸出援助之手,那将是一个很大的缓解。
<!DOCTYPE html>
<html>
<head>
<title>Sounds of keyboard</title>
<link rel="stylesheet" type="text/css" href="style.css">
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/paper.js/0.10.3/paper-full.js"></script>
<script type="text/paperscript" canvas="canvas">
var circles = [];
function onKeyDown(event){
var maxPoint = new Point(view.size.width, view.size.height);
var randomPoint = Point.random();
var point = maxPoint * randomPoint;
var newCircle = new Path.Circle(point, 5oo);
newCircle.fillColor = "orange";
circles.push(newCircle);
}
function onFrame(event){
for(var i=0; i<circles.length; i++){
circles[i].fillColor.hue += 1;
circles[i].scale(.9);
}
}
</script>
</head>
<body>
<canvas id="canvas" resize></canvas>
</body>
</html>
&#13;
答案 0 :(得分:0)
将new Path.Circle(point, 5oo)
替换为new Path.Circle(point, 500)
,可行:)
<!DOCTYPE html>
<html>
<head>
<title>Sounds of keyboard</title>
<link rel="stylesheet" type="text/css" href="style.css">
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/paper.js/0.10.3/paper-full.js"></script>
<script type="text/paperscript" canvas="canvas">
var circles = [];
function onKeyDown(event){
var maxPoint = new Point(view.size.width, view.size.height);
var randomPoint = Point.random();
var point = maxPoint * randomPoint;
var newCircle = new Path.Circle(point, 500);
newCircle.fillColor = "orange";
circles.push(newCircle);
}
function onFrame(event){
for(var i=0; i<circles.length; i++){
circles[i].fillColor.hue += 1;
circles[i].scale(.9);
}
}
</script>
</head>
<body>
<canvas id="canvas" resize></canvas>
</body>
</html>
&#13;