Skip to content

Instantly share code, notes, and snippets.

@osdrv
Created March 21, 2012 06:16
Show Gist options
  • Save osdrv/2145153 to your computer and use it in GitHub Desktop.
Save osdrv/2145153 to your computer and use it in GitHub Desktop.
public void withTranslate( float tx, float ty, Runnable scope_runner ) {
pushMatrix();
translate( tx, ty );
scope_runner.run();
popMatrix();
}
public void withTranslate( float tx, float ty, float tz, Runnable scope_runner ) {
pushMatrix();
translate( tx, ty, tz );
scope_runner.run();
popMatrix();
}
public void withRotate( float angle, Runnable scope_runner ) {
pushMatrix();
rotate( angle );
scope_runner.run();
popMatrix();
}
public void withRotateX( float angle, Runnable scope_runner ) {
pushMatrix();
rotateX( angle );
scope_runner.run();
popMatrix();
}
public void withRotateY( float angle, Runnable scope_runner ) {
pushMatrix();
rotateY( angle );
scope_runner.run();
popMatrix();
}
public void withRotateZ( float angle, Runnable scope_runner ) {
pushMatrix();
rotateZ( angle );
scope_runner.run();
popMatrix();
}
public void withRotate( float angle, float vx, float vy, float vz, Runnable scope_runner ) {
pushMatrix();
rotate( angle, vx, vy, vz );
scope_runner.run();
popMatrix();
}
public void withScale( float s, Runnable scope_runner ) {
pushMatrix();
scale( s );
scope_runner.run();
popMatrix();
}
public void withScale( float sx, float sy, Runnable scope_runner ) {
pushMatrix();
scale( sx, sy );
scope_runner.run();
popMatrix();
}
public void withScale( float sx, float sy, float sz, Runnable scope_runner ) {
pushMatrix();
pushMatrix();
scale( sx, sy, sz );
scope_runner.run();
popMatrix();
}
public void withShearX( float angle, Runnable scope_runner ) {
pushMatrix();
shearX( angle );
scope_runner.run();
popMatrix();
}
public void withShearY( float angle, Runnable scope_runner ) {
pushMatrix();
shearY( angle );
scope_runner.run();
popMatrix();
}
public void withRectMode( int mode, Runnable scope_runner ) {
final int current_mode = g.rectMode;
rectMode( mode );
scope_runner.run();
rectMode( current_mode );
}
public void withEllipseMode( int mode, Runnable scope_runner ) {
final int current_mode = g.ellipseMode;
ellipseMode( mode );
scope_runner.run();
ellipseMode( current_mode );
}
public void withTextFont( PFont font, float size, Runnable scope_runner ) {
final PFont current_font = g.textFont;
final float current_text_size = g.textSize;
textFont( font, size );
scope_runner.run();
if ( current_font != null )
textFont( current_font, current_text_size );
}
public void withTextFont( PFont font, Runnable scope_runner ) {
final PFont current_font = g.textFont;
textFont( font );
scope_runner.run();
textFont( current_font );
}
public void withShapeMode( int mode, Runnable scope_runner ) {
final int current_mode = g.shapeMode;
shapeMode( mode );
scope_runner.run();
shapeMode( current_mode );
}
public void withImageMode( int mode, Runnable scope_runner ) {
final int current_mode = g.imageMode;
imageMode( mode );
scope_runner.run();
imageMode( current_mode );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment