# Mousewheel\_plusplus

**URL:** <https://discourse.processing.org/t/mousewheel-plusplus/5839>\
**Category:** Project Guidance\
**Created:** [November 23, 2018, 2:24am UTC](https://discourse.processing.org/t/mousewheel-plusplus/5839 "2018-11-23T02:24:31Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)\
**Post date:** [November 24, 2018, 12:42am UTC](https://discourse.processing.org/t/mousewheel-plusplus/5839/5 "2018-11-24T00:42:59Z")

</div>

![snap-007](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/7/77341bd9e7d4918c35e1d7e604fd86cb66cbc548.png)  
3 slider move ( Y, X, Rotate )  
3 slider object size ( Y, X, Stroke )  
1 slider object select list ( example ellipse/rectangle/triangle )  
9 slider HSB fill / stroke / background ( using like [b] hue [B] sat [Alt][b] brt )

> **code**
>
> ```auto
> // file: mousewheel_plusplus.pde
> // system win 7 processing 3.4
> // by KLL
> // v0.1 https://discourse.processing.org/t/mousewheel-plusplus/5839
> // v0.2 help default and timer --> blog
> // v0.3 π was rotating
> // v0.4 Lexyth / move X missing! use CTRL scroll
> // v0.5 full HSB colors by [b],[B],[Alt][b] [f]...[s]... --> blog
> 
> // mouseWheel ++
> // "Scrollitis", a operational concept study
> // idea is to multiplex the mouseWheel use
> // by mixing it with several keypressed
> // so the combination is a multi NonGUI slider input
> String[] helplines = {
> "MouseWheel Plus Plus:"
> , "* normal scroll UP DOWN"
> , "+ wheel pressed: fast scroll UP DOWN"
> , "+ CTRL scroll LEFT RIGHT"
> , "+ key [y]: object Y size"
> , "+ key [x]: object X size"
> , "+ key [w]: object border stroke"
> , "+ key [r]: rotate"
> , "+ key [o]: 0 ellipse, 1 rectangle, 2 triangle"
> , "colors: HSB hue, SAT, [Alt]bright "
> , "+ key [b],[B],[Alt][b] backg"
> , "+ key [f],[F],[Alt][f] fill"
> , "+ key [s],[S],[Alt][s] stroke"
> // , " any more ideas?"
> };
> 
> float e_posX=250, e_posY=250, e_radiusx=100, e_radiusy=100, rot = 0;
> int bg_HSBhue = 100,e_fillHSBhue=40,e_strokeHSBhue=70;
> int bg_HSBsat = 100,e_fillHSBsat=100,e_strokeHSBsat=100;
> int bg_HSBbrt = 100,e_fillHSBbrt=100,e_strokeHSBbrt=100;
> color bg,e_fill,e_stroke;
> int e_strokeweight = 10, e_objectTyp = 0;
> // key and mouse all over
> boolean altKey = false, ctrlKey = false, shiftKey = false;
> boolean mousePresent = false;
> // help text show ( at start), on mouse click with timeout
> boolean show_help = true;
> long startT, actionT=10000; // use basic millis timer
> int posl=10, dposl = 15;
> 
> // _______________________________________________
> void setup() {
> size(500, 500);
> colorMode(HSB, 100, 100, 100);
> bg = color(bg_HSBhue,bg_HSBsat,bg_HSBbrt);
> e_fill = color(e_fillHSBhue,e_fillHSBsat,e_fillHSBbrt);
> e_stroke = color(e_strokeHSBhue,e_strokeHSBsat,e_strokeHSBbrt);
> }
> // _______________________________________________
> void draw() {
> background(bg);
> draw_help();
> translate(width/2,height/2);
> rotate(rot);
> translate(-width/2,-height/2);  
> fill(e_fill);
> stroke(e_stroke);
> strokeWeight(abs(e_strokeweight));
> switch(e_objectTyp) {
> case 0: 
> ellipse(e_posX, e_posY, e_radiusx, e_radiusy);
> break;
> case 1:
> rectMode(CENTER);
> rect(e_posX, e_posY, e_radiusx, e_radiusy);
> break;
> case 2: 
> triangle(e_posX-e_radiusx/2, e_posY-e_radiusy/2, e_posX, e_posY+e_radiusy/2,e_posX+e_radiusx/2, e_posY-e_radiusy/2);
> break;
> default: println("wrong"); break;
> }  
> }
> 
> // _______________________________________________
> void mouseExited() { mousePresent = false; }
> void mouseEntered() { if (focused) mousePresent = true; }
> void mousePressed() { if ( mouseButton == LEFT ) { show_help = true; startT = millis(); }}
> void mouseWheel(MouseEvent event) {
> float e = event.getCount();
> if ( mousePressed && mouseButton == CENTER ) e_posY += 10*e; // fast action: scroll Y position
> else if ( !keyPressed ) e_posY += e; // default action: scroll Y position
> else if ( keyPressed && keyCode == CONTROL ) e_posX += e; // [CTRL] scroll X position
> if ( keyPressed && key == 'y' ) e_radiusy += e; // [y] stretch Y
> if ( keyPressed && key == 'x' ) e_radiusx += e; // [x] stretch X
> if ( keyPressed && key == 'w' ) e_strokeweight += e; // [w] strokeWeight
> if ( keyPressed && key == 'r' ) rot += 3*e*TWO_PI/360; // [r] rotate
> if ( keyPressed && key == 'o' ) {    
> e_objectTyp += e;
> e_objectTyp = constrain(e_objectTyp, 0, 2); } // [o] object typ circle rect triangle
> if ( keyPressed && key == 'b' && !altKey ) { 
> bg_HSBhue += 2*e;
> bg_HSBhue = constrain(bg_HSBhue, 0, 100);
> bg = color(bg_HSBhue,bg_HSBsat,bg_HSBbrt); } // [b] background hue color
> if ( keyPressed && key == 'B' ) { 
> bg_HSBsat += 2*e;
> bg_HSBsat = constrain(bg_HSBsat, 0, 100);
> bg = color(bg_HSBhue,bg_HSBsat,bg_HSBbrt); } // [B] ([Shift][b] or [Capslock][b]) background saturation
> if ( keyPressed && key == 'b' && altKey) { 
> bg_HSBbrt += 2*e;
> bg_HSBbrt = constrain(bg_HSBbrt, 0, 100);
> bg = color(bg_HSBhue,bg_HSBsat,bg_HSBbrt); } // [Alt][b] background brt
> if ( keyPressed && key == 'f' && !altKey ) { 
> e_fillHSBhue += 2*e;
> e_fillHSBhue = constrain(e_fillHSBhue, 0, 100);
> e_fill = color(e_fillHSBhue,e_fillHSBsat,e_fillHSBbrt); } // [f] fill hue color
> if ( keyPressed && key == 'F' ) { 
> e_fillHSBsat += 2*e;
> e_fillHSBsat = constrain(e_fillHSBsat, 0, 100);
> e_fill = color(e_fillHSBhue,e_fillHSBsat,e_fillHSBbrt); } // [F] ([Shift][f] or [Capslock][f]) fill saturation
> if ( keyPressed && key == 'f' && altKey ) { 
> e_fillHSBbrt += 2*e;
> e_fillHSBbrt = constrain(e_fillHSBbrt, 0, 100);
> e_fill = color(e_fillHSBhue,e_fillHSBsat,e_fillHSBbrt); } // [Alt][f] fill brt
> if ( keyPressed && key == 's' && !altKey ) { 
> e_strokeHSBhue += 2*e;
> e_strokeHSBhue = constrain(e_strokeHSBhue, 0, 100);
> e_stroke = color(e_strokeHSBhue,e_strokeHSBsat,e_strokeHSBbrt); } // [s] stroke hue color
> if ( keyPressed && key == 'S' ) { 
> e_strokeHSBsat += 2*e;
> e_strokeHSBsat = constrain(e_strokeHSBsat, 0, 100);
> e_stroke = color(e_strokeHSBhue,e_strokeHSBsat,e_strokeHSBbrt); } // [S] ([Shift][s] or [Capslock][s]) stroke saturation
> if ( keyPressed && key == 's' && altKey ) { 
> e_strokeHSBbrt += 2*e;
> e_strokeHSBbrt = constrain(e_strokeHSBbrt, 0, 100);
> e_stroke = color(e_strokeHSBhue,e_strokeHSBsat,e_strokeHSBbrt); } // [Alt][s] stroke brt
> }
> // _______________________________________________
> void my_timer() {
> if ( millis() > startT + actionT ) show_help = false; // timeout, was set true by mouse click
> }
> // _______________________________________________
> void draw_help() {
> my_timer();
> if (show_help) {
> fill(0, 100, 0,70);
> noStroke();
> rectMode(0);
> rect(0, 0, 270, 200);
> fill(22,100,100); // yellow
> for ( int i =0; i < helplines.length; i++ ) text(helplines[i], 10, posl + i*dposl);
> }
> if ( mousePresent ) { fill(0); text("π",width-20,height-10); } // do not click on this!
> if ( keyPressed && (key == 'b' || key == 'B' )) { fill(0); text(" bg color("+bg_HSBhue+","+bg_HSBsat+","+bg_HSBbrt+")",150, posl+10*dposl); }
> if ( keyPressed && (key == 'f' || key == 'F' )) { fill(0); text(" fill color("+e_fillHSBhue+","+e_fillHSBsat+","+e_fillHSBbrt+")",150, posl+11*dposl); }
> if ( keyPressed && (key == 's' || key == 'S' )) { fill(0); text(" stroke color("+e_strokeHSBhue+","+e_strokeHSBsat+","+e_strokeHSBbrt+")",150, posl+12*dposl); }
> } // end
> 
> void keyPressed () {
> if (key == CODED) {
> if (keyCode == ALT) altKey = true;
> else if (keyCode == SHIFT) shiftKey = true;
> else if (keyCode == CONTROL) ctrlKey = true;
> }
> }
> 
> void keyReleased() {
> if ((keyCode >= '0' && keyCode <= '9') || // digit
> (keyCode >= 'A' && keyCode <= 'Z') || // upper-case letter
> (keyCode >= 'a' && keyCode <= 'z')) { // lower-case letter
> if (altKey) {
> //println("ALT " + char (keyCode)+" "+keyCode);
> altKey = false;
> } else if (ctrlKey) {
> //println("CTRL " + char (keyCode)+" "+keyCode);
> ctrlKey = false;
> } else if (shiftKey) {
> //println("SHIFT " + char (keyCode)+" "+keyCode);
> shiftKey = false;
> } //else println("KEY = "+ key+" "+keyCode);
> }
> }
> 
> ```

get newest version at my [blog](http://kll.engineering-news.org/kllfusion01/articles.php?article_id=154#here13)

---

_[View the full topic](https://discourse.processing.org/t/mousewheel-plusplus/5839)._
