-2

Let's say I want to move a shape with coordinates.

The end position is: -500 pixels. The start position is: 500 pixels.

Using a slider with a range of 1-100, I want to move the shape between the start and end position using percentage. When this percent value changes, I want to move the shape. 100% would place the shape at the end position, 0% would place the shape at the start position. Any percentage between would set the pixel value accordingly.

Letters below are variables.

A: -500

B: 500

C: Percentage value between (1-100).

D: (ANSWER)

I need a new value (D) to be the percentage value (C) between (A) & (B).

So if (C) was 50 - (D) would be value 0.

50% between A and B is 0.
SMKS_ARTS
  • 11
  • 2

2 Answers2

0

I think you are looking for $$ D = A + (B-A)\cdot \frac{C}{100} $$ or, with your particular $A$ and $B$ inserted, $$ D = 10\cdot C - 500 $$

0

Given two numbers $\alpha $ and $\beta $, a percentage change of $\gamma $ gives the position as $\delta =\alpha +\frac {\beta-\alpha}{100}\gamma $. Try using this result with $\alpha=-500$ and $\beta=500$. Hope it helps.

  • Why the Greek letters? That seems to be likely to confuse the OP for absolutely no gain that I can see. – hmakholm left over Monica Jan 23 '17 at 12:40
  • Sorry, @HenningMackholm I did not load your answer while writing mine and then I saw that we have both given the answer along the same lines. Sorry again. –  Jan 23 '17 at 12:45