# Changing the Color

I’m trying to change the color of each circle depending on the magnitude. However, they all remain blue.

This is the assignment:

• Determine what color the circle for this earthquake should be:
• If the magnitude is less than 6.3, the color should be (0, 0, 255)
• If the magnitude is between 6.3 (including 6.3) up to but NOT including 7.0 (i.e. greater than or equal to 6.3 but strictly less than 7.0), the color should be (155, 0, 100)
• If the magnitude is between 7.0 (including 7.0) up to but NOT including 7.5, the color should be (200, 0, 55)
• Otherwise, the color should be (255, 0, 0)

And this is the code that I have so far:

``````float varM = getMag(datum);
if (varM < 6.3) {
color(0,0,255);
};
if (6.3 >= varM && varM < 7.0) {
color(155,0,100);
};
if (7.0 <= varM && varM < 7.5) {
color(255,0,55);
};
``````
1 Like

To set the color that something is drawn in, you use the `fill()` function, not `color()`.

You can also use if-else statements, and remove some semicolons that you don’t need:

``````if (varM < 6.3) {
fill(0,0,255);
} else if (varM < 7.0) {
fill(155,0,100);
} else if (varM < 7.5) {
fill(255,0,55);
}``````
1 Like

Thank you for helping, but it still returns the circle as blue

Please post more of your code then. Specifically the bit that draw the circle.

Here’s a small, complete sample:

``````float varM;

void setup() {
size(600, 600);
varM = 6.5;
}

void draw() {
background(0);
if (varM < 6.3) {
fill(0, 0, 255);
} else if (varM < 7.0) {
fill(155, 0, 100);
} else if (varM < 7.5) {
fill(255, 0, 55);
}
ellipse(300, 300, 100, 100);
}
``````
1 Like