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 7712263
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T01:35:11+00:00 2026-06-01T01:35:11+00:00

I have the following function: this.alphaArray = function() { var alpha = this.alphStr, ,

  • 0

I have the following function:

this.alphaArray = function() {
  var alpha   = this.alphStr,
    , alphArr = [],
    , alphInc = (this.alphStr - this.alphEnd) / this.frames;

  for (var i=0;i<this.frames;i++) {
    alphArr.push(alpha);
    alpha -= alphInc;
  }

  return alphArr;
};

The variables are as such:

  • this.alphStr – The starting alpha value, currently 1 (100% opaque).
  • alphArr – An array that the function builds that holds the alpha value for each frame of the animation (used in a loop alongside the drawImage() function.
  • alphInc – The increment that is subtracted from the previous alpha before push()‘d into the array.
  • this.alphEnd – The ending alpha value that the images will appear as at the end of the frames, currently .01 (1% opaque).
  • this.frames – the total amount of frames (and therefor array values) that the animation is shown for.

So to add context to this function, here it is with all the values I currently have plugged in:

this.alphaArray = function() {
  var alpha   = 1,
    , alphArr = [],
    , alphInc = (1 - .01) / this.1000; // 0.00099

  for (var i=0;i<this.frames;i++) {
    alphArr.push(alpha);
    alpha -= 0.00099;
  }

  return alphArr;
};

As stated before, ultimately alphaArr with be iterated through in a while() loop, and will be assigned to context.globalAlpha before drawing an image. Right now it reduces opaqueness in a linear fashion, using a static increment (or rather, decrement) value. I want to apply an ease-in affect on the transparency using the above method of assigning all the interations in an array. Given the values for the initial transparency, the ending transparency, and the duration of the animation (this.frames), how can I apply an ease-in effect where it starts out slowly decreasing in opaqueness, and by the end in the opaqueness reduces much quicker?

  • 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-06-01T01:35:12+00:00Added an answer on June 1, 2026 at 1:35 am

    When decrementing, multiply by the current frame like so

    var frameSum = 0;
    for (var i=0; i < this.frames; i++)
    {
      frameSum = frameSum + i;
    }
    
    var origAlpha = alpha;
    for (var i=0; i < this.frames; i++) 
    {
      alphArr.push(alpha);
      alpha -= (origAlpha / frameSum) * i;
    }
    

    This will increase the opaqueness as you go farther on. You can add some other multiples to the i value if you want to adjust the speed.

    Edit

    Fixed the loop to correctly end at 0 on the final frame.

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

Sidebar

Related Questions

I have the following jquery code: jQuery(function(){ jQuery(select#rooms).change(function(){ var options = ''; jQuery.getJSON(/admin/selection.php,{id: jQuery(this).val(),
I have the following function. $(function() { $(.sectionHeader:gt(0)).click(function() { $(this).next(.fieldset).slideToggle(fast); }); $(img[alt='minimize']).click(function(e) { $(this).closest(table).next(.fieldset).slideUp(fast);
I have the following within an XHTML document: <script type=text/javascript id=JSBALLOONS> function() { this.init
I have the following simple function: private void EnableDisable941ScheduleBButton() { if (this._uosDepositorFrequency.Value != null)
I have the following jQuery: $(#toolbar).hover(function () { $(.logo).fadeOut(slow, function () { $(this).addClass(logohover) $(this).parent().addClass(logohover).fadeIn(slow,
I have the following javascript function: <script type=text/javascript> function quickCardRegister_OnCompleteSave() { publishContent('This is a
I have the following jQuery which I need adapting: $(document).ready(function(){ $(.rss-popup a).hover(function() { $(this).next(em).stop(true,
I have the following piece of code from a book. There is this function
I have the following code: $(document).ready(function(){ $(.yearInner).hide(); $(.year, this).hover( function () { $(.yearInner, this).slideToggle();
I have the following bit of code, simply: $(function() { $('a.add-photos-link').live('click', function(e) { $(this).colorbox({

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.