browse OpenProcessing

Torsion, using void mouseDragged() {}
spxlSuperKnob
Champagne
browse all>

browse the portfolio of subpixel

ImageButtonExample02
ImageButtonExample
spxlUnderPressure
spxlImageGradient
see more>
spxlSuperKnob

spxlSuperKnob

uploaded by
subpixel
A GUI knob that allows multiple revolutions.

Features:
- Rotation limited to specified number of revolutions in each direction
- Revolutions marker with graduated colour indicator
- Snap to full revolutions (visual cue: changed marker colours)
- Plays well with other knobs (ie doesn't hog mouseDragged())
- Resizable.

Inspired by discussion on Processing Discourse forums.

Link to next version: spxlSuperKnob02
Embed Code
Fave'd by 6 users
Sketch added to your favorites in your portfolio.
You must login/register to add this sketch to your favorites.

comments

source code

Comments

Giles Whitaker
27 Feb 2010, 08:32
Nice...I might use these for something as they are much more compact than sliders (and more precise).

A couple of things I don't understand ... what does this do?

int offX = gridSizeX >> 1;

Also, why did you use an abstract class for Knob?
antiplastik
27 Feb 2010, 11:12
oh that's great! I like the idea very much.
still one slight problem : when the mouse is close to the center, it gets weird... :-p

@Giles:
>>1 (bit shifting) does the same as /2, but faster
say you want to divide 6 by 2:
6 (decimal) is 0110 (binary)
0110 >> 1 = 0011
0011 (binary) is 3 (decimal)
subpixel
27 Feb 2010, 11:47
gridSizeX >> 1

to me, means "chop off a bit", or "chop off half". No rounding, no f**kin about. It only works on integral types, so helps me make sure I wasn't trying to get half a float value (the compiler will catch it if I do).

I really want an integer, and I don't care if it is "exactly half" or not. One pixel isn't going to bother me. Half a pixel would.

In all reality, it probably shows a bloody-mindedness. Whenever I see "/ 2", it is something I automatically want to make into ">> 1".

With regards to middle-of-knob weirdness, it might be better to not cause adjustment when the mouse is within some distance of the middle.
subpixel
27 Feb 2010, 11:56
PS: I used a(n abstract) super class to allow space for some other kind of knob(s); I didn't get around to implementing a non-SuperKnob knob. You'll have to use some context-sensitive inference to untangle my tangling of the meaning of "super". I couldn't think of a better term. Super as in awesome and also superposition. MultiRevKnob? Not so nice. It also allowed me to use a generic-sounding "knob" variable, of some generic "knob" class. "You're all a bunch of knobs!" I say to my knobs...
Giles Whitaker
27 Feb 2010, 13:31
Thanks for your answers... I'm learning more every day.
Dave Bollinger
01 Mar 2010, 07:47
these are "cute" as well as functional, nice.
fyi: if you accidentally flub the right mouse button the size gets stuck large: press left (now +10), "accidentally" press right (now +20), release right (back to +10), now release left (reference already nulled, so size remains +10)
Giles Whitaker
01 Mar 2010, 07:57
Not only that, but you can make them grow as large as you like by a series of holding down right mouse button while clicking left mouse button actions.
subpixel
01 Mar 2010, 09:53
Interesting... I make no claims about it being bulletproof!
Add to top of mousePressed:
if (!adjustingKnob) return;
subpixel
01 Mar 2010, 13:14
D'oh!... I mean if (adjustingKnob != null). Sorry, the C coder in me is showing.

I've posted a new (and more complicated) version

spxlSuperKnob02
http://www.openprocessing.org/visuals/?visualID=7962
You need to login/register to comment.