Java Code Examples for processing.core.PApplet#createGraphics()

The following examples show how to use processing.core.PApplet#createGraphics() . 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: DwUtils.java    From PixelFlow with MIT License 6 votes vote down vote up
static public PGraphics2D changeTextureSize(PApplet papplet, PGraphics2D pg, int w, int h, int smooth, boolean[] resized)
{   
  if(pg == null){
    pg = (PGraphics2D) papplet.createGraphics(w, h, PConstants.P2D);
    pg.smooth(smooth);
    resized[0] |= true;
  } else {
    resized[0] |= changeTextureSize(pg, w, h);
  }
  
  if(resized[0]){
    pg.loadTexture();
  }
  
  return pg;
}
 
Example 2
Source File: DwUtils.java    From PixelFlow with MIT License 6 votes vote down vote up
static public PGraphics2D changeTextureSize(PApplet papplet, PGraphics2D pg, int w, int h, int smooth, boolean[] resized,  int internal_format, int format, int type)
{   
  if(pg == null){
    pg = (PGraphics2D) papplet.createGraphics(w, h, PConstants.P2D);
    pg.smooth(smooth);
    resized[0] |= true;
  } else {
    resized[0] |= changeTextureSize(pg, w, h);
  }
  
  if(resized[0]){
    changeTextureFormat(pg, internal_format, format, type);
    pg.loadTexture();
  }

  return pg;
}
 
Example 3
Source File: VideoFrameGrabber.java    From haxademic with MIT License 6 votes vote down vote up
public VideoFrameGrabber( PApplet p, String videoFile, int frameRate, int startFrame ) {
		this.p = p;
		_videoFile = videoFile;
		_fps = frameRate;
		_startFrame = startFrame;
		
		// Load and set the video to play. Setting the video 
		// in play mode is needed so at least one frame is read
		// and we can get duration, size and other information from
		// the video stream. 
		initMovie();

//		_curFrameBuffer = p.createGraphics( _movie.width, _movie.height, P.P2D );
//		_curFrameImage = p.createImage( _movie.width, _movie.height, P.ARGB );

		_curFrameBuffer = p.createGraphics( p.width, p.height, P.P2D );
		_curFrameImage = p.createImage( p.width, p.height, P.ARGB );
	}
 
Example 4
Source File: DwUtils.java    From PixelFlow with MIT License 5 votes vote down vote up
static public PGraphics2D createCheckerBoard(PApplet papplet, int dimx, int dimy, int size, int colA, int colB){
  int num_x = (int) dimx/size;
  int num_y = (int) dimy/size;
  int off_x = (dimx - size *  num_x) / 2;
  int off_y = (dimy - size *  num_y) / 2;
  PGraphics2D pg = (PGraphics2D) papplet.createGraphics(dimx, dimy, PConstants.P2D);
  pg.smooth(0);
  pg.beginDraw();
  pg.blendMode(PConstants.REPLACE);
  pg.textureSampling(2);
  pg.noStroke();
  pg.fill(200);
  for(int y = -1; y < num_y+1; y++){
    for(int x = -1; x < num_x+1; x++){
      int px = off_x + x * size;
      int py = off_y + y * size;
      int col = (x ^ y) & 1;
      if(col == 1){
        pg.fill(colA);
      } else {
        pg.fill(colB);
      }
      pg.rect(px, py, size, size);
    }
  }
  pg.endDraw();
  return pg;
}
 
Example 5
Source File: CustomFontText2D_DEPRECATE.java    From haxademic with MIT License 5 votes vote down vote up
public CustomFontText2D_DEPRECATE( PApplet p, String fontFile, float fontSize, int color, int align, int canvasW, int canvasH ) {
	_fontSize = fontSize;
	_textLeading = (int) fontSize;
	_textColor = color;
	_textStroke = p.color(255);
	_font = p.createFont( fontFile, _fontSize );
	_textAlign = align;
	_textCanvas = p.createGraphics( canvasW, canvasH, P.P2D ); // P.P2D? Whay does this cause issues in Catchy?
	_textCanvas.smooth( OpenGLUtil.SMOOTH_MEDIUM );
}
 
Example 6
Source File: PerlinTexture.java    From haxademic with MIT License 4 votes vote down vote up
public PerlinTexture(PApplet p, int w, int h) {
	this.p = p;
	canvas = p.createGraphics(w, h, P.P3D);
}
 
Example 7
Source File: AbstractSketch.java    From sketch-mapper with MIT License 2 votes vote down vote up
/**
 * Constructor
 *
 * this creates a PGraphics object with the size provided in the parameters
 * and the renderer specified by {@link processing.core.PConstants#OPENGL}.
 *
 * @param parent the parent {@link processing.core.PApplet}.
 * @param width  the width of the sketch in pixels.
 * @param height the height of the sketch in pixels.
 */
public AbstractSketch(final PApplet parent, final int width, final int height) {
    this.parent = parent;
    this.graphics = parent.createGraphics(width, height, PConstants.OPENGL);
}