int r = 5; color nowcolor; color mc[ ] = new color [5]; int mx = 750, my = 10, ms = 40; void setup(){ size(800,550); colorMode(HSB,360,100,100); background(0,0,100); mc[0] = color(50,0,100); mc[1] = color(0, 100,100); mc[2] = color(300 ,100,100); mc[3] = color(39,100,100); mc[4] = color(0,0,100); nowcolor = color(0,0,100); } void draw(){ if( isdrag == true ){ stroke( nowcolor ); strokeWeight( r ); line( bx, by, mouseX, mouseY ); bx = mouseX; by = mouseY; }else{ stroke( 0,0,100 ); for( int i = 0 ; i < 5 ; i++ ){ fill( mc[i] ); strokeWeight( 1 ); rect( mx, my+(ms+10)*i, ms, ms ); } } } boolean isdrag = false; int bx, by; void mousePressed(){ int i = 5; if( mouseX >=mx && mouseX <= mx+ms ){ for( i = 0 ; i < 5 ; i++ ){ if( mouseY >= my+(ms+10)*i && mouseY <= my+(ms+10)*(i+1) ) break; } } if( i < 5 ){ nowcolor = mc[i]; }else{ isdrag = true; bx = mouseX; by = mouseY; } } void mouseReleased(){ isdrag = false; }