Vincent Povirk : gdiplus: Use linear gradient brush angles.

Alexandre Julliard julliard at winehq.org
Mon Feb 8 11:06:06 CST 2010


Module: wine
Branch: master
Commit: 71e4af507fc51c18066273b6c91c843a85c7cdfe
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=71e4af507fc51c18066273b6c91c843a85c7cdfe

Author: Vincent Povirk <vincent at codeweavers.com>
Date:   Sat Feb  6 15:43:16 2010 -0600

gdiplus: Use linear gradient brush angles.

---

 dlls/gdiplus/brush.c |   66 +++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 60 insertions(+), 6 deletions(-)

diff --git a/dlls/gdiplus/brush.c b/dlls/gdiplus/brush.c
index 0f6d707..2eca755 100644
--- a/dlls/gdiplus/brush.c
+++ b/dlls/gdiplus/brush.c
@@ -468,20 +468,74 @@ GpStatus WINGDIPAPI GdipCreateLineBrushFromRectI(GDIPCONST GpRect* rect,
 
 /******************************************************************************
  * GdipCreateLineBrushFromRectWithAngle [GDIPLUS.@]
- *
- * FIXME: angle value completely ignored. Don't know how to use it since native
- *        always set Brush rectangle to rect (independetly of this angle).
- *        Maybe it's used only on drawing.
  */
 GpStatus WINGDIPAPI GdipCreateLineBrushFromRectWithAngle(GDIPCONST GpRectF* rect,
     ARGB startcolor, ARGB endcolor, REAL angle, BOOL isAngleScalable, GpWrapMode wrap,
     GpLineGradient **line)
 {
+    GpStatus stat;
+    LinearGradientMode mode;
+    REAL width, height, exofs, eyofs;
+    REAL sin_angle, cos_angle, sin_cos_angle;
+
     TRACE("(%p, %x, %x, %.2f, %d, %d, %p)\n", rect, startcolor, endcolor, angle, isAngleScalable,
           wrap, line);
 
-    return GdipCreateLineBrushFromRect(rect, startcolor, endcolor, LinearGradientModeForwardDiagonal,
-                                       wrap, line);
+    sin_angle = sinf(deg2rad(angle));
+    cos_angle = cosf(deg2rad(angle));
+    sin_cos_angle = sin_angle * cos_angle;
+
+    if (isAngleScalable)
+    {
+        width = height = 1.0;
+    }
+    else
+    {
+        width = rect->Width;
+        height = rect->Height;
+    }
+
+    if (sin_cos_angle >= 0)
+        mode = LinearGradientModeForwardDiagonal;
+    else
+        mode = LinearGradientModeBackwardDiagonal;
+
+    stat = GdipCreateLineBrushFromRect(rect, startcolor, endcolor, mode, wrap, line);
+
+    if (stat == Ok)
+    {
+        if (sin_cos_angle >= 0)
+        {
+            exofs = width * sin_cos_angle + height * cos_angle * cos_angle;
+            eyofs = width * sin_angle * sin_angle + height * sin_cos_angle;
+        }
+        else
+        {
+            exofs = width * sin_angle * sin_angle + height * sin_cos_angle;
+            eyofs = -width * sin_cos_angle + height * sin_angle * sin_angle;
+        }
+
+        if (isAngleScalable)
+        {
+            exofs = exofs * rect->Width;
+            eyofs = eyofs * rect->Height;
+        }
+
+        if (sin_angle >= 0)
+        {
+            (*line)->endpoint.X = rect->X + exofs;
+            (*line)->endpoint.Y = rect->Y + eyofs;
+        }
+        else
+        {
+            (*line)->endpoint.X = (*line)->startpoint.X;
+            (*line)->endpoint.Y = (*line)->startpoint.Y;
+            (*line)->startpoint.X = rect->X + exofs;
+            (*line)->startpoint.Y = rect->Y + eyofs;
+        }
+    }
+
+    return stat;
 }
 
 GpStatus WINGDIPAPI GdipCreateLineBrushFromRectWithAngleI(GDIPCONST GpRect* rect,




More information about the wine-cvs mailing list