Commit befb8603 authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

gdiplus: Fix GdipCreateLineBrushFromRectWithAngle implementation.

The patch fixes isAngleScalable==TRUE argument handling. It also fixes a mistake when width was used instead of height. Signed-off-by: 's avatarPiotr Caban <piotr@codeweavers.com> Signed-off-by: 's avatarVincent Povirk <vincent@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent d91f985e
......@@ -428,26 +428,43 @@ GpStatus WINGDIPAPI GdipCreateLineBrushFromRectWithAngle(GDIPCONST GpRectF* rect
{
GpStatus stat;
LinearGradientMode mode;
REAL width, height, exofs, eyofs;
REAL 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);
sin_angle = sinf(deg2rad(angle));
cos_angle = cosf(deg2rad(angle));
sin_cos_angle = sin_angle * cos_angle;
if (!rect || !rect->Width || !rect->Height)
return InvalidParameter;
angle = fmodf(angle, 360);
if (angle < 0)
angle += 360;
if (isAngleScalable)
{
width = height = 1.0;
float add_angle = 0;
while(angle >= 90) {
angle -= 180;
add_angle += M_PI;
}
if (angle != 90 && angle != -90)
angle = atan((rect->Width / rect->Height) * tan(deg2rad(angle)));
else
angle = deg2rad(angle);
angle += add_angle;
}
else
{
width = rect->Width;
height = rect->Height;
angle = deg2rad(angle);
}
sin_angle = sinf(angle);
cos_angle = cosf(angle);
sin_cos_angle = sin_angle * cos_angle;
if (sin_cos_angle >= 0)
mode = LinearGradientModeForwardDiagonal;
else
......@@ -459,19 +476,13 @@ GpStatus WINGDIPAPI GdipCreateLineBrushFromRectWithAngle(GDIPCONST GpRectF* rect
{
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;
exofs = rect->Height * sin_cos_angle + rect->Width * cos_angle * cos_angle;
eyofs = rect->Height * sin_angle * sin_angle + rect->Width * 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;
exofs = rect->Width * sin_angle * sin_angle + rect->Height * sin_cos_angle;
eyofs = -rect->Width * sin_cos_angle + rect->Height * sin_angle * sin_angle;
}
if (sin_angle >= 0)
......
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