Undecorated frames
in
Contributed Library Questions
•
1 year ago
Here is example to show how sketches in separate windows can talk to each other...
The problem is how to d isables decorations for both frames and put them on black background (SoftFullScreen - Hansi's fullscreen library for Processing)..
Any help is much appreciated!
The problem is how to d isables decorations for both frames and put them on black background (SoftFullScreen - Hansi's fullscreen library for Processing)..
Any help is much appreciated!
- //multisketchExample1.pde
import org.gicentre.utils.multisketch.*;
import java.awt.MouseInfo;
// The embedded sketch.
RightSketch rightSketch;
int mX;
int mY;
void setup()
{
size(300,300);
smooth();
stroke(120,20,20);
strokeWeight(4);
rightSketch = new RightSketch();
PopupWindow win = new PopupWindow(this,rightSketch);
win.setVisible(true);
}
void draw()
{
background(255,200,200);
float xOffset = width-mouseX + rightSketch.width/2.0;
float yOffset = rightSketch.height/2-mouseY;
line(mouseX,mouseY,mouseX+xOffset,mouseY+yOffset);
float angle = atan(yOffset/xOffset);
// Tell the other sketch to draw a line from one edge to its centre.
rightSketch.setLine(0,mouseY+(width-mouseX)*tan(angle));
}
void mousePressed(){
mX = mouseX;
mY = mouseY;
}
void mouseDragged(){
frame.setLocation(
MouseInfo.getPointerInfo().getLocation().x-mX,
MouseInfo.getPointerInfo().getLocation().y-mY);
println(MouseInfo.getPointerInfo().getLocation().x-mX);
println(MouseInfo.getPointerInfo().getLocation().y-mY);
}
public void init(){
frame.removeNotify();
frame.setUndecorated(true);
frame.addNotify();
super.init();
}
- //AnotherSketch.pde
public class RightSketch extends EmbeddedSketch
{
float x1,y1;
void setup()
{
size(300,300);
smooth();
stroke(20, 120,20);
strokeWeight(2);
}
void draw()
{
super.draw();
background(200,255,200);
line(x1,y1,width/2,height/2);
}
void setLine(float x1, float y1)
{
this.x1 = x1;
this.y1 = y1;
}
}
1