Re: [Interest] sin wave with QPainterPath between two points

2017-07-20 Thread Allan Sandfeld Jensen
On Donnerstag, 20. Juli 2017 10:28:17 CEST Elvis Stansvik wrote:
> 2017-07-20 10:23 GMT+02:00 Jean-Michaël Celerier
> 
> :
> > You can just compute the sine directly :
> >for(int i = 0; i < width; i++)
> >{
> >
> >  int x = i;
> >  int y = height / 2 + amplitude * std::sin(2 * M_PI * freq * i / width
> >  +
> > 
> > phase);
> > 
> >  path.lineTo(x, y);
> >
> >}
> 
> I think he wanted to avoid an approximation with straight lines and
> use cubic beziers.
> 
If he doesn't do it, Qt will just do it for him based on the bezier curves.

`Allan
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] sin wave with QPainterPath between two points

2017-07-20 Thread Elvis Stansvik
2017-07-20 10:30 GMT+02:00 Patrick Stinson :
> Also it should be between two arbitrary points, so the sine wave may go from
> top-right to bottom left, for example.

Right, but that's just a transformation of the bezier control points
once you have them.

Elvis

>
> On Jul 20, 2017, at 1:28 AM, Elvis Stansvik  wrote:
>
> 2017-07-20 10:23 GMT+02:00 Jean-Michaël Celerier
> :
>
> You can just compute the sine directly :
>
>   for(int i = 0; i < width; i++)
>   {
> int x = i;
> int y = height / 2 + amplitude * std::sin(2 * M_PI * freq * i / width +
> phase);
> path.lineTo(x, y);
>   }
>
>
> I think he wanted to avoid an approximation with straight lines and
> use cubic beziers.
>
> Jean-Michaël: There seems to be many pages explaining the theory
> behind sine approximation using Beziers if you Google.
>
> Elvis
>
>
>
>
>
>
> ---
> Jean-Michaël Celerier
> http://www.jcelerier.name
>
> On Thu, Jul 20, 2017 at 9:47 AM, Patrick Stinson 
> wrote:
>
>
> Hello! I want to figure out how to draw a sin wave between two QPointF’s
> using QPainterPath. Calculating the cubic control points seems like the best
> way, but I am far from mastering that theory.
>
> This is a diagramming app and the goal is to get a squiggly line between
> two objects.
>
> Thanks!
> ___
> Interest mailing list
> Interest@qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>
>
>
> ___
> Interest mailing list
> Interest@qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>
>
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] sin wave with QPainterPath between two points

2017-07-20 Thread Patrick Stinson
Also it should be between two arbitrary points, so the sine wave may go from 
top-right to bottom left, for example.

> On Jul 20, 2017, at 1:28 AM, Elvis Stansvik  wrote:
> 
> 2017-07-20 10:23 GMT+02:00 Jean-Michaël Celerier
> >:
>> You can just compute the sine directly :
>> 
>>   for(int i = 0; i < width; i++)
>>   {
>> int x = i;
>> int y = height / 2 + amplitude * std::sin(2 * M_PI * freq * i / width +
>> phase);
>> path.lineTo(x, y);
>>   }
> 
> I think he wanted to avoid an approximation with straight lines and
> use cubic beziers.
> 
> Jean-Michaël: There seems to be many pages explaining the theory
> behind sine approximation using Beziers if you Google.
> 
> Elvis
> 
>> 
>> 
>> 
>> 
>> 
>> ---
>> Jean-Michaël Celerier
>> http://www.jcelerier.name
>> 
>> On Thu, Jul 20, 2017 at 9:47 AM, Patrick Stinson 
>> wrote:
>>> 
>>> Hello! I want to figure out how to draw a sin wave between two QPointF’s
>>> using QPainterPath. Calculating the cubic control points seems like the best
>>> way, but I am far from mastering that theory.
>>> 
>>> This is a diagramming app and the goal is to get a squiggly line between
>>> two objects.
>>> 
>>> Thanks!
>>> ___
>>> Interest mailing list
>>> Interest@qt-project.org
>>> http://lists.qt-project.org/mailman/listinfo/interest
>>> 
>> 
>> 
>> ___
>> Interest mailing list
>> Interest@qt-project.org 
>> http://lists.qt-project.org/mailman/listinfo/interest 
>> 


smime.p7s
Description: S/MIME cryptographic signature
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] sin wave with QPainterPath between two points

2017-07-20 Thread Elvis Stansvik
2017-07-20 10:23 GMT+02:00 Jean-Michaël Celerier
:
> You can just compute the sine directly :
>
>for(int i = 0; i < width; i++)
>{
>  int x = i;
>  int y = height / 2 + amplitude * std::sin(2 * M_PI * freq * i / width +
> phase);
>  path.lineTo(x, y);
>}

I think he wanted to avoid an approximation with straight lines and
use cubic beziers.

Jean-Michaël: There seems to be many pages explaining the theory
behind sine approximation using Beziers if you Google.

Elvis

>
>
>
>
>
> ---
> Jean-Michaël Celerier
> http://www.jcelerier.name
>
> On Thu, Jul 20, 2017 at 9:47 AM, Patrick Stinson 
> wrote:
>>
>> Hello! I want to figure out how to draw a sin wave between two QPointF’s
>> using QPainterPath. Calculating the cubic control points seems like the best
>> way, but I am far from mastering that theory.
>>
>> This is a diagramming app and the goal is to get a squiggly line between
>> two objects.
>>
>> Thanks!
>> ___
>> Interest mailing list
>> Interest@qt-project.org
>> http://lists.qt-project.org/mailman/listinfo/interest
>>
>
>
> ___
> Interest mailing list
> Interest@qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] sin wave with QPainterPath between two points

2017-07-20 Thread Jean-Michaël Celerier
You can just compute the sine directly :

   for(int i = 0; i < width; i++)
   {
 int x = i;
 int y = height / 2 + amplitude * std::sin(2 * M_PI * freq * i / width
+ phase);
 path.lineTo(x, y);
   }





---
Jean-Michaël Celerier
http://www.jcelerier.name

On Thu, Jul 20, 2017 at 9:47 AM, Patrick Stinson 
wrote:

> Hello! I want to figure out how to draw a sin wave between two QPointF’s
> using QPainterPath. Calculating the cubic control points seems like the
> best way, but I am far from mastering that theory.
>
> This is a diagramming app and the goal is to get a squiggly line between
> two objects.
>
> Thanks!
> ___
> Interest mailing list
> Interest@qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>
>
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest