0

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.

1
  • There's an extra closing bracket right before the closing script tag. That's one error. Commented Mar 14, 2017 at 1:37

1 Answer 1

1

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>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.