Processing, 類PShape
中的addChild()
用法介紹。
用法
sh.addChild(who)
sh.addChild(who, idx)
參數
sh
(PShape)
任何 PShape 類型的變量who
(PShape)
任何 PShape 類型的變量idx
(int)
插入新孩子的圖層位置
返回
void
說明
將子 PShape 添加到定義為 GROUP 的父 PShape。在示例中,將三個形狀 path
、 rectangle
和 circle
添加到名為 house
的父 PShape 變量中,該變量是一個 GROUP。
例子
PShape house;
void setup() {
size(200, 200);
// Make a group PShape
house = createShape(GROUP);
// Make three shapes
PShape path = createShape();
path.beginShape();
path.vertex(-20, -20);
path.vertex(0, -40);
path.vertex(20, -20);
path.endShape();
PShape rectangle = createShape(RECT, -20, -20, 40, 40);
PShape circle = createShape(ELLIPSE, 0, 0, 20, 20);
// Add all three as children
house.addChild(path);
house.addChild(rectangle);
house.addChild(circle);
}
void draw() {
background(52);
translate(mouseX, mouseY);
shape(house);
}
相關用法
- Processing PShape.enableStyle()用法及代碼示例
- Processing PShape.setStroke()用法及代碼示例
- Processing PShape.isVisible()用法及代碼示例
- Processing PShape.getChildCount()用法及代碼示例
- Processing PShape.getVertex()用法及代碼示例
- Processing PShape.resetMatrix()用法及代碼示例
- Processing PShape.rotateX()用法及代碼示例
- Processing PShape.getChild()用法及代碼示例
- Processing PShape.rotateY()用法及代碼示例
- Processing PShape.setVisible()用法及代碼示例
- Processing PShape.beginContour()用法及代碼示例
- Processing PShape.beginShape()用法及代碼示例
- Processing PShape.endShape()用法及代碼示例
- Processing PShape.getVertexCount()用法及代碼示例
- Processing PShape.setFill()用法及代碼示例
- Processing PShape.rotate()用法及代碼示例
- Processing PShape.endContour()用法及代碼示例
- Processing PShape.scale()用法及代碼示例
- Processing PShape.disableStyle()用法及代碼示例
- Processing PShape.translate()用法及代碼示例
- Processing PShape.setVertex()用法及代碼示例
- Processing PShape用法及代碼示例
- Processing PShader用法及代碼示例
- Processing Pulse用法及代碼示例
- Processing PVector.set()用法及代碼示例
注:本文由純淨天空篩選整理自processing.org大神的英文原創作品 PShape.addChild()。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。