首页 > 文档 > PShape类
2017
07-12

PShape类

PShape

Name

名称

PShape

PShape类

Examples

例子

PShape s;

 

void setup() {

size(100, 100);

// The file “bot.svg” must be in the data folder

// of the current sketch to load successfully

s = loadShape(“bot.svg”);

}

 

void draw() {

shape(s, 10, 10, 80, 80);

}

PShape类 - 第1张  | Processing编程艺术

PShape square; // The PShape object

 

void setup() {

size(100, 100);

// Creating the PShape as a square. The corner

// is 0,0 so that the center is at 40,40

square = createShape(RECT, 0, 0, 80, 80);

}

 

void draw() {

shape(square, 10, 10);

}

Description

描述

Datatype for storing shapes. Before a shape is used, it must be loaded with the loadShape() or created with the createShape(). The shape() function is used to draw the shape to the display window. Processing can currently load and display SVG (Scalable Vector Graphics) and OBJ shapes. OBJ files can only be opened using the P3D renderer. The loadShape() function supports SVG files created with Inkscape and Adobe Illustrator. It is not a full SVG implementation, but offers some straightforward support for handling vector data. 
存储形状的数据类型。在使用一个形状之前,它必须由loadShape()载入或由createShape()创建。
 shape()函数用于将形状绘制到显示窗口。Processing可以加载并显示SVG(可伸缩的矢量图形)和OBJ形状。OBJ文件只能使用P3D渲染器打开。loadShape()函数支持用Inkscape和Adobe Illustrator创建的SVG文件。它不是一个完整的SVG处理函数,只支持直接处理向量数据。
The
 PShape object contains a group of methods that can operate on the shape data. Some of the methods are listed below, but the full list used for creating and modifying shapes is available here in the Processing Javadoc.
PShape对象包含一组可以对形状数据进行操作的方法。下面列出了一些方法,但是用于创建和修改形状的完整列表在Processing Javadoc。


To create a new shape, use the
 createShape() function. Do not use the syntax new PShape().

要创建一个新形状,使用createShape()函数。不要使用新的PShape()语法。

Fields

字段

width

Shape document width

形状的宽

height

Shape document height

形状的高

Methods

方法

isVisible()

Returns a boolean value “true” if the image is set to be visible, “false” if not

查询形状是否可见

setVisible()

Sets the shape to be visible or invisible

设置形状可见状态

disableStyle()

Disables the shape’s style data and uses Processing styles

关闭shape风格并使用Processing风格

enableStyle()

Enables the shape’s style data and ignores the Processing styles

使能shape风格并关闭Processing风格

beginContour()

Starts a new contour

开始新的轮廓线

endContour()

Ends a contour

结束轮廓线

beginShape()

Starts the creation of a new PShape

开始创建一个新的PShape

endShape()

Finishes the creation of a new PShape

结束创建一个新的PShape

getChildCount()

Returns the number of children

返回子类的数量

getChild()

Returns a child element of a shape as a PShape object

返回一个形状的子元素作为PShape的对象

addChild()

Adds a new child

添加一个新的子类

getVertexCount()

Returns the total number of vertices as an int

返回顶点的总数(int整形)

getVertex()

Returns the vertex at the index position

返回检索位置的顶点

setVertex()

Sets the vertex at the index position

设置检索位置的顶点

setFill()

Set the fill value

设置填充值

setStroke()

Set the stroke value

设置线宽

translate()

Displaces the shape

移动形状的位置

rotateX()

Rotates the shape around the x-axis

绕X轴旋转

rotateY()

Rotates the shape around the y-axis

绕Y轴旋转

rotateZ()

Rotates the shape around the z-axis

绕Z轴旋转

rotate()

Rotates the shape

旋转形状

scale()

Increases and decreases the size of a shape

缩放图像

resetMatrix()

Replaces the current matrix of a shape with the identity matrix

重置矩阵

Constructor

构造函数

PShape(g, kind, params)



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

留下一个回复

你的email不会被公开。