Digital Workshop

Welcome to the Digital Workshop Message Boards
It is currently December 22nd, 2024, 11:29 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: slider to set rotation angle
PostPosted: October 21st, 2006, 12:11 pm 
Offline
Godlike
Godlike

Joined: November 11th, 2004, 1:18 pm
Posts: 1213
Location: New York
Opus: Opus Pro 9.75
OS: Windows 10 Pro 64 bit
System: Core i7, 16G RAM, Nvidia 640GT (desktop), plus Windows 10 and Android tablets
Hi

I'm trying to create a small slider (needs to fit on a toolbar) that moves horizontally, which would allow the end-user to set the rotation angle for a vector (rotation angle is scripted using a variable, so if the variable is set to a number value like 15, the rotation will be 15 degrees).

An excellent sample, by Robin Garrett, is on the Forum at

viewtopic.php?t=658&highlight=slider

However, it is set up with some advanced math, arranged in percent values/increments and only in a positive direction. I can't figure out how to modify this sample slider so that it has a series of values (to set the variable to) expressed as minus to plus degrees instead: for example,
-90 degrees, -45 degrees, -15 degrees, -5 degrees, 0 degrees, +5 degrees, +15 degrees, +45 degrees and +90 degrees. The choices are arbitrary, but the minus to plus range is needed. There is no need to set the slider to scale or have values arranged in-between the few categories. The aim to to give the end-user a few choices, plus or minus, to set rotation angle (actual rotation is built into the vector-click and it turns). The slider is a more elegant solution than 9 very small buttons on the toolbar (too much space). (I also need to set up a second slider for scaling the vector with minus to plus values, but different increments.)

Any design help would be appreciated to suggest how this slider can be modified (or a new one constructed) to accomplish the above results.

Kind Regards,

_________________
Stephen


Top
 Profile  
 
 Post subject:
PostPosted: October 21st, 2006, 8:48 pm 
Offline

Joined: November 11th, 2004, 4:05 am
Posts: 636
Location: Christchurch, NZ
Here's how you get the minus to plus range.

The key line in Robin's script is pospercent = Math.round(pospixabs/percentwidth)
which gives an output of 0-100.
you can reset the output from -50 to +50 by subtracting 50 from it.

pospercent = Math.round(pospixabs/percentwidth) - 50

you can scale the output with a multiplier -- since you are working in %, compensate for it with a suitable divisor.

example -- the line below will give an output of -90 to +90

pospercent = Math.round(((pospixabs/percentwidth)-50)*(90/50))

I've adapted the sample -- see the third page.

cheers
Paul


Top
 Profile  
 
 Post subject:
PostPosted: October 21st, 2006, 9:07 pm 
Offline
Godlike
Godlike

Joined: November 11th, 2004, 1:18 pm
Posts: 1213
Location: New York
Opus: Opus Pro 9.75
OS: Windows 10 Pro 64 bit
System: Core i7, 16G RAM, Nvidia 640GT (desktop), plus Windows 10 and Android tablets
Hi Paul

Thanks once again for helping out. This is a very nice solution. :)

Kind Regards,

_________________
Stephen


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 66 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group