10 void Fill(SDL_Surface *dst, Color c) {
11 Fill(dst, c.MapRGBA(dst));
14 void Fill(SDL_Surface *dst, Uint32 color) {
15 SDL_FillRect(dst, nullptr, color);
19 void HLine(SDL_Surface *dst, Vector<int> pos, int len, Color c) {
20 HLine(dst, pos, len, c.MapRGBA(dst));
23 void HLine(SDL_Surface *dst, Vector<int> pos, int len, Uint32 c) {
24 FillRect(dst, pos, Vector<int>(len, 1), c);
27 void VLine(SDL_Surface *dst, Vector<int> pos, int len, Color c) {
28 VLine(dst, pos, len, c.MapRGBA(dst));
31 void VLine(SDL_Surface *dst, Vector<int> pos, int len, Uint32 c) {
32 FillRect(dst, pos, Vector<int>(1, len), c);
36 void FillRect(SDL_Surface *dst, Vector<int> pos, Vector<int> size, Color c) {
37 FillRect(dst, pos, size, c.MapRGBA(dst));
40 void FillRect(SDL_Surface *dst, Vector<int> pos, Vector<int> size, Uint32 c) {
46 SDL_FillRect(dst, &destRect, c);
49 void OutlineRect(SDL_Surface *dst, Vector<int> pos, Vector<int> size, Color c) {
50 OutlineRect(dst, pos, size, c.MapRGBA(dst));
53 void OutlineRect(SDL_Surface *dst, Vector<int> pos, Vector<int> size, Uint32 c) {
60 SDL_FillRect(dst, &destRect, c);
63 destRect.y = pos.y + size.y - 1;
66 SDL_FillRect(dst, &destRect, c);
72 SDL_FillRect(dst, &destRect, c);
74 destRect.x = pos.x + size.x - 1;
78 SDL_FillRect(dst, &destRect, c);
87 Uint32 c = color.MapRGBA(dst);
88 int len = 2 * extent + 1;
90 HLine(dst, Vector<int>(pos.x - extent, pos.y), len, c);
91 VLine(dst, Vector<int>(pos.x, pos.y - extent), len, c);
101 Uint32 c = color.MapRGBA(dst);
103 Vector<int> from = min(first, second);
104 Vector<int> to = max(first, second);
106 if (size.x <= 1 || size.y <= 1) {
107 FillRect(dst, from, to - from, c);
111 if (from.x > dst->w || from.y > dst->h || to.x < 0 || to.y < 0) {
115 while (from.x < -size.x) from.x += size.x;
116 while (from.y < -size.y) from.y += size.y;
117 while (to.x > dst->w + size.x) to.x -= size.x;
118 while (to.y > dst->h + size.y) to.y -= size.y;
120 int width = to.x - from.x;
121 int height = to.y - from.y;
123 for (Vector<int> pos(from); pos.x <= to.x; pos.x += size.x) {
124 VLine(dst, pos, height, c);
126 for (Vector<int> pos(from); pos.y <= to.y; pos.y += size.y) {
127 HLine(dst, pos, width, c);
137 Uint32 c = color.MapRGBA(dst);
139 Vector<int> from = min(first, second);
140 Vector<int> to = max(first, second);
142 if (size.x <= 1 || size.y <= 1) {
143 FillRect(dst, from, to - from, c);
147 if (from.x > dst->w || from.y > dst->h || to.x < 0 || to.y < 0) {
151 while (from.x < -size.x) from.x += size.x;
152 while (from.y < -size.y) from.y += size.y;
153 while (to.x > dst->w + size.x) to.x -= size.x;
154 while (to.y > dst->h + size.y) to.y -= size.y;
156 float width = to.x - from.x;
157 float height = to.y - from.y;
159 for (Vector<float> pos(from); pos.x <= to.x; pos.x += size.x) {
160 VLine(dst, pos, height, c);
162 for (Vector<float> pos(from); pos.y <= to.y; pos.y += size.y) {
163 HLine(dst, pos, width, c);
175 Uint32 c1 = color1.MapRGBA(dst);
176 Uint32 c2 = color2.MapRGBA(dst);
178 Vector<int> from = min(first, second);
179 Vector<int> to = max(first, second);
181 if (size.x <= 1 || size.y <= 1) {
182 FillRect(dst, from, to - from, c1);
183 Grid(dst, from, to, size * n, color2);
187 if (from.x > dst->w || from.y > dst->h || to.x < 0 || to.y < 0) {
192 while (from.x < -size.x) { from.x += size.x; ++i.x; }
193 while (from.y < -size.y) { from.y += size.y; ++i.y; }
194 while (to.x > dst->w + size.x) to.x -= size.x;
195 while (to.y > dst->h + size.y) to.y -= size.y;
197 int width = to.x - from.x;
198 int height = to.y - from.y;
200 for (Vector<int> pos(from); pos.x <= to.x; pos.x += size.x) {
201 VLine(dst, pos, height, (i.x++ % n.x) ? c1 : c2);
203 for (Vector<int> pos(from); pos.y <= to.y; pos.y += size.y) {
204 HLine(dst, pos, width, (i.y++ % n.y) ? c1 : c2);
216 Uint32 c1 = color1.MapRGBA(dst);
217 Uint32 c2 = color2.MapRGBA(dst);
219 Vector<int> from = min(first, second);
220 Vector<int> to = max(first, second);
222 if (size.x <= 1 || size.y <= 1) {
223 FillRect(dst, from, to - from, c1);
224 Grid(dst, from, to, size * Vector<float>(n), color2);
228 if (from.x > dst->w || from.y > dst->h || to.x < 0 || to.y < 0) {
233 while (from.x < -size.x) { from.x += size.x; ++i.x; }
234 while (from.y < -size.y) { from.y += size.y; ++i.y; }
235 while (to.x > dst->w + size.x) to.x -= size.x;
236 while (to.y > dst->h + size.y) to.y -= size.y;
238 float width = to.x - from.x;
239 float height = to.y - from.y;
241 for (Vector<float> pos(from); pos.x <= to.x; pos.x += size.x) {
242 VLine(dst, pos, height, (i.x++ % n.x) ? c1 : c2);
244 for (Vector<float> pos(from); pos.y <= to.y; pos.y += size.y) {
245 HLine(dst, pos, width, (i.y++ % n.y) ? c1 : c2);