Results 1 to 10 of 10

Thread: slider with numbers

  1. #1

    slider with numbers

    So i got the slider itself working, but how would I, for example with a slider length of 1 to 100 pixels create an array of numbers between 20 and 200? (or simply between numbers x and y)?

    I figure theres tutorials all over the web for a formula, and that theres even a simple 9th grade math equation for it, but im simply too lazy.

    Thanks in advance for any help..

  2. #2
    TheCanadian's Avatar
    10,302
    posts
    Noo doot aboot it, eh?
    Quote Originally Posted by GeekTweak.0 View Post
    I figure theres tutorials all over the web for a formula, and that theres even a simple 9th grade math equation for it, but im simply too lazy.
    Well I was going to just give you the equation until I read that It is a very simple problem: you want a linear function that maps 1->20 and 100->200. That's enough data to solve the equation y=mx+b.
    Proud Montanadian
    We tolerate living and breathing. And niches.

    Name Brand Watches

    Maybe getTimer() or TweenMax is the answer to your problem . . .

  3. #3
    alright, so maybe im just a moron, but i am having trouble and learn much better through visual example. from x values of the slider being between 10 to 100, and desired output being between 20 to 200, and variable:value is the output depending on slider.x(that x value being between 10 and 100).... what equation do i plug in to get value?? Maybe just cuz i aint been in school for a while, maybe cuz im tired, maybe both, idk. please just give me the answer XP

  4. #4
    TheCanadian's Avatar
    10,302
    posts
    Noo doot aboot it, eh?
    Oh the input value is from 10 to 200? That makes it even easier. You really can't figure out how to scale the interval 10-100 to 20-200?

    Here's a visual example: Tommy has 10 apples. Sally has 20 apples. How many times more apples does Sally have than Tommy?

    Proud Montanadian
    We tolerate living and breathing. And niches.

    Name Brand Watches

    Maybe getTimer() or TweenMax is the answer to your problem . . .

  5. #5
    Usually i make the sliders to return Number from 0 to 1 and then transform it to any value needed. Simple percentage usage. I that case the transformation will look something like this:

    value = minValue + (Math.abs(maxValue - minValue)*sliderPercent);

    in your 20 to 200 case:
    value = 20 + (Math.abs(200-20)*sliderPercent);

    Props to The Canadian for the visual aids

  6. #6
    TheCanadian's Avatar
    10,302
    posts
    Noo doot aboot it, eh?
    I knew someone was just going to give it to him eventually. Although, if your input is 10-100, there is a much simpler equation to use. Perhaps there's some constant you can multiply it by…
    Proud Montanadian
    We tolerate living and breathing. And niches.

    Name Brand Watches

    Maybe getTimer() or TweenMax is the answer to your problem . . .

  7. #7
    Quote Originally Posted by TheCanadian View Post
    Although, if your input is 10-100, there is a much simpler equation to use. Perhaps there's some constant you can multiply it by…
    I wonder what that constant might be ...

  8. #8
    TheCanadian's Avatar
    10,302
    posts
    Noo doot aboot it, eh?
    I'm sure there's enough leading questions in this thread to figure it out
    Proud Montanadian
    We tolerate living and breathing. And niches.

    Name Brand Watches

    Maybe getTimer() or TweenMax is the answer to your problem . . .

  9. #9
    yes thank you everyone. the answer was very simple. I needed the formula because the min-max values and variables would be different for each slider i make. thanks.

  10. #10
    TheCanadian's Avatar
    10,302
    posts
    Noo doot aboot it, eh?
    I gave you the formula in the second post
    Proud Montanadian
    We tolerate living and breathing. And niches.

    Name Brand Watches

    Maybe getTimer() or TweenMax is the answer to your problem . . .

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012