Thank you @mindfaQ

That is exactly what I was talking about.

@Heptagono

mindfaQ's example might need some explanation for your understanding. 'Amplitude' is Y and 'Period' (or Frequency) is what you called 'distance pp' in your graphic.

20 posts
• Page **2** of **2** • 1, **2**

I probably use too many points with rising new_period. I think canvas.width*newperiod/4 or even /8 will be enough and stay fast enough if the new_period number gets large. Also what I called period in my example is the frequency instead of period in (sinwaves/360 pixel) as unit.

and instead of adding sin to y, substract it, as it should point upwards when sin is 1, not downwardsmindfaQ 2013-11-10 23:38:13

and instead of adding sin to y, substract it, as it should point upwards when sin is 1, not downwards

Visual Novel 'Engine' in 100 Events

if you ever have to choose between buying Construct 2 on scirra.com or on Steam, read this: Review

if you ever have to choose between buying Construct 2 on scirra.com or on Steam, read this: Review

**Posts:**788**Reputation:**3,788

B

22
S

9
G

1
Not sure what you mean with that. The code already does that, no? The slider is not a necessity.

Visual Novel 'Engine' in 100 Events

if you ever have to choose between buying Construct 2 on scirra.com or on Steam, read this: Review

if you ever have to choose between buying Construct 2 on scirra.com or on Steam, read this: Review

**Posts:**788**Reputation:**3,788

B

22
S

9
G

1
I did a vey easy approach the other day

[QUOTE=lennaert] :)

web example

capx

Manipulate magnitude from sine when needed ;)[/QUOTE]

[QUOTE=lennaert] :)

web example

capx

Manipulate magnitude from sine when needed ;)[/QUOTE]

Who dares wins

**Posts:**1,880**Reputation:**19,628

B

57
S

17
G

21
[QUOTE=mindfaQ] Not sure what you mean with that. The code already does that, no? The slider is not a necessity.[/QUOTE]

Ok, I've worked out a better explanation for this:

Well, I mean that if we have two formulas to pick up the value of Amplitude and Period, let's say the ones I'm trying to implement:

Amplitude: 4 * cos^2(Pi*X/Period)

Period: Omega * Distance1 / 2 * Factor

Omega and Factor are given by two sliders.

They result in two real values, if they are introduced as variables in Draw Line:

Having a sinus in the Y term, we can find ourselves with a wave that doesn't depicts the numbers from our mathematical formulae.

That's the issue. I Hope this has been clearer. Tell me what do you think.

Ok, I've worked out a better explanation for this:

Well, I mean that if we have two formulas to pick up the value of Amplitude and Period, let's say the ones I'm trying to implement:

Amplitude: 4 * cos^2(Pi*X/Period)

Period: Omega * Distance1 / 2 * Factor

Omega and Factor are given by two sliders.

They result in two real values, if they are introduced as variables in Draw Line:

Having a sinus in the Y term, we can find ourselves with a wave that doesn't depicts the numbers from our mathematical formulae.

That's the issue. I Hope this has been clearer. Tell me what do you think.

**Posts:**105**Reputation:**1,874

B

17
S

4
G

1
Period: Distance1 is a constant I suppose? Period should calculate just fine imo.

Amplitude: What is x? also note that construct uses degrees instead of radian, so you probably want to use 180 instead of p. Also you need to place the ^2 after the brackets. Also you need to calculate the period before amplitude in the event sheet (just put the period calculation above the amplitude calculation), so that you use the current period for your calculation.

To make the drawing formula more clear (I suppose distance1 is the width of your graph):

for 1 to distance1: canvas line to: x = loopindex+startx; y = sin(loopindex*360/period)*amplitude+starty

period then would be the amount of pixels it takes to run through a full circle.

mindfaQ 2013-11-24 02:31:07

Amplitude: What is x? also note that construct uses degrees instead of radian, so you probably want to use 180 instead of p. Also you need to place the ^2 after the brackets. Also you need to calculate the period before amplitude in the event sheet (just put the period calculation above the amplitude calculation), so that you use the current period for your calculation.

To make the drawing formula more clear (I suppose distance1 is the width of your graph):

for 1 to distance1: canvas line to: x = loopindex+startx; y = sin(loopindex*360/period)*amplitude+starty

period then would be the amount of pixels it takes to run through a full circle.

Visual Novel 'Engine' in 100 Events

if you ever have to choose between buying Construct 2 on scirra.com or on Steam, read this: Review

if you ever have to choose between buying Construct 2 on scirra.com or on Steam, read this: Review

**Posts:**788**Reputation:**3,788

B

22
S

9
G

1
Hi mindfaQ,

I've prepared this clear version of the test. Below the waves box you will see a black box, which is aimed to represent a pattern of vertical lines with different color values, from white to black, depending on the point of the wave represented alog the x axis: maximum point white, minimum point black.

The x represents in the formula the whole lenght of the box, although I suspect it's aimed to be used only to show a point. If so, I fear all this effort could be in the wrong direction.

By now, the version of the proyect is here:

Test.capx

What do you think?

I've prepared this clear version of the test. Below the waves box you will see a black box, which is aimed to represent a pattern of vertical lines with different color values, from white to black, depending on the point of the wave represented alog the x axis: maximum point white, minimum point black.

The x represents in the formula the whole lenght of the box, although I suspect it's aimed to be used only to show a point. If so, I fear all this effort could be in the wrong direction.

By now, the version of the proyect is here:

Test.capx

What do you think?

**Posts:**105**Reputation:**1,874

B

17
S

4
G

1
20 posts
• Page **2** of **2** • 1, **2**

## Who is online |

Users browsing this forum: Google [Bot], kelvinb, SERGIOManOwaR and 3 guests |