David
David

Reputation: 49

Paper.js uncaught syntax error

Getting lots of issues with Paper.js. Doing Colt Steele's Web Developer Bootcamp on Udemy. I'm on Section 19. Currently trying to make a Patatap clone. Here's when I'm stuck:

http://codepen.io/SlouchingToast/pen/LWLXYZ

HTML

<!DOCTYPE html>
<html>
<head>
    <title>Circles</title>
    <link rel="stylesheet" type="text/css" href="circles.css">
    <script src="https://cdnjs.cloudflare.com/ajax/libs/paper.js/0.10.3/paper-full.min.js"></script>

    <script type="text/paperscript" canvas="myCanvas">

    function onKeyDown(event) {
        var maxPoint = new Point(view.size.width, view.size.height);
        var randomPoint = Point.random();
        var point = maxPoint * randomPoint;
        new Path.Circle(point, 10).fillColor = "olive";
    }

    var animatedCircle = new Path.Circle(new Point(300,300), 100);
    animatedCircle.fillColor = "red";

    }

    </script>
</head>
<body>
    <canvas id="myCanvas" resize></canvas>

</body>
</html>    

CSS

canvas {
    width: 100%;
    height: 100%;
    background: black;
}

body, html {
 height: 100%;
 margin: 0;
}

Chrome Console Error

Uncaught ReferenceError: animatedCircle is not defined
    at at.paper._execute (<anonymous>:11:2)
    at u (paper-full.min.js:38)
    at HTMLCollection.l (paper-full.min.js:38)
    at HTMLCollection.l (paper-full.min.js:32)
    at Function.f [as each] (paper-full.min.js:32)
    at f (paper-full.min.js:38)
paper._execute @ VM519:11
u @ paper-full.min.js:38
l @ paper-full.min.js:38
l @ paper-full.min.js:32
f @ paper-full.min.js:32
f @ paper-full.min.js:38

What's supposed to happen, is just displaying a circle. That's it.

Upvotes: 0

Views: 1137

Answers (1)

sapics
sapics

Reputation: 1114

By replacing paperscript to below, it works. First, remove unnecessary end tag }. Second, fix animateCircle to animatedCircle.

    <script type="text/paperscript" canvas="myCanvas">
    function onKeyDown(event) {
        var maxPoint = new Point(view.size.width, view.size.height);
        var randomPoint = Point.random();
        var point = maxPoint * randomPoint;
        new Path.Circle(point, 10).fillColor = "olive";
    }

    var animatedCircle = new Path.Circle(new Point(300,300), 100);
    animatedCircle.fillColor = "red";
    </script>

Upvotes: 1

Related Questions