Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 232693
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T20:02:20+00:00 2026-05-11T20:02:20+00:00

I’m trying to add a fade effect to my form by manually changing the

  • 0

I’m trying to add a fade effect to my form by manually changing the opacity of the form but I’m having some trouble calculating the correct value to increment by the Opacity value of the form.

I know I could use the AnimateWindow API but it’s showing some unexpected behavior and I’d rather do it manually anyways as to avoid any p/invoke so I could use it in Mono later on.

My application supports speeds ranging from 1 to 10. And I’ve manually calculated that for a speed of 1 (slowest) I should increment the opacity by 0.005 and for a speed of 10 (fastest) I should increment by 0.1. As for the speeds between 1 and 10, I used the following expression to calculate the correct value:

double opSpeed = (((0.1 - 0.005) * (10 - X)) / (1 - 10)) + 0.1; // X = [1, 10]

I though this could give me a linear value and that that would be OK. However, for X equal 4 and above, it’s already too fast. More than it should be. I mean, speeds between 7, and 10, I barely see a difference and the animation speed with these values should be a little more spaced

Note that I still want the fastest increment to be 0.1 and the slowest 0.005. But I need all the others to be linear between them.

What I’m doing wrong?

It actually makes sense why it works like this, for instance, for a fixed interval between increments, say a few milliseconds, and with the equation above, if X = 10, then opSpeed = 0.1 and if X = 5, then opSpeed = 0.47. If we think about this, a value of 0.1 will loop 10 times and a value of 0.47 will loop just the double. For such a small interval of just a few milliseconds, the difference between these values is not that much as to differentiate speeds from 5 to 10.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T20:02:20+00:00Added an answer on May 11, 2026 at 8:02 pm

    I think what you want is:

    0.005 + ((0.1-0.005)/9)*(X-1)
    

    for X ranging from 1-10

    This gives a linear scale corresponding to 0.005 when X = 1 and 0.1 when X = 10

    After the comments below, I’m also including my answer fit for a geometric series instead of a linear scale.

    0.005 * (20^((X-1)/9)))
    

    Results in a geometric variation corresponding to 0.005 when X = 1 and 0.1 when X = 10

    After much more discussion, as seen in the comments below, the updates are as follows.

    @Nazgulled found the following relation between my geometric series and the manual values he actually needed to ensure smooth fade animation.

    The relationship was as follows:
    I ♥ Graphs! :)

    Which means a geometric/exponential series is the way to go.

    After my hours of trying to come up with the appropriate curve fitting to the right hand side graph and derive a proper equation, @Nazgulled informed me that Wolfram|Alpha does that. Seriously amazing. 🙂

    Wolfram Alpha link

    He should have what he wants now, barring very high error from the equation above.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have just tried to save a simple *.rtf file with some websites and
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
That's pretty much it. I'm using Nokogiri to scrape a web page what has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.