Question

float boxkPosition- (¡%7) * boxHidth; // Calculate the Y position of the box. float boxYPosition- (i/7) boxHeight; 43 45 46 4

Hi, how do you add color to a heat map using "lerpcolor" (application: processing)?

0 0
Add a comment Improve this question Transcribed image text
Answer #1

void applyColor() { // Generate the heat map

color c1 = color(0, 0, 255); // Blue color
color c2 = color(0, 255, 255); // color Cyan
color c3 = color(0, 255, 0); // Green color
color c4 = color(255, 255, 0); // Yellow color
color c5 = color(240, 150, 5); // Orange color
color c6 = color(255, 0, 0); // Red color

loadPixels();
int p = 0;
color c;
float fraction;

for (int i = 0; i < rows; i++) {
for (int j = 0; j < cols; j++) {
float value = interp_array[i][j];

if (value>= 25 && value<26) {
fraction = value;
c = lerpColor(c1, c2, fraction);
} else if (value>=26 && value<27) {
fraction = value;
c = lerpColor(c2, c3, fraction);
} else if (value>=27 && value<28) {
fraction = value;
c = lerpColor(c3, c4, fraction);
} else if (value>=28 && value<29) {
fraction = value;
c = lerpColor(c4, c5, fraction);
} else if (value>=29 && value<30) {
fraction = value;
c = lerpColor(c5, c6, fraction);
} else
c = c6;
pixels[p++] = c;
}
}
updatePixels();

Add a comment
Know the answer?
Add Answer to:
Hi, how do you add color to a heat map using "lerpcolor" (application: processing)? float boxkPosition- (¡%7) * boxHidth; // Calculate the Y position of the box. float boxYPosition- (i/7)...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • How do I flip this shape across the y-axis using processing? h_190527e | Processing 3.5.3 t Sketch Debug Too...

    How do I flip this shape across the y-axis using processing? h_190527e | Processing 3.5.3 t Sketch Debug Tools Help sketch_190527e sketch 190527e float angleoffsetAnchor 13; vertex(centerx, centerY); float nappedStepsForLerp-map(steps, minstepsValue, maaStepsvalue, θ, 1); color lowSteps - color(9, 10, 200); color highSteps -color(29e, o, e); lor mappedDayColor lerpColor (Lowsteps, highSteps, mappedStepsForLerp); fill (mappedDayColor); float anchorPointx1 - centerx distanceoffsetAnchor sin(angle radians(angleoffsetAnchor)) float anchorPointy centerY distance0ffsetAnchor cos (angle radíans (angleOffsetAnchor)) 54 56float controlPointx - centerx + distanceoffset sin(angle); at controlPointy centerV +...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT