简体   繁体   English

我在带有脚本标签的网页中使用processing.js。 如何更改脚本标签的高度?

[英]I am using processing.js in a web page with script tag. How can I change the height of the script tag?

I have created a script tag to put in processing code. 我创建了一个脚本标签来放入处理代码。 When I put it on a website it only takes up a small fraction of the web page despite it having 1142 as a height. 当我将其放置在网站上时,尽管它的高度为1142,但它仅占网页的一小部分。

 <html>
      <head>
        <script type="text/javascript" src="processingJS/processing.js"></script>
        <script type="text/javascript" src="processingJS/init.js"></script>
      </head>
      <body>
        <script type="application/processing" height="1142" width="1142">
        noStroke();


    draw = function() {
        fill(mouseX, mouseY, 0);
        ellipse(mouseX, mouseY, 100, 100);
    };

        </script><canvas></canvas>
      </body>
    </html>

Like NewToJS said in their comment, you need to use the setup() and size() functions. 就像NewToJS在评论中所说的那样,您需要使用setup()size()函数。

More info is available in the reference : 参考中提供了更多信息:

Defines the dimension of the display window in units of pixels. 以像素为单位定义显示窗口的尺寸。 The size() function must be the first line in setup() . size()函数必须是setup()的第一行。 If size() is not called, the default size of the window is 100x100 pixels. 如果未调用size() ,则窗口的默认大小为100x100像素。 The system variables width and height are set by the parameters passed to the size() function. 系统变量widthheight由传递给size()函数的参数设置。

You should also really get into the habit of doing some research before you post a question. 在发布问题之前,您还应该真正养成进行研究的习惯。 This is covered in pretty much every Processing and Processing.js tutorial, so a little reading would have gone a long way for you here. 几乎所有Processing and Processing.js教程都涵盖了这一点,因此在这里稍加阅读对您来说将大有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM