如何在HTML中包含Processing.js代码

问题描述 投票:0回答:2

我想为我的网页编写一个processing.js脚本,但是我的草图没有显示。我包括以下几行:

<canvas id="mycanvas'></canvas>
<script src="https://cdn.jsdelivr.net/processing.js/1.4.8/processing.min.js"></script>
<script>
    var sketchProc = function(processingInstance) {
     with (processingInstance) {
        size(400, 400);
        frameRate(30);

        // ProgramCodeGoesHere
        fill(255, 255, 0);
        ellipse(200, 200, 200, 200);
        noFill();
        stroke(0, 0, 0);
        strokeWeight(2);
        arc(200, 200, 150, 100, 0, PI);
        fill(0, 0, 0);
        ellipse(250, 200, 10, 10);
        ellipse(153, 200, 10, 10);
    }};

    // Get the canvas that Processing-js will use
    var canvas = document.getElementById("mycanvas");
    // Pass the function sketchProc (defined in myCode.js) to Processing's constructor.
    var processingInstance = new Processing(canvas, sketchProc);
 </script>

我没有看到任何错误消息,所以我不知道怎么了。

javascript html processing
2个回答
0
投票

请尝试在画布上添加尺寸


0
投票

因为您的html中有错误

© www.soinside.com 2019 - 2024. All rights reserved.