small bugfixes

This commit is contained in:
nakst 2022-08-19 14:50:19 +01:00
parent 2191d611f7
commit 5f7f600cb6
3 changed files with 16 additions and 12 deletions

View File

@ -129,7 +129,7 @@ ES_EXTERN_C __attribute__((noreturn)) void _EsCRTlongjmp(EsCRTjmp_buf *env, int
#define ES_RECT_BOTTOM_LEFT(_r) (_r).l, (_r).b
#define ES_RECT_BOTTOM_RIGHT(_r) (_r).r, (_r).b
#define ES_RECT_ALL(_r) (_r).l, (_r).r, (_r).t, (_r).b
#define ES_RECT_VALID(_r) (ES_RECT_WIDTH(_r) > 0 && ES_RECT_HEIGHT(_r) > 0)
#define ES_RECT_VALID(_r) ((_r).l < (_r).r && (_r).t < (_r).b) // This handles extreme values correctly!
#define ES_POINT(x, y) ((EsPoint) { (int32_t) (x), (int32_t) (y) })

View File

@ -516,17 +516,21 @@ void _RastJoinMeter(RAST_ARRAY(RastVertex) *output, RastVertex *from1, RastVerte
// TODO For internal contours, this can generate vertices forming anticlockwise regions if the contour width is large enough.
// (You can't see it though because we use a non-zero fill rule.)
float a = to1->x - from1->x, b = from2->x - to2->x, e = from2->x - from1->x;
float c = to1->y - from1->y, d = from2->y - to2->y, f = from2->y - from1->y;
float j = (d * e - b * f) / (d * a - b * c);
RastVertex v = { from1->x + j * (to1->x - from1->x), from1->y + j * (to1->y - from1->y) };
if ((v.x - point->x) * (v.x - point->x) + (v.y - point->y) * (v.y - point->y) <= miterLimit * miterLimit) {
RAST_ARRAY_ADD(*output, v);
} else {
// TODO Move bevel to miter limit.
RAST_ARRAY_ADD(*output, *to1);
if ((to1->x - from2->x) * (to1->x - from2->x) + (to1->y - from2->y) * (to1->y - from2->y) < RAST_ADD_VERTEX_MINIMUM_DISTANCE_SQUARED) {
RAST_ARRAY_ADD(*output, *from2);
} else {
float a = to1->x - from1->x, b = from2->x - to2->x, e = from2->x - from1->x;
float c = to1->y - from1->y, d = from2->y - to2->y, f = from2->y - from1->y;
float j = (d * e - b * f) / (d * a - b * c);
RastVertex v = { from1->x + j * (to1->x - from1->x), from1->y + j * (to1->y - from1->y) };
if ((v.x - point->x) * (v.x - point->x) + (v.y - point->y) * (v.y - point->y) <= miterLimit * miterLimit) {
RAST_ARRAY_ADD(*output, v);
} else {
// TODO Move bevel to miter limit.
RAST_ARRAY_ADD(*output, *to1);
RAST_ARRAY_ADD(*output, *from2);
}
}
}

View File

@ -847,7 +847,7 @@ float EsCRTlog2f(float x) {
c.i = (c.i & ~(0xFF << 23)) + (0x7F << 23);
x = c.f;
double y = F(0xC05B5154) + x * (F(0x410297C6) + x * (F(0xC1205CEB)
float y = F(0xC05B5154) + x * (F(0x410297C6) + x * (F(0xC1205CEB)
+ x * (F(0x4114DF63) + x * (F(0xC0C0DBBB) + x * (F(0x402942C6)
+ x * (F(0xBF3FF98A) + x * (F(0x3DFE1050) + x * F(0xBC151480))))))));