Removing Border from Processing Screen

I wrote the script below that takes part of my computer screen and shows a smaller version of it in a tiny window in the corner. I found a helpful thread that helped me remove the toolbar from the top of the window but I can’t figure out how to remove the gray border from it. Bonus points if you can tell me if there is a way to put a red square around the area of the screen I am taking from.

import processing.video.*;
import processing.serial.*;
import java.awt.Rectangle;
import java.awt.Frame;
import processing.awt.PSurfaceAWT;
import processing.awt.PSurfaceAWT.SmoothCanvas;

// https://github.com/onformative/ScreenCapturer/issues/2
import java.awt.Robot;
import java.awt.Rectangle;
import java.awt.AWTException;

Robot robot;

int errorCount=0;
PImage img;
String[] strLines;

//void settings() {
//    fullScreen();
//}



void setup() {
  
  strLines = loadStrings("C:/Users/Jesse's PC/Desktop/coordinate_writer/positions.txt");
  
  if (errorCount > 0) exit();
     
  //size(89, 78);  // create the window
  surface.setSize(89,78);
  surface.setLocation(1775, 875);
 
  
  try {
    robot = new Robot();
  }
  catch (AWTException e) {
    println(e);
  }  
}

PSurface initSurface() {
  PSurface pSurface = super.initSurface();
  PSurfaceAWT awtSurface = (PSurfaceAWT) surface;
  SmoothCanvas smoothCanvas = (SmoothCanvas) awtSurface.getNative();
  Frame frame = smoothCanvas.getFrame();
  frame.setUndecorated(true);
  frame.setLayout(null);
  return pSurface;
}
 
 
// runs for each new frame of movie data
void movieEvent() {
  // read the movie's next frame
  img = new PImage(robot.createScreenCapture(new Rectangle(100, 200, 720, 640)));
}

// draw runs every time the screen is redrawn - show the movie...
void draw() {
  //background(100);
  movieEvent();
  loadPixels();
  for (int i = 1; i < (strLines.length); i++) {
    pixels[i] = img.pixels[int(strLines[i])];
  }
  updatePixels(); 
}

Try this code:

import java.awt.*;
int center_x, center_y;

void setup() {
  fullScreen();
  Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
  int screenHeight = screenSize.height;
  int screenWidth = screenSize.width;
  surface.setSize(600, 600);
  center_x = screenWidth/2-width/2;
  center_y = screenHeight/2-height/2;
  surface.setLocation(center_x, center_y);
  strokeWeight(10);
  stroke(255, 0, 0);
}

void draw() {
  rect(0, 0, width, height);
}

Hi Noel, thanks for responding. That works but the border reappears when I shrink the size down to (89, 78). Any idea why that would be?

Didn’t receive yet. :grinning:

1 Like

Hi noel, it didn’t work when I shrunk it down to 89x78.

A bit of research revealed the answer.

:)

This depends on the platform you use. I can’t change that. See here.

Field Detail

static final int MIN_WINDOW_WIDTH

Minimum dimensions for the window holding an applet. This varies between platforms, Mac OS X 10.3 (confirmed with 10.7 and Java 6) can do any height but requires at least 128 pixels width. Windows XP has another set of limitations. And for all I know, Linux probably allows window sizes to be negative numbers.

1 Like

Did you succeed without any border?

I am not working on a size smaller than 128x128.
Rebuilding the source is something to try for the adventurous.

void setup() 
  {
  fullScreen();
  surface.setSize(600, 600);
  surface.setLocation(500, 500);
  }

void draw() 
  {
  background(255, 255, 0);
  int xy = int(200+200*sin(frameCount*TAU/360)); //0 to 400
  println(xy);
  surface.setSize(xy, xy);
  }

:)

1 Like