Assign 3 typed numbers to a variable in Processing -
i making paint program in processign , want allow user type 3 numbers change int r;. want know if take 3 typed numbers , assign them single variable int r. such typing 2, 5, 5, , storing them int r =255;
you use array.
an array variable holds multiple values.
int[] r = {1, 2, 3}; int x = r[0];
here processing array reference.
you create own class.
better yet, create class keeps track of 3 values:
class mynumbers{ int r; int g; int b; public mynumbers(int r, int g, int b){ this.r = r; this.g = g; this.b = b; } }
then create instance of class , pass in values:
mynumbers rgb = new mynumbers(1, 2, 3); int r = rgb.r;
here processing class reference.
you use color
type.
if want store rgb values, consider using existing color
type in processing:
color c = color(1, 2, 3); int r = red(c);
here processing color reference.
Comments
Post a Comment