Search in sources :

Example 6 with PImage

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.");
    }
}
Also used : PImage(processing.core.PImage)

Example 7 with PImage

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.");
    }
}
Also used : PImage(processing.core.PImage)

Example 8 with PImage

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);
    }
}
Also used : PImage(processing.core.PImage) ImageIcon(javax.swing.ImageIcon) Point(java.awt.Point)

Example 9 with PImage

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);
        }
    }
}
Also used : PImage(processing.core.PImage)

Example 10 with PImage

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);
    }
}
Also used : PImage(processing.core.PImage) Color(java.awt.Color)

Aggregations

PImage (processing.core.PImage)17 Color (java.awt.Color)4 File (java.io.File)2 Image (java.awt.Image)1 Point (java.awt.Point)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 Method (java.lang.reflect.Method)1 ImageIcon (javax.swing.ImageIcon)1 SunburstItem (org.sirix.gui.view.sunburst.SunburstItem)1