mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
Putting drawing methods from PShape3D in PShape, updated examples
This commit is contained in:
@@ -197,7 +197,8 @@ public class PShape implements PConstants {
|
||||
/** True if colorMode(RGB, 255) */
|
||||
boolean colorModeDefault; // = true;
|
||||
|
||||
|
||||
/** To mark the shape dirty upon changes in its geometry **/
|
||||
public boolean modified;
|
||||
|
||||
// should this be called vertices (consistent with PGraphics internals)
|
||||
// or does that hurt flexibility?
|
||||
@@ -389,7 +390,161 @@ public class PShape implements PConstants {
|
||||
public boolean is3D() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
//
|
||||
|
||||
// Drawing methods
|
||||
|
||||
public void texture(PImage tex) {
|
||||
}
|
||||
|
||||
public void noTexture() {
|
||||
}
|
||||
|
||||
public void solid(boolean solid) {
|
||||
}
|
||||
|
||||
public void beginContour() {
|
||||
}
|
||||
|
||||
public void endContour() {
|
||||
}
|
||||
|
||||
public void vertex(float x, float y) {
|
||||
}
|
||||
|
||||
|
||||
public void vertex(float x, float y, float z) {
|
||||
}
|
||||
|
||||
public void vertex(float x, float y, float z, float u, float v) {
|
||||
}
|
||||
|
||||
public void normal(float nx, float ny, float nz) {
|
||||
}
|
||||
|
||||
public void end() {
|
||||
}
|
||||
|
||||
public void end(int mode) {
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
// STROKE CAP/JOIN/WEIGHT
|
||||
|
||||
|
||||
public void strokeWeight(float weight) {
|
||||
}
|
||||
|
||||
public void strokeJoin(int join) {
|
||||
}
|
||||
|
||||
public void strokeCap(int cap) {
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
// FILL COLOR
|
||||
|
||||
public void noFill() {
|
||||
}
|
||||
|
||||
public void fill(int rgb) {
|
||||
}
|
||||
|
||||
public void fill(int rgb, float alpha) {
|
||||
}
|
||||
|
||||
public void fill(float gray) {
|
||||
}
|
||||
|
||||
public void fill(float gray, float alpha) {
|
||||
}
|
||||
|
||||
public void fill(float x, float y, float z) {
|
||||
}
|
||||
|
||||
public void fill(float x, float y, float z, float a) {
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
// STROKE COLOR
|
||||
|
||||
|
||||
public void noStroke() {
|
||||
}
|
||||
|
||||
public void stroke(int rgb) {
|
||||
}
|
||||
|
||||
public void stroke(int rgb, float alpha) {
|
||||
}
|
||||
|
||||
public void stroke(float gray) {
|
||||
}
|
||||
|
||||
public void stroke(float gray, float alpha) {
|
||||
}
|
||||
|
||||
public void stroke(float x, float y, float z) {
|
||||
}
|
||||
|
||||
public void stroke(float x, float y, float z, float alpha) {
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
//
|
||||
|
||||
// Bezier curves
|
||||
|
||||
|
||||
public void bezierDetail(int detail) {
|
||||
}
|
||||
|
||||
public void bezierVertex(float x2, float y2,
|
||||
float x3, float y3,
|
||||
float x4, float y4) {
|
||||
}
|
||||
|
||||
public void bezierVertex(float x2, float y2, float z2,
|
||||
float x3, float y3, float z3,
|
||||
float x4, float y4, float z4) {
|
||||
}
|
||||
|
||||
public void quadraticVertex(float cx, float cy,
|
||||
float x3, float y3) {
|
||||
}
|
||||
|
||||
public void quadraticVertex(float cx, float cy, float cz,
|
||||
float x3, float y3, float z3) {
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
//
|
||||
|
||||
// Catmull-Rom curves
|
||||
|
||||
public void curveDetail(int detail) {
|
||||
}
|
||||
|
||||
public void curveTightness(float tightness) {
|
||||
}
|
||||
|
||||
public void curveVertex(float x, float y) {
|
||||
}
|
||||
|
||||
public void curveVertex(float x, float y, float z) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
||||
|
||||
|
||||
@@ -915,13 +1070,11 @@ public class PShape implements PConstants {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
// public PShape createGroup() {
|
||||
// PShape group = new PShape();
|
||||
// group.kind = GROUP;
|
||||
// addChild(group);
|
||||
// return group;
|
||||
// }
|
||||
public void addShape(PShape child) {
|
||||
}
|
||||
|
||||
public void updateRoot(PShape root) {
|
||||
}
|
||||
|
||||
|
||||
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
size(100, 100, P3D);
|
||||
|
||||
PShape3D obj = (PShape3D)createShape(POLYGON);
|
||||
PShape obj = createShape(POLYGON);
|
||||
obj.fill(0, 255, 0, 255);
|
||||
obj.stroke(0, 0, 255, 255);
|
||||
obj.strokeWeight(5);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
PShape3D circle;
|
||||
PShape circle;
|
||||
|
||||
public void setup() {
|
||||
size(400, 400, P3D);
|
||||
@@ -7,7 +7,7 @@ public void setup() {
|
||||
fill(255, 0, 0);
|
||||
stroke(0, 0, 255);
|
||||
strokeWeight(3);
|
||||
circle = (PShape3D) createShape(ELLIPSE, 0, 0, 100, 100);
|
||||
circle = createShape(ELLIPSE, 0, 0, 100, 100);
|
||||
}
|
||||
|
||||
public void draw () {
|
||||
@@ -18,7 +18,6 @@ public void draw () {
|
||||
circle.stroke(0, 0, map(mouseY, 0, height, 255, 0));
|
||||
}
|
||||
|
||||
|
||||
translate(mouseX, mouseY);
|
||||
shape(circle);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
size(100, 100, P3D);
|
||||
smooth();
|
||||
|
||||
PShape3D obj = (PShape3D)createShape();
|
||||
PShape obj = createShape();
|
||||
obj.noFill();
|
||||
obj.stroke(0);
|
||||
obj.strokeWeight(1);
|
||||
|
||||
@@ -294,6 +294,27 @@ public class PShape3D extends PShape {
|
||||
}
|
||||
}
|
||||
|
||||
public void addShape(PShape child) {
|
||||
if (family == GROUP) {
|
||||
super.addChild(child);
|
||||
child.updateRoot(root);
|
||||
root.modified = true;
|
||||
modified = true;
|
||||
child.modified = true;
|
||||
} else {
|
||||
PGraphics.showWarning("Cannot add child shape to non-group shape.");
|
||||
}
|
||||
}
|
||||
|
||||
public void updateRoot(PShape root) {
|
||||
this.root = (PShape3D) root;
|
||||
if (family == GROUP) {
|
||||
for (int i = 0; i < childCount; i++) {
|
||||
PShape3D child = (PShape3D)children[i];
|
||||
child.updateRoot(root);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void finalize() throws Throwable {
|
||||
try {
|
||||
@@ -1651,28 +1672,6 @@ public class PShape3D extends PShape {
|
||||
getGl().glBindBuffer(GL.GL_ARRAY_BUFFER, 0);
|
||||
}
|
||||
|
||||
public void addShape(PShape3D child) {
|
||||
if (family == GROUP) {
|
||||
super.addChild(child);
|
||||
child.updateRoot(root);
|
||||
root.modified = true;
|
||||
modified = true;
|
||||
child.modified = true;
|
||||
} else {
|
||||
PGraphics.showWarning("Cannot add child shape to non-group shape.");
|
||||
}
|
||||
}
|
||||
|
||||
private void updateRoot(PShape3D root) {
|
||||
this.root = root;
|
||||
if (family == GROUP) {
|
||||
for (int i = 0; i < childCount; i++) {
|
||||
PShape3D child = (PShape3D)children[i];
|
||||
child.updateRoot(root);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
Reference in New Issue
Block a user