4
4
5
5
#include < math.h>
6
6
7
+ #include < algorithm>
8
+
7
9
namespace Vortex {
8
10
9
11
// ================================================================================================
@@ -103,13 +105,13 @@ struct GetRoundRectDist : public DistanceFunc
103
105
104
106
float Get (float px, float py) const
105
107
{
106
- float x = min (max (px, x1 + r), x2 - r);
107
- float y = min (max (py, y1 + r), y2 - r);
108
+ float x = std:: min (std:: max (px, x1 + r), x2 - r);
109
+ float y = std:: min (std:: max (py, y1 + r), y2 - r);
108
110
if (x == px && y == py)
109
111
{
110
- float dx = min (x - x1, x2 - x);
111
- float dy = min (y - y1, y2 - y);
112
- return -min (dx, dy);
112
+ float dx = std:: min (x - x1, x2 - x);
113
+ float dy = std:: min (y - y1, y2 - y);
114
+ return -std:: min (dx, dy);
113
115
}
114
116
else
115
117
{
@@ -143,7 +145,7 @@ struct GetPolyDist : public DistanceFunc
143
145
for (int i = 0 , j = count - 1 ; i < count; j = i, ++i)
144
146
{
145
147
GetLineDist ld (x[i], y[i], x[j], y[j], 0 );
146
- d = min (d, ld.Get (px, py));
148
+ d = std:: min (d, ld.Get (px, py));
147
149
}
148
150
return InsidePoly (px, py) ? -d : d;
149
151
}
@@ -180,13 +182,13 @@ void Canvas::Data::draw(float* buf, int w, int h, const areaf& area, DistanceFun
180
182
if (blendMode == Canvas::BM_ALPHA) blendfunc = BlendAlpha;
181
183
if (blendMode == Canvas::BM_ADD) blendfunc = BlendAdd;
182
184
183
- int x1 = max (mask.l , (int )(area.l - outerGlow - 1 + 0 .5f ) );
184
- int y1 = max (mask.t , (int )(area.t - outerGlow - 1 + 0 .5f ) );
185
- int x2 = min (mask.r , (int )(area.r + outerGlow + 1 + 0 .5f ) );
186
- int y2 = min (mask.b , (int )(area.b + outerGlow + 1 + 0 .5f ) );
185
+ int x1 = std:: max (mask.l , (int )(area.l - outerGlow - 1 + 0 .5f );
186
+ int y1 = std:: max (mask.t , (int )(area.t - outerGlow - 1 + 0 .5f );
187
+ int x2 = std:: min (mask.r , (int )(area.r + outerGlow + 1 + 0 .5f );
188
+ int y2 = std:: min (mask.b , (int )(area.b + outerGlow + 1 + 0 .5f );
187
189
188
- float rh = 1 .f / max (1 , y2 - y1);
189
- float rw = 1 .f / max (1 , x2 - x1);
190
+ float rh = 1 .f / std:: max (1 , y2 - y1);
191
+ float rw = 1 .f / std:: max (1 , x2 - x1);
190
192
float ig = 1 .f / (innerGlow + 1 );
191
193
float og = 1 .f / (outerGlow + 1 );
192
194
@@ -206,12 +208,12 @@ void Canvas::Data::draw(float* buf, int w, int h, const areaf& area, DistanceFun
206
208
if (outline && dist < -0 .5f )
207
209
{
208
210
float a = 1 - ig * ((-dist - lineWidth) + 0 .5f );
209
- if (a > 0 ) blendfunc (*dst, src, min (a, 1 .f ));
211
+ if (a > 0 ) blendfunc (*dst, src, std:: min (a, 1 .f ));
210
212
}
211
213
else
212
214
{
213
215
float a = 1 - og * (dist + 0 .5f );
214
- if (a > 0 ) blendfunc (*dst, src, min (a, 1 .f ));
216
+ if (a > 0 ) blendfunc (*dst, src, std:: min (a, 1 .f ));
215
217
}
216
218
}
217
219
}
@@ -248,7 +250,7 @@ Canvas::Canvas(const Canvas& other)
248
250
249
251
void Canvas::setMask (int l, int t, int r, int b)
250
252
{
251
- data_->mask = {max (0 , l), max (0 , t), min (r, canvas_width_), min (r, canvas_height_)};
253
+ data_->mask = {std:: max (0 , l), std:: max (0 , t), std:: min (r, canvas_width_), std:: min (r, canvas_height_)};
252
254
}
253
255
254
256
void Canvas::setOutline (float size)
@@ -312,8 +314,8 @@ void Canvas::clear(float l)
312
314
void Canvas::line (float x1, float y1, float x2, float y2, float width)
313
315
{
314
316
float r = width * 0 .5f ;
315
- float xmin = min (x1, x2), xmax = max (x1, x2);
316
- float ymin = min (y1, y2), ymax = max (y1, y2);
317
+ float xmin = std:: min (x1, x2), xmax = std:: max (x1, x2);
318
+ float ymin = std:: min (y1, y2), ymax = std:: max (y1, y2);
317
319
GetLineDist func (x1, y1, x2, y2, r);
318
320
data_->draw (canvas_data_, canvas_width_, canvas_height_, {xmin - r, ymin - r, xmax + r, ymax + r}, &func);
319
321
}
@@ -326,9 +328,9 @@ void Canvas::circle(float x, float y, float r)
326
328
327
329
void Canvas::box (float x1, float y1, float x2, float y2, float radius)
328
330
{
329
- float xl = min (x1, x2), xr = max (x1, x2);
330
- float yt = min (y1, y2), yb = max (y1, y2);
331
- float r = min (min (xr - xl, yb - yt)*0 .5f , max (0 .f , radius));
331
+ float xl = std:: min (x1, x2), xr = std:: max (x1, x2);
332
+ float yt = std:: min (y1, y2), yb = std:: max (y1, y2);
333
+ float r = std:: min (std:: min (xr - xl, yb - yt)*0 .5f , std:: max (0 .f , radius));
332
334
GetRoundRectDist func (xl, yt, xr, yb, r);
333
335
data_->draw (canvas_data_, canvas_width_, canvas_height_, {xl, yt, xr, yb}, &func);
334
336
}
@@ -351,7 +353,7 @@ Texture Canvas::createTexture(bool mipmap) const
351
353
for (int i = 0 ; i < canvas_width_ * canvas_height_ * 4 ; ++i)
352
354
{
353
355
int v = (int )(canvas_data_[i] * 255 .f + 0 .5f );
354
- dst[i] = min (max (v, 0 ), 255 );
356
+ dst[i] = std:: min (std:: max (v, 0 ), 255 );
355
357
}
356
358
Texture result (canvas_width_, canvas_height_, dst, mipmap);
357
359
free (dst);
0 commit comments