Commit 2fb0c7e6 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

gdiplus: Move some Beziers helpers to gdiplus.c to use them for graphicspath.

parent 2583975e
......@@ -285,3 +285,29 @@ REAL convert_unit(HDC hdc, GpUnit unit)
return 1.0;
}
}
/* Calculates Bezier points from cardinal spline points. */
void calc_curve_bezier(CONST GpPointF *pts, REAL tension, REAL *x1,
REAL *y1, REAL *x2, REAL *y2)
{
REAL xdiff, ydiff;
/* calculate tangent */
xdiff = pts[2].X - pts[0].X;
ydiff = pts[2].Y - pts[0].Y;
/* apply tangent to get control points */
*x1 = pts[1].X - tension * xdiff;
*y1 = pts[1].Y - tension * ydiff;
*x2 = pts[1].X + tension * xdiff;
*y2 = pts[1].Y + tension * ydiff;
}
/* Calculates Bezier points from cardinal spline endpoints. */
void calc_curve_bezier_endp(REAL xend, REAL yend, REAL xadj, REAL yadj,
REAL tension, REAL *x, REAL *y)
{
/* tangent at endpoints is the line from the endpoint to the adjacent point */
*x = roundr(tension * (xadj - xend) + xend);
*y = roundr(tension * (yadj - yend) + yend);
}
......@@ -38,6 +38,7 @@
#define INCH_HIMETRIC (2540)
#define VERSION_MAGIC 0xdbc01001
#define TENSION_CONST (0.3)
COLORREF ARGB2COLORREF(ARGB color);
extern INT arc2polybezier(GpPointF * points, REAL x1, REAL y1, REAL x2, REAL y2,
......@@ -46,6 +47,11 @@ extern REAL gdiplus_atan2(REAL dy, REAL dx);
extern GpStatus hresult_to_status(HRESULT res);
extern REAL convert_unit(HDC hdc, GpUnit unit);
extern void calc_curve_bezier(CONST GpPointF *pts, REAL tension, REAL *x1,
REAL *y1, REAL *x2, REAL *y2);
extern void calc_curve_bezier_endp(REAL xend, REAL yend, REAL xadj, REAL yadj,
REAL tension, REAL *x, REAL *y);
static inline INT roundr(REAL x)
{
return (INT) floorf(x + 0.5);
......
......@@ -42,7 +42,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(gdiplus);
/* looks-right constants */
#define TENSION_CONST (0.3)
#define ANCHOR_WIDTH (2.0)
#define MAX_ITERS (50)
......@@ -194,34 +193,6 @@ static void draw_pie(GpGraphics *graphics, REAL x, REAL y, REAL width,
pti[2].y, pti[3].x, pti[3].y);
}
/* GdipDrawCurve helper function.
* Calculates Bezier points from cardinal spline points. */
static void calc_curve_bezier(CONST GpPointF *pts, REAL tension, REAL *x1,
REAL *y1, REAL *x2, REAL *y2)
{
REAL xdiff, ydiff;
/* calculate tangent */
xdiff = pts[2].X - pts[0].X;
ydiff = pts[2].Y - pts[0].Y;
/* apply tangent to get control points */
*x1 = pts[1].X - tension * xdiff;
*y1 = pts[1].Y - tension * ydiff;
*x2 = pts[1].X + tension * xdiff;
*y2 = pts[1].Y + tension * ydiff;
}
/* GdipDrawCurve helper function.
* Calculates Bezier points from cardinal spline endpoints. */
static void calc_curve_bezier_endp(REAL xend, REAL yend, REAL xadj, REAL yadj,
REAL tension, REAL *x, REAL *y)
{
/* tangent at endpoints is the line from the endpoint to the adjacent point */
*x = roundr(tension * (xadj - xend) + xend);
*y = roundr(tension * (yadj - yend) + yend);
}
/* Draws the linecap the specified color and size on the hdc. The linecap is in
* direction of the line from x1, y1 to x2, y2 and is anchored on x2, y2. Probably
* should not be called on an hdc that has a path you care about. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment