G4P Gpanel and Gview

Hi,

I want to add a GView area on a Gpanel but when i do this the color of the Gpanelcolors is darker. It looks like a shade on the view area. I would like to have this transparent to match the real backgroundcolor of the Gpanel.

Suggestions?

Code:

import g4p_controls.*;

GView view2D;
GPanel pnMain;

void setup() {
size(1280, 800, JAVA2D);
background(#FFFFFF);
textSize(15);

pnMain = new GPanel(this, 1, 1,1200,800, “Main Panel”);
pnMain.setText(“Main Panel”);

view2D = new GView(this, 0,0, 900, 600, JAVA2D);
pnMain.addControl(view2D);
}

void draw(){}

Hi @Piko,

Welcome to the community! :slight_smile:

I was looking at the documentation:

and Processing also has an example of the GP4 library on how to use GView.
So, the following code does what you ask

import g4p_controls.*;

GView view2D;
GPanel pnMain;

void setup() {
size(1280, 800, JAVA2D);
background(#FFFFFF);
textSize(15);

pnMain = new GPanel(this, 1, 1,1200,800, "Main Panel");
pnMain.setText("Main Panel");

view2D = new GView(this, 0,0, 900, 600, JAVA2D);
pnMain.addControl(view2D);
}

void draw(){
  PGraphics v = view2D.getGraphics();
  v.beginDraw();
  v.background(0,255); // Change this line to (0,0) to make it transparent
  v.noStroke();
  v.endDraw();
}

But I was wondering if there is a simple way to do this. The documentation on the link shows that the GView inherits from other members.
image

Maybe @quark can help with this.
Best regards

1 Like

Hi Migual,

Thanks!
It did the trick.

Best regards