oh sorry - quick question - can anyone explain the difference between 'blend' and

gplus
(Lawrence Clark) #1

oh sorry - quick question - can anyone explain the difference between ‘blend’ and ‘nblend’ (or point me in the direction of where i can read up on it online)

(Daniel Garcia) #2

The blend function takes two color objects and returns a blended third color object - nblend takes two color objects and replaces the first color object with the blended one - most of the functions that start with an n like that basically do an “in place” edit of the object.

scale8 also has an nscale8 version - here’s a quick example:

int something = 128;
// scales the value to 1/4, effectively
int newvalue =scale8(something, 64);
Serial.print("from scale8 – something = “); Serial.print(something); Serial.print(” and newvalue = "); Serial.println(newvalue);
// This will print “from scale8 - something = 128 and newvalue = 32”

int anotherthing = 128;
Serial.print("before nscale8 - anotherthing = "); Serial.println(anotherthing);
// scales the value to 1/4, but changes it, instead of returning a new one
nscale8(anotherthing, 64);
Serial.print("after nscale8 - anotherthing = ");
Serial.println(anotherthing);
// This will print:
// before nscale8 - anotherthing = 128
// after nscale8 - anotherthing = 32

(Lawrence Clark) #3

Thanks for taking the time to help me out with that explanation - I think I understand now … just to confirm , could you tell me the expected result from combining the two following rgb colours together :
(155,10,10)
And
(20,96.44)

If I understand correctly , is this the result blend would make (assuming the value is set halfway) ?

(175,106,54)

And if so , what would nblend do?