use of processing.core.PImage in project processing by processing.
the class PShapeOpenGL method addChild.
@Override
public void addChild(PShape who) {
if (who instanceof PShapeOpenGL) {
if (family == GROUP) {
PShapeOpenGL c3d = (PShapeOpenGL) who;
super.addChild(c3d);
c3d.updateRoot(root);
markForTessellation();
if (c3d.family == GROUP) {
if (c3d.textures != null) {
for (PImage tex : c3d.textures) {
addTexture(tex);
}
} else {
untexChild(true);
}
if (c3d.strokedTexture) {
strokedTexture(true);
}
} else {
if (c3d.image != null) {
addTexture(c3d.image);
if (c3d.stroke) {
strokedTexture(true);
}
} else {
untexChild(true);
}
}
} else {
PGraphics.showWarning("Cannot add child shape to non-group shape.");
}
} else {
PGraphics.showWarning("Shape must be OpenGL to be added to the group.");
}
}
use of processing.core.PImage in project processing by processing.
the class PShapeOpenGL method addChild.
@Override
public void addChild(PShape who, int idx) {
if (who instanceof PShapeOpenGL) {
if (family == GROUP) {
PShapeOpenGL c3d = (PShapeOpenGL) who;
super.addChild(c3d, idx);
c3d.updateRoot(root);
markForTessellation();
if (c3d.family == GROUP) {
if (c3d.textures != null) {
for (PImage tex : c3d.textures) {
addTexture(tex);
}
} else {
untexChild(true);
}
if (c3d.strokedTexture) {
strokedTexture(true);
}
} else {
if (c3d.image != null) {
addTexture(c3d.image);
if (c3d.stroke) {
strokedTexture(true);
}
} else {
untexChild(true);
}
}
} else {
PGraphics.showWarning("Cannot add child shape to non-group shape.");
}
} else {
PGraphics.showWarning("Shape must be OpenGL to be added to the group.");
}
}
use of processing.core.PImage in project processing by processing.
the class PSurfaceJOGL method setCursor.
public void setCursor(int kind) {
if (!cursorNames.containsKey(kind)) {
PGraphics.showWarning("Unknown cursor type: " + kind);
return;
}
CursorInfo cursor = cursors.get(kind);
if (cursor == null) {
String name = cursorNames.get(kind);
if (name != null) {
ImageIcon icon = new ImageIcon(getClass().getResource("cursors/" + name + ".png"));
PImage img = new PImage(icon.getImage());
// Most cursors just use the center as the hotspot...
int x = img.width / 2;
int y = img.height / 2;
// ...others are more specific
if (kind == PConstants.ARROW) {
x = 10;
y = 7;
} else if (kind == PConstants.HAND) {
x = 12;
y = 8;
} else if (kind == PConstants.TEXT) {
x = 16;
y = 22;
}
cursor = new CursorInfo(img, x, y);
cursors.put(kind, cursor);
}
}
if (cursor != null) {
cursor.set();
} else {
PGraphics.showWarning("Cannot load cursor type: " + kind);
}
}
use of processing.core.PImage in project processing by processing.
the class PShapeOpenGL method setTextureImpl.
protected void setTextureImpl(PImage tex) {
PImage image0 = image;
image = tex;
if (textureMode == IMAGE && image0 != image) {
// Need to rescale the texture coordinates
float uFactor = 1;
float vFactor = 1;
if (image != null) {
uFactor /= image.width;
vFactor /= image.height;
}
if (image0 != null) {
uFactor *= image0.width;
vFactor *= image0.height;
}
scaleTextureUV(uFactor, vFactor);
}
if (image0 != tex && parent != null) {
((PShapeOpenGL) parent).removeTexture(image0, this);
}
if (parent != null) {
((PShapeOpenGL) parent).addTexture(image);
if (is2D() && stroke) {
((PShapeOpenGL) parent).strokedTexture(true);
}
}
}
use of processing.core.PImage in project hid-serial by rayshobby.
the class GCScheme method makeColorSchemes.
/**
* This method is called by the G4P GUI Builder tool when there is no
* sketch = no PApplet object to use
*/
public static void makeColorSchemes() {
// otherwise do nothing
if (palettes != null)
return;
// Load the image
PImage image = new PImage((new javax.swing.ImageIcon(new GCScheme().getClass().getResource("/data/default_gui_palette.png"))).getImage());
// Now make the palletes
palettes = new int[16][16];
jpalettes = new Color[16][16];
for (int p = 0; p < 16; p++) for (int c = 0; c < 16; c++) {
int col = image.get(c * 16 + 8, p * 16 + 8);
palettes[p][c] = col;
jpalettes[p][c] = new Color((col >> 16) & 0xff, (col >> 8) & 0xff, col & 0xff);
}
}
Aggregations