java Slick 2D how to set color - slick2d

I'm getting crazy trying to draw a very simple rect and a text in order to just understand how it works with the slick 2d java library.
This is what I try:
g.setColor(Color.green);
g.fillRect(50, 50, 50 ,50);
g.setColor(Color.orange);
g.drawString("Write something", 100, 100);
I just got to have everything I draw either in green or orange, but not one green and the other orange, as I would like to do...
Can someone help me to figure this out ???
Many thanks in advance

Your code seems to be correct, and works on my test-game.
Are you running it in the appropriate method, public void render(GameContainer gc, Graphics g)?
Try to update your LWJGL and Slick2D libraries too.

Imagine you're drawing the screen by hand. You pick up a green pen, and you draw a rectangle. Then you pick up an orange pen and draw the words. That's what you're telling Slick2D to do with your code. Don't change colors between the two drawing operations - just set the color, then draw both objects and they will come out as the same color.
When you change colors all shape/text operations you do after that will be in that color, until you change colors again.

I was also importing the java.awt.Color;, this library is incompatible with Slick2D.
To fix this replace the line import java.awt.Color; with import org.newdawn.slick.Color;.

Related

Draw a line and color it based on direction

Is it possible to draw a line similar to the example below and color it based on the previous value?
So to have the color red when the line is moving down and green when it goes up.
Can this be done with line type? Or does it need to be drawn with markLine or something else?
Any help is much appreciated!
https://echarts.apache.org/examples/en/editor.html?c=dynamic-data2
I don't think it is possible with the line chart, as the whole line uses the same color for all points. I suggest you use a scatter type chart where each point can have a different color. By setting symbol size to a small value and drawing values close together you can emulate visual line.
Here is an example based on the regression sample from echarts site:

Create Color Variations From Main Color

I have a main color in Flutter, Color(0xFF6E8898), and what I want to do is create variations or shades from that color. For example here is a chart with different variations of one main color:
Right now, I have one color, but I don't know how to create different shades or variations from it. Current Picture:
Thanks for any help.
Note: I don't think it matters, but just in case charts_flutter has a method for this I am using the charts_flutter library to generate my charts
I think this one can help you: https://graphicdesign.stackexchange.com/questions/75417/how-to-make-a-given-color-a-bit-darker-or-lighter
You can write a function to generate color to lighter or darker with a given RGB color.
The material colors have a shade attribute which you can use:
Colors.green.shade300
You can see a list of the shades of all the material colors here.

Two line charts as fill delimiter?

Do you have any idea of how to achieve this?
Thanks in advance
Just in case someone is looking for the same approach... As #Wingzero said, his solution requieres a pretty advanced knowledge on CoreGraphics. What I did is modified the framework and make the lines render in front of the content. With that, Added 2 lines: the first one with a fill color green with an alpha of 0.5 and the second one with a fill color of the same color of the background color and a alpha of 1 :)

GIMP will not blend completely to color using opacity and paint tool

I am stuck on a blending problem that appears to have only started once I started blending without any color. I am painting a grey suit and using shades to capture the lighting realistically. For some reason, when I paint with a dark grey over a light grey, with say 20% opacity, with enough strokes, the color I am painting will match the color in the color picker. With the reverse situation (light to dark), the paint tool never quite blends to the color in the color picker, it is always a shade or two off. No matter how many times I stroke the area, it will not become the color I have chosen. It has me dumbfounded and is crippling my ability to make light and shadow and show depth.
I have tried googling and messing with every possible option, deselecting all, triple checking what layer I am in, but I cannot seem to find anyone else with this problem...
I openned GIMP 2.8 (stable version) and the development version of GIMP and tried a procedure like the one you tell about:
Indeed, when working with 8 bit color, the wayGIMP is structured internally will prevent the gray values to converge toa precise shade of gray in same cases. When GIMP applies 20% of the difference between a value 129 to a pixel valued 127, that "20%" is a "0.4" darkening, which is rounded down to zero.
This certainly won't be dealt with on current GIMP stable, since it is fundamental to the way 8 bit color works, ansd given that GIMP unstable - the 2.9 version that will eventually be out as GIMP 2.10 can be set to use higher color precision so that this behavior does not happen. (With floating point pixel values, you just get as close as you want from your shade of gray).
I'd suggest you either find a compiled "nightly" version of GIMP 2.9 for your system, or try some other way of painting: maybe using a more spread shade of gray with values varying over a broader range, and after you are done, compressing the results to the desired range with the Levels or Curves tool.
Anyway, this is offtopic here - if you have further doubts on painting, please take the question to graphicdesign.stackexachange.com

How to change the histogram colour in Matlab

So i'm awful at Matlab and I mainly learn through examples and literally spelt out explanations.
So baring that in mind - Right now i'm trying to find how likely it is that one image i'm given is in anther via a histogram.
What i want to do is create 3 histograms for red, blue & green for each image and then add those into one image - So basically i'll have an image with a literal green histogram showing the green, a red one showing the red and a blue one showing the blue.
I know that to show a colour chanel in matlab i have to do imhist(image(:,:,1/2/3)
however that still gives me a histogram in blue.
I've looked up some things that are meant to help with this issue but it's normally aimed toward someone who knows what they're doing.... not helpful.
I've heard peope saying something like get(get(gca,'child')) which just seems giberish to me.
SO - for what i'm trying to do, image detection via histrograms, is this an appropriate method? And if so HOW do i create my 1 histogram that shows all 3 histograms in their respective colour
Cheers
You could use this version of imhist:
[counts,x] = imhist(...)
And then draw your histograms yourself, via bar, stem or similar.
These functions are then fully customizable and you can plug in your favourite color, linestyle, etc.