From 2fb0c7e639d0c8ff8920a44f5400629503925133 Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Sun, 3 Aug 2008 02:44:57 +0400 Subject: [PATCH] gdiplus: Move some Beziers helpers to gdiplus.c to use them for graphicspath. --- dlls/gdiplus/gdiplus.c | 26 ++++++++++++++++++++++++++ dlls/gdiplus/gdiplus_private.h | 6 ++++++ dlls/gdiplus/graphics.c | 29 ----------------------------- 3 files changed, 32 insertions(+), 29 deletions(-) diff --git a/dlls/gdiplus/gdiplus.c b/dlls/gdiplus/gdiplus.c index fb38497084c..070a80f993b 100644 --- a/dlls/gdiplus/gdiplus.c +++ b/dlls/gdiplus/gdiplus.c @@ -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); +} diff --git a/dlls/gdiplus/gdiplus_private.h b/dlls/gdiplus/gdiplus_private.h index 8fe8862e50d..3611239f2b2 100644 --- a/dlls/gdiplus/gdiplus_private.h +++ b/dlls/gdiplus/gdiplus_private.h @@ -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); diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c index 4448b6a4f9b..2450b479504 100644 --- a/dlls/gdiplus/graphics.c +++ b/dlls/gdiplus/graphics.c @@ -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. */ -- 2.11.4.GIT