Heretic86 Posted May 26, 2022 Share Posted May 26, 2022 Im messing around in HTML5 Canvas which uses Javascript to draw to the Canvas. The Canvas is being used to display an RPG Character attribute over the number of levels. Making a Linear Slope (straight line) is easy. (NOTE: same post on a couple places I dont visit regularly, varied responses are VERY helpful...) Im curious what the formula is to calculate the value for each level that implements an Exponential Curve? The following image is from the Editor that I am trying to emulate. This is a Non Exponential Curve, which I already have working. These are the Exponential Curves that I want to emulate, and I dont know the value of the Slider when its set to either "Fast" or "Slow", and "Middle" is a Non Exponential Curve (so guessing a value of 0 there. What would I need to do to generate a curve that looks like this, where we input the Level 1 and Level 99 values? Experimented with something like this but its not coming out anywhere like I need it to... let exp_list = [null]; let pow = parseInt(slider.value); for (let i = 1; i < 99; i++){ exp_list[i] = 500 * (n ** pow) + 1; // ???? ab^x } Not quite sure what this formula is to plug in here. Halp? Quote Link to comment Share on other sites More sharing options...
Saint_Pepsi Posted May 26, 2022 Share Posted May 26, 2022 (edited) Have you tried using Math.pow() ? Docs: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/pow Edited May 26, 2022 by Saint_Pepsi Quote Link to comment Share on other sites More sharing options...
Heretic86 Posted May 26, 2022 Author Share Posted May 26, 2022 This ones going in Javascript, so exponents there are ** operators, others are ^ operators... Im just having trouble figuring out how to implement a* (b ** x) + c so I dont really have anything close to working since i cant figure out where to plug in the variables into the data! I understand that there should be a way to do something like a Level Curve as i, where i ** exp = 9999, but not sure where to plug in those figures into the equation? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.