首页 > 文档 > rectMode()矩形模式
2017
08-01

rectMode()矩形模式

Name

rectMode()矩形模式

   

Examples

rectMode()矩形模式 - 第1张  | Processing编程艺术

rectMode(CORNER); // Default rectMode is CORNER

fill(255); // Set fill to white

rect(25, 25, 50, 50); // Draw white rect using CORNER mode

 

rectMode(CORNERS); // Set rectMode to CORNERS

fill(100); // Set fill to gray

rect(25, 25, 50, 50); // Draw gray rect using CORNERS mode

rectMode()矩形模式 - 第2张  | Processing编程艺术

rectMode(RADIUS); // Set rectMode to RADIUS

fill(255); // Set fill to white

rect(50, 50, 30, 30); // Draw white rect using RADIUS mode

 

rectMode(CENTER); // Set rectMode to CENTER

fill(100); // Set fill to gray

rect(50, 50, 30, 30); // Draw gray rect using CENTER mode

Description

Modifies the location from which rectangles are drawn by changing the way in which parameters given to rect() are intepreted.

The default mode is rectMode(CORNER), which interprets the first two parameters of rect() as the upper-left corner of the shape, while the third and fourth parameters are its width and height.

rectMode(CORNERS) interprets the first two parameters of rect() as the location of one corner, and the third and fourth parameters as the location of the opposite corner.

rectMode(CENTER) interprets the first two parameters of rect() as the shape’s center point, while the third and fourth parameters are its width and height.

rectMode(RADIUS) also uses the first two parameters of rect() as the shape’s center point, but uses the third and fourth parameters to specify half of the shapes’s width and height.

The parameter must be written in ALL CAPS because Processing is a case-sensitive language.

通过更改给矩形 () intepreted 的参数的方式, 来修改从其绘制长方形的位置。

 

默认模式为 rectMode (), 它将矩形 () 的前两个参数解释为形状的左上角, 而第三和第四参数是其宽度和高度。

 

rectMode () 将矩形 () 的前两个参数解释为一个角的位置, 第三和第四参数作为相对角的位置。

 

rectMode (中心) 将矩形 () 的前两个参数解释为形状的中心点, 而第三和第四参数是其宽度和高度。

 

rectMode (radius) 还使用矩形 () 的前两个参数作为形状的中心点, 但使用第三和第四参数指定形状的宽度和高度的一半。

 

该参数必须以所有大写形式写入, 因为处理是一种 case-sensitive 的语言。

Syntax

rectMode(mode)

Parameters

mode

int: either CORNER, CORNERS, CENTER, or RADIUS


整数型:角,多个角,中心或者半径


 

 

Returns

void

Related

rect()



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

留下一个回复

你的email不会被公开。