We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello everyone, I am a newbie programmer trying out Processing to make my own program to calculate some values for a game. I am using G4P library and G4P GUI Buiilder for the user interface.
Firstly, why do text on labels appear to have aliasing when the background is set to not opaque in the GUI builder (Look at 1 in the image)? I need to make the background of all labels opaque with the same colour as my sketch background to get smooth, anti-aliased text (the rest of the labels in the image). Is there a way to have transparent background and smooth text at the same time?
Secondly, is there any way to change the look of the scrollbar in a text area (Look at 2 in the image)? I am looking at plain square thumb and arrows buttons with no or light colour border instead of the default rounded ones with black outline. The user defined palette doesn't seem to change the colour of the outline out the scrollbar, it seems to be always black. Unchecking rounded corners in the GUI builder does not seem to change the shape of the scrollbar.
Thanks!
Answers
G4P uses double buffering for all visual controls to reduce CPU usage. It means that each control has an internal graphic buffer which is updated only when there is a change of state in the control eg mouse moves over a button, key typed in a text field etc. The graphic buffer is copied to the screen on each frame. When a buffer is updated the background is either transparent (setOpaque false) or cleared to a colour from the colour scheme (setOpaque true) so ignores the display colour under the control.
It does mean that text is not as sharp when the background is transparent. You found one solution by changing the background colour of each label. Another solution would to create a new colour scheme for the global scheme before calling create GUI. See the guides in on my website.
http://lagers.org.uk/g4p/guides/g04-colorschemes.html
The buffer type is java.awt.Graphics2D no matter which Processing renderer is being used ie JAVA2D (default), P2D or P3D. Note that in PS3 P2D and P3D are in fact OpenGL. This change also let me give the user much greater control over the front attributes, a feature not available in the Processing core. For instance font colour, italics, bold, underline can be changed for the whole or part of some piece of text.
I investigate the border colour for scrollbars.
Thanks for the prompt reply!
I am not very sure on how to create a new colour scheme
Does it mean I call
GCScheme.makeColorSchemes(this);
beforecreateGUI();
like this:or are you referring to creating user_gui_palette.png?
The above code does not seem to work, it runs as per normal but the text still has aliasing as before.
The website needs a bit more information / explanation so here we go.
By default G4P uses an image called
default_gui_palette.png
if you want to a particular sketch to use your own palette then you need to create a new image calleduser_gui_palette.png
this image needs to be placed inside a folder called data inside the sketch folder like thisBefore G4P V4.0.3 creating the new image file had to be done using a graphics editor program but now it can be done inside Processing.
The sketch below demonstrates how to create the image.
copy the
user_gui_palette.png
image file created into the data folder of any sketch that intends to use it. When you run your sketch G4P will find this image and use it instead of the default one.You need to set the labels background to opaque either manually like
label1.setOpaque(true);
or click the option in GUI Builder. Also if you are using GUI Builder then you have to modify the statement
G4P.setGlobalColorScheme(GCScheme.BLUE_SCHEME);
to use the new palette like this
G4P.setGlobalColorScheme(10);
You will have to do this each time you modify the GUI with GUI Builder because it only allows to choose one of the default palettes.
I will modify GUI Builder in its next release to accept user palettes but for the moment you have to do it manually.
I have tried reproducing the two labels "Defending Pokemon" and "Attacking Pokemon" and have not been able to reproduce the difference you show in the picture above.
Can you create a simple sketch with just 2 labels that demonstrates the problem and post the code here?
I wanted to give you an example, but I was shocked that my problem could not be replicated when I wrote a new simple sketch. After investigation, I found my mistake: I put
background(250)
insetup()
rather thandraw()
.You can recreate the problem with these codes:
and
If you are going to use G4P then you MUST use
background(...)
in thedraw()
method. I don't need to recreate the problem because you have solved it.And I don't have to create a new release of G4P :D
Thank you for your support. Perhaps that could be included in the website for newbies like me to reference.
Any new info on the possibility of customizing the scrollbar not to have round edges or changing the colour of the border?
I will investigate the scrollbar issue but it would involve changing the library source code and that might be some time off since I am busy at the moment. If you are desperate then you could install V4.0.2 which had square corners for buttons and scrollbars but then you would miss out on later bug fixes and enhancements etc.