Why does get return a negative value?

Im printing out get(x,y), and it is a negative value. White is -1. What is going on?

Answers

  • Answer ✓

    The color type is secretly an int. Try:

    color c = get(x,y);
    println( red(c) );
    println( green(c) );
    println( blue(c) );
    println( hex(c) );
    
  • So, i'm trying to get an average of chunks of color. How do I get the real color?

  • What you are getting with get() is a color. The problem is that prinln() doesn't treat the color you got like a color - it thinks it is an int!

    How are you planning to average two or more colors?

  • edited April 2018

    I'm trying to get an average of chunks of color

    Are these like a line, rectangle, or circle of pixels in a photographic or drawn image? Should your "average" be weighted towards the center of the selection area, or all all pixels of equal interest? Can you say more about what a chunk is - 20 pixels, 200?

    How are you planning to average two or more colors?

    lerpColor() gives linear interpolation between two colors -- so, for example, you could find the outliers and then linearly interpolation them.

    Note however that outlier components and outliers are a different thing -- and that linear interpellation of color RGB components do not always give visually intuitive values for hue, brightness etc.

  • edited April 2018

    Eh, I fixed it. The problem was with the averaging of the LITERAL color values. I just stored the separate RGB values.

Sign In or Register to comment.