processing.core.PGraphics Java Examples

The following examples show how to use processing.core.PGraphics. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WashHands.java    From haxademic with MIT License 6 votes vote down vote up
public void update(PGraphics pg) {
			if(available()) return;
			
			pg.sphereDetail(6);
			
			// update position
			speed.add(gravity);
			pos.add(speed);
			
			// update size
			sizeProgress.update();
			float curSize = size * Penner.easeOutExpo(sizeProgress.value());
			if(sizeProgress.value() == 1) sizeProgress.setTarget(0);
			
			// draw image
			pg.pushMatrix();
			pg.translate(pos.x, pos.y, pos.z);
			pg.rotateY(rotationMin);
			pg.fill(color);
			pg.box(curSize, curSize, curSize);
//			pg.sphere(curSize);
			pg.fill(255);
			pg.popMatrix();
		}
 
Example #2
Source File: DwSoftGrid3D.java    From PixelFlow with MIT License 6 votes vote down vote up
private PShape createShape(PGraphics pg){
  PShape shp = pg.createShape(PConstants.GROUP);

  PShape[] shp_grid = new PShape[6];
  for(int i = 0; i < shp_grid.length; i++){
    shp_grid[i] = pg.createShape();
    shp.addChild(shp_grid[i]);
  }
  
  shp_grid[0].setName("gridXYp");
  shp_grid[1].setName("gridXYn");
  shp_grid[2].setName("gridYZp");
  shp_grid[3].setName("gridYZn");
  shp_grid[4].setName("gridXZp");
  shp_grid[5].setName("gridXZn");

                  displayGridXY(shp_grid[0], normals[0], 0        , texture_XYp);
  if(nodes_z > 1) displayGridXY(shp_grid[1], normals[1], nodes_z-1, texture_XYn);
                  displayGridYZ(shp_grid[2], normals[2], 0        , texture_YZp);
  if(nodes_x > 1) displayGridYZ(shp_grid[3], normals[3], nodes_x-1, texture_YZn);
                  displayGridXZ(shp_grid[4], normals[4], 0        , texture_XZp);
  if(nodes_y > 1) displayGridXZ(shp_grid[5], normals[5], nodes_y-1, texture_XZn);
  return shp;
}
 
Example #3
Source File: BlackHole.java    From haxademic with MIT License 6 votes vote down vote up
protected void initImages() {
	images = new PImage[] {
			p.loadImage(FileUtil.getPath("images/black-holes/2014-06-11-black.jpg")),
			p.loadImage(FileUtil.getPath("images/black-holes/15084150039_299e5e4ed6_o.jpg")),
			p.loadImage(FileUtil.getPath("images/black-holes/behemoth_blackhole.jpg")),
			p.loadImage(FileUtil.getPath("images/black-holes/BlackHole.jpg"))
	};
	
	buffers = new PGraphics[4];
	for (int i = 0; i < buffers.length; i++) {
		buffers[i] = p.createGraphics(p.width * 2, p.height * 2, P.P2D);
		ImageUtil.imageToGraphicsCropFill(images[i], buffers[i]);
		VignetteFilter.instance(p).setDarkness(0.99f);
		VignetteFilter.instance(p).setSpread(0.7f);
		VignetteFilter.instance(p).applyTo(buffers[i]);
		ChromaColorFilter.instance(p).presetBlackKnockout();
		ChromaColorFilter.instance(p).applyTo(buffers[i]);
	}
}
 
Example #4
Source File: ShaderVertexSvgDeform.java    From haxademic with MIT License 6 votes vote down vote up
protected void firstFrame() {
	
		p.smooth( OpenGLUtil.SMOOTH_HIGH );
		
		// create dynamic deformation texture
//		audioTexture = new TextureEQGrid(800, 800);
		perlinTexture = new PerlinTexture(p, 200, 200);
		audioTexture = new TextureEQConcentricCircles(200, 200);
		PGraphics displacementMap = (_isAudio == true) ? audioTexture.texture() : perlinTexture.texture();
		
		// create geometry
		shape = p.loadShape( FileUtil.getPath("svg/ello-centered.svg"));
		shape = PShapeUtil.clonePShape(this, shape.getTessellation());
		PShapeUtil.scaleShapeToExtent(shape, p.height * 0.3f);
		PShapeUtil.addTextureUVToShape(shape, displacementMap);
		shape.setTexture(displacementMap);
	}
 
Example #5
Source File: WashHands.java    From haxademic with MIT License 6 votes vote down vote up
public void update(PGraphics pg) {
	pg.push();
	pg.translate(pg.width * x, pg.height * y, 0);	// -0.25f   -0.33f
	if(FrameLoop.isTick()) {
		if(FrameLoop.curTick() == tickShow) wordWashEase.setInc(0.07f).setTarget(1);
		if(FrameLoop.curTick() == tickShow + 4) wordWashEase.setInc(0.04f).setTarget(0);
		if(tickShow == 4 && FrameLoop.curTick() % 8 == 0)  wordWashEase.setInc(0.04f).setTarget(0);
	}
	wordWashEase.update();
	float easedProgress = Penner.easeInOutExpo(wordWashEase.value());
	pg.rotateY(rotY + FrameLoop.osc(0.125f, -0.2f, 0.2f));  // 0.4f
	if(tickShow != 4) pg.rotateX(rotX + FrameLoop.osc(0.225f, -0.05f, 0.05f));  // -0.1f
	else pg.rotateX(rotX*1.5f);
	pg.scale(easedProgress);
	pg.shape(wordWash);
	pg.pop();
}
 
Example #6
Source File: PG.java    From haxademic with MIT License 6 votes vote down vote up
public static void drawStrokedRect(PGraphics pg, float w, float h, float strokeWeight, int colorBg, int colorStroke) {
	int prevRectMode = pg.rectMode;
	pg.push();
	
	// make sure rect stroke is drawing from the same top left as rect bg
	if(prevRectMode == PConstants.CENTER) pg.translate(P.round(-w/2), P.round(-h/2));
	pg.rectMode(PConstants.CORNER);
	
	// rect bg
	pg.noStroke();
	pg.fill(colorBg);
	pg.rect(0, 0, w, h);
	
	// pixel-perfect stroke by drawing 4 rects
	pg.fill(colorStroke);
	pg.rect(0, 0, w, strokeWeight);					// top
	pg.rect(0, h - strokeWeight, w, strokeWeight);	// bottom
	pg.rect(0, 0, strokeWeight, h);					// left
	pg.rect(w - strokeWeight, 0, strokeWeight, h);	// right
	pg.rectMode(prevRectMode);						// reset rectMode to whatever it was before

	pg.pop();
}
 
Example #7
Source File: Silhouect.java    From haxademic with MIT License 6 votes vote down vote up
protected void storeUserFrame() {
	if(noUser == false && flashFrame == true) {
		// if user, add a frame to the array
		if(lastUserBuffer.size() < USER_HISTORY_SIZE) {
			PGraphics newUserBuffer = p.createGraphics(userBuffer.width, userBuffer.height, PRenderers.P2D); 
			if(lastUserBuffer.size() == 0) slideshow.add(newUserBuffer);	// add a single PGraphics to end of slideshow array
			lastUserBuffer.add(newUserBuffer);
			userHistoryStorageIndex = lastUserBuffer.size() - 1;
		} else {
			userHistoryStorageIndex++;
			if(userHistoryStorageIndex >= lastUserBuffer.size()) userHistoryStorageIndex = 0;
		}
		
		// draw current frame to oldest buffer
		PGraphics oldBuffer = lastUserBuffer.get(userHistoryStorageIndex);
		oldBuffer.beginDraw();
		oldBuffer.clear();
		oldBuffer.copy(userBuffer, 0, 0, userBuffer.width, userBuffer.height, 0, 0, oldBuffer.width, oldBuffer.height);
		oldBuffer.endDraw();
	}
}
 
Example #8
Source File: PbezierTangent.java    From warp10-platform with Apache License 2.0 6 votes vote down vote up
@Override
public Object apply(WarpScriptStack stack) throws WarpScriptException {
  
  List<Object> params = ProcessingUtil.parseParams(stack, 5);
      
  PGraphics pg = (PGraphics) params.get(0);
  
  float f = pg.parent.bezierTangent(
    ((Number) params.get(1)).floatValue(),
    ((Number) params.get(2)).floatValue(),
    ((Number) params.get(3)).floatValue(),
    ((Number) params.get(4)).floatValue(),
    ((Number) params.get(5)).floatValue()
  );      
  
  stack.push(pg);
  stack.push((double) f);
      
  return stack;
}
 
Example #9
Source File: Demo_TexturedStripsPShape.java    From haxademic with MIT License 5 votes vote down vote up
protected void firstFrame() {
	// load movie
	if(videoMap) {
		testMovie = DemoAssets.movieKinectSilhouette();
		testMovie.jump(0);
		testMovie.loop();
	} else {
		staticImg = DemoAssets.squareTexture();
	}
	
	// load map & build buffer
	bwMap = p.createGraphics(p.width, p.height, PRenderers.P3D);
	
	// load thread textures
	threadTexturesSource = new PImage[] {
			DemoAssets.textureJupiter(),
			DemoAssets.textureNebula(),
			DemoAssets.squareTexture(),
			DemoAssets.justin(),
	};
	threadTextures = new PGraphics[] {
			p.createGraphics(8, 512, P.P2D),
			p.createGraphics(8, 512, P.P2D),
			p.createGraphics(8, 512, P.P2D),
			p.createGraphics(8, 512, P.P2D),
	};
	for (int i = 0; i < threadTextures.length; i++) {
		ImageUtil.cropFillCopyImage(threadTexturesSource[i], threadTextures[i], true);
	}
	
	// build particles
	particles = new ArrayList<Particle>();
	for (int i = 0; i < numParticles; i++) {
		particles.add(new Particle());
	}
	
}
 
Example #10
Source File: MultiSimpleCalibrator.java    From PapARt with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static void sin(PApplet parent, PGraphics g, int amt, float freq, int xDiff, float size) {
    float v = (PApplet.sin((float) (parent.millis()) / 1000f * PConstants.TWO_PI * freq) + 1f) / 2f;
    g.noStroke();
    g.ellipseMode(CENTER);
    g.fill(v * amt);
    g.ellipse(-xDiff, 0, size, size);
    g.ellipse(0, 0, size, size);
    g.ellipse(xDiff, 0, size, size);
}
 
Example #11
Source File: SavedRectangle.java    From haxademic with MIT License 5 votes vote down vote up
public void drawDebugToPG(PGraphics pg, boolean drawInPlace) {
	int x = (drawInPlace == true) ? 0 : x();
	int y = (drawInPlace == true) ? 0 : y();
	if(isDragging() == true) 
		pg.fill(255, 100); 
	else 
		pg.fill(0,100,0, 100);
	pg.rect(x, y, width(), height());
	pg.fill(255);
	pg.text(""+x()+", "+y()+", "+width()+", "+height(), x + 10, y + 20);
}
 
Example #12
Source File: Pblend.java    From warp10-platform with Apache License 2.0 5 votes vote down vote up
private int getBlendMode(String mode) throws WarpScriptException {
  if ("BLEND".equals(mode)) {
    return(PGraphics.BLEND);
  } else if ("ADD".equals(mode)) {
    return(PGraphics.ADD);
  } else if ("SUBTRACT".equals(mode)) {
    return(PGraphics.SUBTRACT);
  } else if ("DARKEST".equals(mode)) {
    return(PGraphics.DARKEST);
  } else if ("LIGHTEST".equals(mode)) {
    return(PGraphics.LIGHTEST);
  } else if ("DIFFERENCE".equals(mode)) {
    return(PGraphics.DIFFERENCE);
  } else if ("EXCLUSION".equals(mode)) {
    return(PGraphics.EXCLUSION);
  } else if ("MULTIPLY".equals(mode)) {
    return(PGraphics.MULTIPLY);
  } else if ("SCREEN".equals(mode)) {
    return(PGraphics.SCREEN);
  } else if ("OVERLAY".equals(mode)) {
    return(PGraphics.OVERLAY);
  } else if ("HARD_LIGHT".equals(mode)) {
    return(PGraphics.HARD_LIGHT);
  } else if ("SOFT_LIGHT".equals(mode)) {
    return(PGraphics.SOFT_LIGHT);
  } else if ("DODGE".equals(mode)) {
    return(PGraphics.DODGE);
  } else if ("BURN".equals(mode)) {
    return(PGraphics.BURN);
  } else {
    throw new WarpScriptException(getName() + ": invalid mode, should be 'BLEND', 'ADD', 'SUBTRACT', 'DARKEST', 'LIGHTEST', 'DIFFERENCE', 'EXCLUSION', 'MULTIPLY', 'SCREEN', 'OVERLAY', 'HARD_LIGHT', 'SOFT_LIGHT', 'DODGE' or 'BURN'.");
  }
}
 
Example #13
Source File: BaseSavedQuadUI.java    From haxademic with MIT License 5 votes vote down vote up
public void drawDebug(PGraphics pg, boolean offscreen) {
	if(active && P.p.millis() < lastInteractTime + INTERACTION_TIMEOUT)  {
		if(offscreen) pg.beginDraw();
		showSelectedPoint(pg);
		showMappedRect(pg);
		if(offscreen) pg.endDraw();
	}
}
 
Example #14
Source File: DwSoftBall2D.java    From PixelFlow with MIT License 5 votes vote down vote up
@Override
public void createShapeWireframe(PGraphics pg, DwStrokeStyle style){
  PShape shp = createShape(pg);
  
  shp.setTexture(null);
  shp.setFill(false);
  shp.setStroke(true);
  shp.setStroke(style.stroke_color);
  shp.setStrokeWeight(style.stroke_weight);
  setShapeWireframe(pg.parent, shp);
}
 
Example #15
Source File: Shapes.java    From haxademic with MIT License 5 votes vote down vote up
public static void cylinderBetween( PGraphics pg, PVector point1, PVector point2, int resolution, float radius, float radiusBot ) {
	pg.pushMatrix();
		
	// set orientation 
	OrientationUtil.setMidPoint(pg, point1, point2);
	OrientationUtil.setRotationTowards(pg, point1, point2);

	// draw box
	Shapes.drawCylinder(pg, resolution, radius, radiusBot, point1.dist(point2), false);

	pg.popMatrix(); 
}
 
Example #16
Source File: AudioInputESS.java    From haxademic with MIT License 5 votes vote down vote up
public void update(PGraphics pg) {
	if(rendering) return; // don't override with microphone data
	
	// update audio data object
	audioStreamData.setFFTFrequencies(fft.spectrum);
	audioStreamData.setWaveformOffsets(audioInput.buffer);
	audioStreamData.setAmp(fft.getLevel(audioInput));
	audioStreamData.freqsCopyDampened();
	audioStreamData.update();

	// debug draw
	if(pg != null) audioStreamData.drawDebug(pg);
}
 
Example #17
Source File: ConstellationPointMarker.java    From constellation with Apache License 2.0 5 votes vote down vote up
@Override
public boolean draw(final PGraphics graphics, final List<MapPosition> positions, final UnfoldingMap map) {
    if (positions.isEmpty() || isHidden()) {
        return false;
    }

    final float x = positions.get(0).x;
    final float y = positions.get(0).y;

    graphics.pushStyle();

    if (size > MarkerUtilities.DEFAULT_SIZE) {
        graphics.strokeWeight(strokeWeight);
        graphics.stroke(strokeColor);
        graphics.fill(getFillColor());
        graphics.ellipseMode(PConstants.RADIUS);
        graphics.ellipse(x, y, size, size);
    } else {
        TEMPLATE_IMAGE.loadPixels();
        for (int i = 0; i < TEMPLATE_IMAGE.width * TEMPLATE_IMAGE.height; i++) {
            final int[] pixelArgb = MarkerUtilities.argb(TEMPLATE_IMAGE.pixels[i]);
            if (!(pixelArgb[0] == 0 || (pixelArgb[1] == 0 && pixelArgb[2] == 0 && pixelArgb[3] == 0))) {
                TEMPLATE_IMAGE.pixels[i] = getFillColor();
            }
        }
        TEMPLATE_IMAGE.updatePixels();

        graphics.imageMode(PConstants.CORNER);
        graphics.image(TEMPLATE_IMAGE, x - POINT_X_OFFSET, y - POINT_Y_OFFSET);
    }

    graphics.popStyle();

    return true;
}
 
Example #18
Source File: ImageUtil.java    From haxademic with MIT License 5 votes vote down vote up
public static void removeImageFromGraphicsCache(PImage img, PGraphics pg) {
		// https://forum.processing.org/two/discussion/6898/how-to-correctly-release-pimage-memory
		// https://github.com/jeffThompson/ProcessingTeachingSketches/blob/master/Utilities/AvoidPImageMemoryLeaks/AvoidPImageMemoryLeaks.pde
		// https://forum.processing.org/one/topic/pimage-memory-leak-example.html
//		for (int i = 0; i < imageSequence.size(); i++) {
			Object cache = pg.getCache(img);
			pg.removeCache(img);
			if (cache instanceof Texture) {
				((Texture) cache).disposeSourceBuffer();
			}
//		}
//		imageSequence.clear();
	}
 
Example #19
Source File: DwSoftGrid3D.java    From PixelFlow with MIT License 5 votes vote down vote up
private void displayNormalsYZ(PGraphics pg, float[][] normals, int ix, float nlen){
  pg.beginShape(PConstants.LINES);
  for(int iz = 0; iz < nodes_z; iz++){
    for(int iy = 0; iy < nodes_y; iy++){
      normal(pg, getNode3D(ix, iy, iz), normals[iz * nodes_y + iy], nlen);
    }
  }
  pg.endShape();
}
 
Example #20
Source File: DwSoftGrid3D.java    From PixelFlow with MIT License 5 votes vote down vote up
@Override
public void displayNormals(PGraphics pg){
                  displayNormalsXY(pg, normals[0], 0        ,  display_normal_length);
  if(nodes_z > 1) displayNormalsXY(pg, normals[1], nodes_z-1, -display_normal_length);
                  displayNormalsYZ(pg, normals[2], 0        ,  display_normal_length);
  if(nodes_x > 1) displayNormalsYZ(pg, normals[3], nodes_x-1, -display_normal_length);
                  displayNormalsXZ(pg, normals[4], 0        , -display_normal_length); // y inverted
  if(nodes_y > 1) displayNormalsXZ(pg, normals[5], nodes_y-1, +display_normal_length); // y inverted
}
 
Example #21
Source File: DwUtils.java    From PixelFlow with MIT License 5 votes vote down vote up
static public void endScreen2D(PGraphics pg){
  if(pg.isGL() && pg.is3D()){
    PGraphicsOpenGL pgl = (PGraphicsOpenGL)pg;
    pgl.popProjection();
    pgl.lights = pushed_lights;
  }
  pg.popMatrix();
  pg.hint(PConstants.ENABLE_DEPTH_TEST);
  pg.popStyle();
}
 
Example #22
Source File: ImageUtil.java    From haxademic with MIT License 5 votes vote down vote up
public static void drawImageCropFillRotated90deg(PImage img, PGraphics dest, boolean cropFill, boolean positive, boolean openDestContext) {
	float ratioW = MathUtil.scaleToTarget(img.height, dest.width);
	float ratioH = MathUtil.scaleToTarget(img.width, dest.height);
	float scale = (ratioH < ratioW) ? ratioH : ratioW;				// letterbox
	if(cropFill) scale = (ratioH > ratioW) ? ratioH : ratioW;		// crop fill
	if(openDestContext) dest.beginDraw();
	PG.push(dest);
	PG.setDrawCenter(dest);
	PG.setCenterScreen(dest);
	dest.rotate(P.HALF_PI * ((positive) ? 1f : -1f));
	dest.image(img, 0, 0, img.width * scale, img.height * scale);
	PG.setDrawCorner(dest);
	PG.pop(dest);
	if(openDestContext) dest.endDraw();
}
 
Example #23
Source File: AudioInputBeads.java    From haxademic with MIT License 5 votes vote down vote up
public void update(PGraphics pg) {
	// get FFT spectrum from Beads
	if(ps == null) return;
	float[] features = ps.getFeatures();
	
	// update audio data object
	if(features != null) {
		// make a lower-amplitude copy
		if(freqs == null) freqs = new float[features.length];
		for (int i = 0; i < features.length; i++) {
			freqs[i] = features[i] * 15f * window(features.length, i);
		}
		
		audioStreamData.setFFTFrequencies(freqs);
		audioStreamData.calcFreqsDampened();
	}
	if(audioInput) {
		audioStreamData.setWaveformOffsets(gain.getOutBuffer(0));
	} else {
		audioStreamData.setWaveformOffsets(ac.out.getOutBuffer(0));
	}
	if(beatDirty && P.p.millis() > lastBeatTime + beatTimeThresh) {
		lastBeatTime = P.p.millis();
		beatDirty = false;
		audioStreamData.setBeat();
	}

	// audioStreamData.setAmp(od.getLastOnsetValue());
	audioStreamData.calcAmpAverage();
	audioStreamData.update();

	// debug draw
	if(pg != null) audioStreamData.drawDebug(pg);
}
 
Example #24
Source File: DwDisplayUtils.java    From PixelFlow with MIT License 5 votes vote down vote up
static public final void normal(PGraphics pg,float[] v0, float[] n, float len){
  if(pg.is2D()){
    pg.vertex(v0[0]           , v0[1]           ); 
    pg.vertex(v0[0] + n[0]*len, v0[1] + n[1]*len); 
  } else {
    pg.vertex(v0[0]           , v0[1]           , v0[2]           ); 
    pg.vertex(v0[0] + n[0]*len, v0[1] + n[1]*len, v0[2] + n[2]*len); 
  }
}
 
Example #25
Source File: DwFoldingTile.java    From PixelFlow with MIT License 5 votes vote down vote up
public void displayMesh(PGraphics pg, DwIndexedFaceSet ifs){
//    pg.beginShape(PConstants.TRIANGLES);
    pg.textureMode(PConstants.NORMAL);
    pg.texture(DEF.style.texture);
    pg.noStroke();
    int     s0,s1,s2;
    int     i0,i1,i2;
    float[] t0,t1,t2;
    float[] v0,v1,v2;
    for(int i = 0; i < DEF.FACES_COUNT; i++){
      i0 = faces[i][0];  v0 = ifs.verts[i0];
      i1 = faces[i][1];  v1 = ifs.verts[i1];
      i2 = faces[i][2];  v2 = ifs.verts[i2];
      
      i0 = DEF.FACES[i][0]; s0 = DEF.HILO[i0];  t0 = DEF.TEX_COORDS[i0];
      i1 = DEF.FACES[i][1]; s1 = DEF.HILO[i1];  t1 = DEF.TEX_COORDS[i1];
      i2 = DEF.FACES[i][2]; s2 = DEF.HILO[i2];  t2 = DEF.TEX_COORDS[i2];
      
      int ci = DEF.FACES_COL[i];
      
      if(DEF.style.texture != null){
        DwDisplayUtils.vertex(pg, v0, t0); 
        DwDisplayUtils.vertex(pg, v1, t1); 
        DwDisplayUtils.vertex(pg, v2, t2); 
      } else {
//        pg.fill(DEF.style.COL[s0]); DwDisplayUtils.vertex(pg, v0);
//        pg.fill(DEF.style.COL[s1]); DwDisplayUtils.vertex(pg, v1);
//        pg.fill(DEF.style.COL[s2]); DwDisplayUtils.vertex(pg, v2);
        pg.fill(DEF.style.RGBS[ci][s0]); DwDisplayUtils.vertex(pg, v0);
        pg.fill(DEF.style.RGBS[ci][s1]); DwDisplayUtils.vertex(pg, v1);
        pg.fill(DEF.style.RGBS[ci][s2]); DwDisplayUtils.vertex(pg, v2);
      }
    }
//    pg.endShape();
  }
 
Example #26
Source File: DwFoldingTile.java    From PixelFlow with MIT License 5 votes vote down vote up
public void displayMesh(PGraphics pg, DwParticle3D[] particles){
//    pg.beginShape(PConstants.TRIANGLES);
    pg.textureMode(PConstants.NORMAL);
    pg.texture(DEF.style.texture);
    pg.noStroke();
    int          s0,s1,s2;
    int          i0,i1,i2;
    float[]      t0,t1,t2;
    DwParticle3D v0,v1,v2;
    for(int i = 0; i < DEF.FACES_COUNT; i++){
      i0 = faces[i][0];  v0 = particles[i0];  if(v0.all_springs_deactivated) continue;
      i1 = faces[i][1];  v1 = particles[i1];  if(v1.all_springs_deactivated) continue;
      i2 = faces[i][2];  v2 = particles[i2];  if(v2.all_springs_deactivated) continue;
      
      i0 = DEF.FACES[i][0]; s0 = DEF.HILO[i0];  t0 = DEF.TEX_COORDS[i0];
      i1 = DEF.FACES[i][1]; s1 = DEF.HILO[i1];  t1 = DEF.TEX_COORDS[i1];
      i2 = DEF.FACES[i][2]; s2 = DEF.HILO[i2];  t2 = DEF.TEX_COORDS[i2];
      
      int ci = DEF.FACES_COL[i];
      
      if(DEF.style.texture != null){
        DwDisplayUtils.vertex(pg, v0, t0); 
        DwDisplayUtils.vertex(pg, v1, t1); 
        DwDisplayUtils.vertex(pg, v2, t2); 
      } else {
//        pg.fill(DEF.style.COL[s0]); DwDisplayUtils.vertex(pg, v0);
//        pg.fill(DEF.style.COL[s1]); DwDisplayUtils.vertex(pg, v1);
//        pg.fill(DEF.style.COL[s2]); DwDisplayUtils.vertex(pg, v2);
 
        pg.fill(DEF.style.RGBS[ci][s0]); DwDisplayUtils.vertex(pg, v0);
        pg.fill(DEF.style.RGBS[ci][s1]); DwDisplayUtils.vertex(pg, v1);
        pg.fill(DEF.style.RGBS[ci][s2]); DwDisplayUtils.vertex(pg, v2);
      }
    }
//    pg.endShape();
  }
 
Example #27
Source File: MoireProposal.java    From haxademic with MIT License 5 votes vote down vote up
public void drawNumberToTexture(String str, PGraphics tex) {
	tex.beginDraw();
	tex.fill(0);
	tex.textFont(font);
	tex.textAlign(P.CENTER, P.TOP);
	tex.text(str, 0, p.height * 0.2f, p.width, p.height * 0.8f);
	tex.endDraw();
}
 
Example #28
Source File: Pblend.java    From warp10-platform with Apache License 2.0 5 votes vote down vote up
@Override
public Object apply(WarpScriptStack stack) throws WarpScriptException {
  
  List<Object> params = ProcessingUtil.parseParams(stack, 9, 10);
      
  PGraphics pg = (PGraphics) params.get(0);
  
  if (10 == params.size()) {
    pg.parent.blend(
      ((Number) params.get(1)).intValue(),
      ((Number) params.get(2)).intValue(),
      ((Number) params.get(3)).intValue(),
      ((Number) params.get(4)).intValue(),
      ((Number) params.get(5)).intValue(),
      ((Number) params.get(6)).intValue(),
      ((Number) params.get(7)).intValue(),
      ((Number) params.get(8)).intValue(),
      getBlendMode((String) params.get(9))
    );
  } else if (11 == params.size()) {
    pg.parent.blend(        
      (PImage) params.get(1),
      ((Number) params.get(2)).intValue(),
      ((Number) params.get(3)).intValue(),
      ((Number) params.get(4)).intValue(),
      ((Number) params.get(5)).intValue(),
      ((Number) params.get(6)).intValue(),
      ((Number) params.get(7)).intValue(),
      ((Number) params.get(8)).intValue(),
      ((Number) params.get(9)).intValue(),
      getBlendMode((String) params.get(10))
    );
  }
  
  stack.push(pg);
      
  return stack;
}
 
Example #29
Source File: Demo_DropShadowBlur.java    From haxademic with MIT License 5 votes vote down vote up
public PGraphics imageToImageWithPadding(PImage img, float scaleCanvasUp) {
	PGraphics pg = PG.newPG(P.ceil((float) img.width * scaleCanvasUp), P.ceil((float) img.height * scaleCanvasUp));
	pg.beginDraw();
	PG.setDrawCenter(pg);
	pg.clear();
	pg.translate(pg.width/2, pg.height/2);
	pg.image(img, 0, 0);
	pg.endDraw();
	return pg;
}
 
Example #30
Source File: Polygon.java    From haxademic with MIT License 5 votes vote down vote up
public void draw(PGraphics pg, boolean debug) {
		updateEdges();
		updateAnim();
		if(!debug) {
			drawShapeBg(pg);
			drawEdges(pg);
		} else {
			drawShapeOutline(pg);
			drawNeighborDebug(pg);
			drawCentroid(pg);
		}
//		drawMouseOver(pg);
	}