~ubuntu-branches/ubuntu/quantal/sgt-puzzles/quantal

« back to all changes in this revision

Viewing changes to drawing.c

  • Committer: Bazaar Package Importer
  • Author(s): Ben Hutchings
  • Date: 2011-03-01 04:16:54 UTC
  • mfrom: (1.2.9 upstream)
  • mto: This revision was merged to the branch mainline in revision 18.
  • Revision ID: james.westby@ubuntu.com-20110301041654-949qy9qrroziy7vq
* New upstream version:
  - Add Range and Signpost puzzles
  - Use stock icons and conventional order for dialog buttons
  - Use Cairo for screen rendering
* Update German translation, thanks to Helge Kreutzmann
* Remove or update patches applied or partially applied upstream
* Use Debian source format 3.0 (quilt)

Show diffs side-by-side

added added

removed removed

Lines of Context:
87
87
    dr->api->draw_line(dr->handle, x1, y1, x2, y2, colour);
88
88
}
89
89
 
 
90
void draw_thick_line(drawing *dr, float thickness,
 
91
                     float x1, float y1, float x2, float y2, int colour)
 
92
{
 
93
    if (dr->api->draw_thick_line) {
 
94
        dr->api->draw_thick_line(dr->handle, thickness,
 
95
                                 x1, y1, x2, y2, colour);
 
96
    } else {
 
97
        /* We'll fake it up with a filled polygon.  The tweak to the
 
98
         * thickness empirically compensates for rounding errors, because
 
99
         * polygon rendering uses integer coordinates.
 
100
         */
 
101
        float len = sqrt((x2 - x1)*(x2 - x1) + (y2 - y1)*(y2 - y1));
 
102
        float tvhatx = (x2 - x1)/len * (thickness/2 - 0.2);
 
103
        float tvhaty = (y2 - y1)/len * (thickness/2 - 0.2);
 
104
        int p[8];
 
105
 
 
106
        p[0] = x1 - tvhaty;
 
107
        p[1] = y1 + tvhatx;
 
108
        p[2] = x2 - tvhaty;
 
109
        p[3] = y2 + tvhatx;
 
110
        p[4] = x2 + tvhaty;
 
111
        p[5] = y2 - tvhatx;
 
112
        p[6] = x1 + tvhaty;
 
113
        p[7] = y1 - tvhatx;
 
114
        dr->api->draw_polygon(dr->handle, p, 4, colour, colour);
 
115
    }
 
116
}
 
117
 
90
118
void draw_polygon(drawing *dr, int *coords, int npoints,
91
119
                  int fillcolour, int outlinecolour)
92
120
{