Hi,
I have a sketch that is going to be presented on a large screen monitor. Is there a way to get my sketch to resize and center itself onto the monitor when it is run?
Here is my code:
``
/*
* Base Example
*
* Sketch that features the basic building blocks of a Spacebrew client app.
*
*/
import spacebrew.*;
String server="192.168.1.57";
String name="Maria's Comp";
String description ="This is an blank example client that publishes .... and also listens to ...";
Spacebrew sb;
String message ="Hello!";
PFont f;
float r= 100;
int i = 0;
int color1 = i;
int color2 = i;
int color3 = i;
int color1e = i;
int color2e = i;
int color3e = i;
int[] color1a = new int[10];
int[] color2a = new int[10];
int[] color3a = new int[10];
int i1 =0;
int i2 =0;
int i3 =0;
//colorMode RGB;
PImage ring;
PImage may;
PImage new1;
int np = 500 * 375;
void setup() {
fullScreen();
imageMode(CENTER);
//fill(255);
//size(375,500);
ring = loadImage("ring.jpg");
may= loadImage("maygs.jpg");
new1=loadImage("may.jpg");
for(int i =0; i < 10; i++){
color1a[i]=0;
color2a[i]=0;
color3a[i]=0;
}
// instantiate the sb variable
sb = new Spacebrew( this );
// add each thing you publish to
// sb.addPublish( "buttonPress", "boolean", false );
// add each thing you subscribe to
sb.addSubscribe( "color1", "range" );
sb.addSubscribe( "color2", "range" );
sb.addSubscribe( "color3", "range" );
// connect to spacebrew
sb.connect(server, name, description );
}
//void draw() {
void draw() {
// Update some picels
ring.loadPixels();
may.loadPixels();
new1.loadPixels();
for (int i = 0; i < np; i++) {
// Select random pixel
int ring_argb = ring.pixels[i];
//Fast way to get argb values in range 0-255
// for a pixel. The alpha is shown but not altered
// in this example
int ring_alpha = ring_argb >>> 24;
int ring_red = (ring_argb >> 16) & 0xFF;
int ring_green = (ring_argb >> 8) & 0xFF;
int ring_blue = ring_argb & 0xFF;
int may_argb = may.pixels[i];
//Fast way to get argb values in range 0-255
// for a pixel. The alpha is shown but not altered
// in this example
int may_alpha = may_argb >>> 24;
int may_red = (may_argb >> 16) & 0xFF;
int may_green = (may_argb >> 8) & 0xFF;
int may_blue = may_argb & 0xFF;
int new1_argb = new1.pixels[i];
//Fast way to get argb values in range 0-255
// for a pixel. The alpha is shown but not altered
// in this example
int new1_alpha = new1_argb >>> 24;
int new1_red = (new1_argb >> 16) & 0xFF;
int new1_green = (new1_argb >> 8) & 0xFF;
int new1_blue = new1_argb & 0xFF;
//playground- this one looks awesome write an artist statment about the convergence of the two pics.
new1_red = (ring_red+may_red *color1e) % 255;
new1_green =(ring_blue + may_green * color2e) % 255;
new1_blue = (ring_green + may_red * color3e)% 255;
//heavy metal version
/*
new1_red = (ring_red+may_red *color1e) % (color2+1);
new1_green =(ring_blue + may_green * color2e) % (color3+1);
new1_blue = (ring_green + may_red * color3e)% (color1+1);
*/
//good static image, but not as good as the first two
/*
new1_red = (ring_red - may_red / (color1e+1)) % (color2+1);
new1_green =(ring_blue - may_green / (color2e+1)) % (color3+1);
new1_blue = (ring_green - may_red / (color3e+1))% (color1+1);
*/
new1_argb = (new1_alpha << 24) | (new1_red << 16) | (new1_green << 8) | new1_blue;
// update the pixel
new1.pixels[i] = new1_argb;
}
// Stote the changes made to the image before displaying it
new1.updatePixels();
// Now display updated image
//new1.resize(0,displayHeight);
image(new1, displayWidth/2, displayHeight/2);
}
void onRangeMessage( String name, int value ) {
println("got range message )" + name + ") : " + value);
if (name.equals("color1")==true) {
color1 = value;
if (color1 > 255) {
color1 = 255;
}
if (color1<0) {
color1=0;
}
int oldVal=color1a[i];
color1a[i] = color1;
color1e = abs(color1-oldVal);
i1=(i1+1) % 10;
}
println("betsy)"+name+"):"+value);
if (name.equals("color2")==true) {
color2 = value;
if (color2 > 255) {
color2 = 255;
}
if (color2<0) {
color2=0;
}
int oldVal=color2a[i2];
color2a[i2] = color2;
color2e = abs(color2-oldVal);
i2=(i2+1) % 10;
}
//println("Hithere"+name);
if (name.equals("color3")==true) {
color3 = value;
//println("setting");
if (color3 > 255) {
color3 = 255;
}
if (color3<0) {
//println("<0");
color3=0;
}
int oldVal=color3a[i3];
color3a[i3] = color3;
color3e = abs(color3-oldVal);
i3=(i3+1) % 10;
} //else
//{
//println(name+"not color3");
//}
}
void onBooleanMessage( String name, boolean value ) {
println("got boolean message " + name + " : " + value);
}
void onStringMessage( String name, String value ) {
println("got string message " + name + " : " + value);
//if(name == "color1") {
//color1 = value;
}
//if(name == "color2") {
//color2 = value;
//if(name == "color3") {
//color3 = value;
void onSbClose(){
println("sb closed, trying to reopen");
// instantiate the sb variable
sb = new Spacebrew( this );
// add each thing you publish to
// sb.addPublish( "buttonPress", "boolean", false );
// add each thing you subscribe to
sb.addSubscribe( "color1", "range" );
sb.addSubscribe( "color2", "range" );
sb.addSubscribe( "color3", "range" );
// connect to spacebrew
sb.connect(server, name, description );
}
void onCustomMessage( String name, String type, String value ) {
println("got " + type + " message " + name + " : " + value);
}