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.

you might want arraylist or hashmap classes.


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -