Thief007 / swingamesdk

Automatically exported from code.google.com/p/swingamesdk
1 stars 2 forks source link

Issue with negative width and height for ellipses #18

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
/* 
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
** Issues with Swingame 3.0 and DrawEllipse & FillEllipse methods in C#.
** Submitted by: Chris Tolhurst - 695578
** 
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
** When drawing an Ellipse with either negative Width or Height, or both, 
the
** Ellipse will not draw to the screen. It appears that the Swingame Engine
** can't cope with the negative values.
** 
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
**
** This Ellipse will not draw: */
    float x = X;
    float y = Y;
    int w = -20;
    int h = 30;
    Graphics.DrawEllipse(Color, x, y, w, h);

/* In order for this to draw as intended, the following adjustments need to 
be
** made: */
    Graphics.DrawEllipse(Color, (x + w), y, (w * (-1)), h);

// For a fully negative Ellipse here is what is needed:
    float x = X;
    float y = Y;
    int w = -20;
    int h = -30;
    Graphics.DrawEllipse(Color, (x + w), (y + h), (w * (-1)), (h * (-
1)));

/* 
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
** This issue is only for the Ellipse shape type; Retangles, Lines, 
Triangles
** and Polygons all appear to work fine when negative Width and Heights are
** used.
** 
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
** Some form of modification is needed for Swingames Draw and Fill Ellipse
** methods. Below is an example of ome code that catches this and adjusts 
the
** dimensions accordingly so that it will draw correctly.
** 
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
**
** Code to correctly adjust an Ellipse when resized with negative Widths 
and
** Heights: */
    if (W < 0 && H >= 0)
        Graphics.FillEllipse(Color, (X + W), Y, (W * (-1)), H);
    else if (W >= 0 && H < 0)
        Graphics.FillEllipse(Color, X, (Y + H), W, (H * (-1)));
    else if (W < 0 && H < 0)
        Graphics.FillEllipse(Color, (X + W), (Y + H), (W * (-1)), 
(H * (-1)));
    else if (W >= 0 && H >= 0)
        Graphics.FillEllipse(Color, X, Y, W, H);

Original issue reported on code.google.com by mister.c...@gmail.com on 29 Sep 2009 at 5:13

GoogleCodeExporter commented 8 years ago

Original comment by swinbr...@gmail.com on 1 Oct 2009 at 11:44

GoogleCodeExporter commented 8 years ago
Fixed.

Draw and Fill Ellipse and Circle now support drawing with a negative 
width/height.

Original comment by swinbr...@gmail.com on 1 Oct 2009 at 11:45

GoogleCodeExporter commented 8 years ago

Original comment by swinbr...@gmail.com on 1 Oct 2009 at 11:46