Recent

Author Topic: [Solved][LazFreeType]How to interpolate a point not on the curve?  (Read 29190 times)

zamtmn

  • Hero Member
  • *****
  • Posts: 594
As I understand it in the TTF fonts order Bezier curve is not limited. There may be three or more points not on the curve. Built in LazFreeType tools for interpolating Bezier curves I have found. Interpolation to be done by himself or have a ready method in LazUtils?

In the screenshot "x" marked point on the curve, "o" - not on the curve.
« Last Edit: February 22, 2013, 07:08:31 am by zamtmn »

circular

  • Hero Member
  • *****
  • Posts: 4195
    • Personal webpage
Re: [LazFreeType]How to interpolate a point not on the curve?
« Reply #1 on: February 19, 2013, 09:44:42 am »
You mean you need a function do compute those ?

Yes, there are built in functions in LazFreeType, but not easy to use. To my knowledge, there are no independant function, and Bezier functions generally have 1 or 2 control points.
Conscience is the debugger of the mind

zamtmn

  • Hero Member
  • *****
  • Posts: 594
Re: [LazFreeType]How to interpolate a point not on the curve?
« Reply #2 on: February 19, 2013, 10:04:39 am »
>>Built in LazFreeType tools for interpolating Bezier curves I have found
Sorry for my english (google.translate). I not found.

>>You mean you need a function do compute those ?
Yes
>>Yes, there are built in functions in LazFreeType, but not easy to use
Where are they?

circular

  • Hero Member
  • *****
  • Posts: 4195
    • Personal webpage
Re: [LazFreeType]How to interpolate a point not on the curve?
« Reply #3 on: February 19, 2013, 10:20:45 am »
I suppose it is the Split_Bezier method in TTProfile unit, but I'm not sure how it works.
Conscience is the debugger of the mind

zamtmn

  • Hero Member
  • *****
  • Posts: 594
Re: [LazFreeType]How to interpolate a point not on the curve?
« Reply #4 on: February 21, 2013, 06:13:27 am »
Thanks. Мethods from the TTProfile unit too complicated for me. I did my implementation Bezier
>> and Bezier functions generally have one or two control points.
In cases when there is 2 or more points "not on curve", between them need generate a point "on curve." It turned out that the Bezier curves in TTF always quadratic

circular

  • Hero Member
  • *****
  • Posts: 4195
    • Personal webpage
Re: [LazFreeType]How to interpolate a point not on the curve?
« Reply #5 on: February 21, 2013, 08:14:50 am »
Ok, so how is computed for example a point with 3 control points using 2-control-point bezier curves ?

Let's say these are (p1,p2,p3,p4,p5), what do you do with them?
Conscience is the debugger of the mind

zamtmn

  • Hero Member
  • *****
  • Posts: 594
Re: [LazFreeType]How to interpolate a point not on the curve?
« Reply #6 on: February 21, 2013, 09:27:46 am »
First I made the interpolation points as Bezier curves of higher order. This is not correct, see wrong.png. Then added via points - all became good, see good.png. If there is a sequence P0, P1, P2, P3, and P0,P3 - on curve, P1,P2 not on curve, It splits into two quadratic Bezier curve.
P0, P1, (P1+P2)/2
and
(P1+P2)/2, P2, P3

circular

  • Hero Member
  • *****
  • Posts: 4195
    • Personal webpage
Re: [LazFreeType]How to interpolate a point not on the curve?
« Reply #7 on: February 21, 2013, 10:29:59 pm »
Oh ok, so no cubic Bezier at all. And if there are 3 control points ?

P0, P1, P2, P3, P4 with P0,P4 on curve ?

Does it gives :
P0, P1, (P1+P2)/2
(P1+P2)/2, P2,(P2+P3)/2
(P2+P3)/2, P3, P4
?
Conscience is the debugger of the mind

zamtmn

  • Hero Member
  • *****
  • Posts: 594
Re: [LazFreeType]How to interpolate a point not on the curve?
« Reply #8 on: February 21, 2013, 10:55:22 pm »
>>P0, P1, (P1+P2)/2
>>(P1+P2)/2, P2,(P2+P3)/2
>>(P2+P3)/2, P3, P4
Yes, it is.
But it also may be the case that there is no point on the curve, look at the circle of the percent. In this case between the points are added to the mid-points on the curve. And because of the fact that the circuit is closed again be quadratic curves

User137

  • Hero Member
  • *****
  • Posts: 1791
    • Nxpascal home
Re: [LazFreeType]How to interpolate a point not on the curve?
« Reply #9 on: February 22, 2013, 12:30:13 am »
I don't know if this is what you are looking for, but catmull curve goes through the points. Helper points are simply next polygon points in the curve.
http://code.google.com/p/nxpascal/source/browse/trunk/src/nxMath.pas#75
Code: [Select]
function Catmull(const p0,p1,p2,p3,t: single): single;
begin
  result:=0.5*( 2*p1+(p2-p0)*t +
    (2*p0-5*p1+4*p2-p3)*t*t +
    (3*p1-p0-3*p2+p3)*t*t*t );
end;

I mean it could look like that in the middle of long point sequence:
http://www.mvps.org/directx/articles/shadeland.old/images/spline2a.gif
Red circles are p0..p3 from left to right.
« Last Edit: February 22, 2013, 12:32:21 am by User137 »

circular

  • Hero Member
  • *****
  • Posts: 4195
    • Personal webpage
Re: [LazFreeType]How to interpolate a point not on the curve?
« Reply #10 on: February 22, 2013, 01:00:07 am »
>>P0, P1, (P1+P2)/2
>>(P1+P2)/2, P2,(P2+P3)/2
>>(P2+P3)/2, P3, P4
Yes, it is.
But it also may be the case that there is no point on the curve, look at the circle of the percent. In this case between the points are added to the mid-points on the curve. And because of the fact that the circuit is closed again be quadratic curves
Alright, thank you very much for the explanations.
Conscience is the debugger of the mind

circular

  • Hero Member
  • *****
  • Posts: 4195
    • Personal webpage
Re: [LazFreeType]How to interpolate a point not on the curve?
« Reply #11 on: February 22, 2013, 01:01:36 am »
I don't know if this is what you are looking for, but catmull curve goes through the points. Helper points are simply next polygon points in the curve.
http://code.google.com/p/nxpascal/source/browse/trunk/src/nxMath.pas#75
Code: [Select]
function Catmull(const p0,p1,p2,p3,t: single): single;
begin
  result:=0.5*( 2*p1+(p2-p0)*t +
    (2*p0-5*p1+4*p2-p3)*t*t +
    (3*p1-p0-3*p2+p3)*t*t*t );
end;

I mean it could look like that in the middle of long point sequence:
http://www.mvps.org/directx/articles/shadeland.old/images/spline2a.gif
Red circles are p0..p3 from left to right.
It seems like a cubic spline.
Conscience is the debugger of the mind

zamtmn

  • Hero Member
  • *****
  • Posts: 594
Re: [Solved][LazFreeType]How to interpolate a point not on the curve?
« Reply #12 on: February 22, 2013, 07:13:23 am »
User137
Thanks, but in this case it does not fit. As it turned out, in TTF fonts used only quadratic Bezier curves http://en.wikipedia.org/wiki/File:Bezier_2_big.gif

zamtmn

  • Hero Member
  • *****
  • Posts: 594
Re: [Solved][LazFreeType]How to interpolate a point not on the curve?
« Reply #13 on: February 23, 2013, 09:52:15 am »
Previous screenshots I gave the value ftFont.SizeInPoints: = 100; If SizeInPoints reduce glyphs detail decreases and artefacts appear. I've attached a screenshot of the font times.ttf and ftFont.SizeInPoints: = 10. And the values ​​that appear after distortion for all the fonts are different. What values ​​to use to always get the maximum detail glyphs?

circular

  • Hero Member
  • *****
  • Posts: 4195
    • Personal webpage
Re: [Solved][LazFreeType]How to interpolate a point not on the curve?
« Reply #14 on: February 23, 2013, 01:32:06 pm »
You need to deactivate font hinting (Hinted property).
Conscience is the debugger of the mind

 

TinyPortal © 2005-2018