首页 > 文档 > size()画布尺寸
2017
07-03

size()画布尺寸

16.size()

Name名称):size()//画布尺寸

Examples例子):

 

size(200, 100);

background(153);

line(0, 0, width, height);

 

Description描述):Defines the dimension of the display window width and height in units of pixels. In a program that has the setup() function, the size() function must be the first line of code inside setup().

定义显示窗口宽度的尺寸和像素单位的高度。在具有setup()函数的程序中,size()函数必须是setup()中的第一行代码。

The built-in variables width and height are set by the parameters passed to this function. For example, running size(640, 480) will assign 640 to the width variable and 480 to the height variable. If size() is not used, the window will be given a default size of 100 x 100 pixels.

内置变量的宽度和高度是由传递给这个函数的参数设置的。例如,运行size (640,480)将分配640到宽度变量,480到高度变量。如果不使用size(),则窗口将默认为100 x 100像素。

The size() function can only be used once inside a sketch, and it cannot be used for resizing.

size()函数只能在草图中使用一次,它不能用于调整大小。

As of Processing 3, to run a sketch at the full dimensions of a screen, use the fullScreen() function, rather than the older way of using size(displayWidth, displayHeight).

在处理3的过程中,要在屏幕的整个维度上运行一个示意图,使用fullScreen()函数,而不是使用更老的方法来使用size (显示宽度、显示高度)。

The maximum width and height is limited by your operating system, and is usually the width and height of your actual screen. On some machines it may simply be the number of pixels on your current screen, meaning that a screen of 800 x 600 could support size(1600, 300), since that is the same number of pixels. This varies widely, so you’ll have to try different rendering modes and sizes until you get what you’re looking for. If you need something larger, use createGraphics to create a non-visible drawing surface.

最大宽度和高度受操作系统的限制,通常是实际屏幕的宽度和高度。在一些机器上,它可能只是你当前屏幕上的像素数量,这意味着一个800 x 600的屏幕可以支持size (1600,300),因为这是相同数量的像素。这是不同的,所以你必须尝试不同的渲染模式和大小,直到你得到你想要的。如果你需要更大的东西,使用createGraphics来创建一个非可见的绘图表面。

The minimum width and height is around 100 pixels in each direction. This is the smallest that is supported across Windows, macOS, and Linux. We enforce the minimum size so that sketches will run identically on different machines.

最小宽度和高度大约在100像素左右。这是在Windows、macOS和Linux上支持的最小值。我们执行最小大小,这样草图将在不同的机器上相同的运行。

The renderer parameter selects which rendering engine to use. For example, if you will be drawing 3D shapes, use P3D. In addition to the default renderer, other renderers are:

渲染器参数选择要使用的渲染引擎。例如,如果您将绘制3D图形,请使用P3D。除了默认的渲染器外,其他渲染器是:

P2D (Processing 2D): 2D graphics renderer that makes use of OpenGL-compatible graphics hardware.

P2D(处理2D):2D图形渲染器使用opengl兼容的图形硬件。

P3D (Processing 3D): 3D graphics renderer that makes use of OpenGL-compatible graphics hardware.

P3D(处理3D):3D图形渲染器,利用opengl兼容的图形硬件。

FX2D (JavaFX 2D): A 2D renderer that uses JavaFX, which may be faster for some applications, but has some compatibility quirks.

FX2D(JavaFX 2D):一个使用JavaFX的2D渲染器,它对某些应用程序来说可能更快,但有一些兼容性方面的问题。

PDF: The PDF renderer draws 2D graphics directly to an Acrobat PDF file. This produces excellent results when you need vector shapes for high-resolution output or printing. You must first use Import Library → PDF to make use of the library. More information can be found in the PDF library reference.

PDF:PDF渲染器将2D图形直接绘制到Acrobat PDF文件。当您需要用于高分辨率输出或打印的矢量形状时,这将产生极好的结果。你必须首先使用导入库→PDF利用图书馆。更多信息可以在PDF库参考中找到。

As of Processing 3.0, to use variables as the parameters to size() function, place the size() function within the settings() function (instead of setup()). There is more information about this on the settings() reference page.

在处理3.0时,将变量作为参数用于size()函数,将size()函数放置在settings()函数中(而不是setup ())。在settings()参考页面上有更多关于这个的信息。

 

Syntax(语法): size(width, height)

size(width, height, renderer)

Parameters (参数):width——width of the display window in units of pixels以像素为单位的显示窗口的宽度

height——height of the display window in units of pixels以像素为单位的显示窗口的宽度

Returns返回值):Void(

Related相关函数):width

                      Height



最后编辑:
作者:卡萨布兰卡
这个作者貌似有点懒,什么都没有留下。

留下一个回复

你的email不会被公开。