diff --git a/demo/src/drawing.c b/demo/src/drawing.c index 544791f..5456f86 100644 --- a/demo/src/drawing.c +++ b/demo/src/drawing.c @@ -18,11 +18,16 @@ void drawingInit() { void drawingDraw() { saveState(); - double x = 512 - 64; + double x = 512 - 176; double y = 512 - 64; - strokeWidth(20); + strokeWidth(4); + fill(colorByRGBA(1, 0, 0, 1)); + stroke(colorByRGBA(0, 0, 1, 0.5)); + rectRounded(x, y, 48*2, 48, 8); + x += 48*2 + 16; + strokeWidth(20); fill(colorByName("red")); stroke(colorByName("blue")); rect(x, y, 48*2, 48); diff --git a/demo/src/font.c b/demo/src/font.c index 84613ad..0da9efa 100644 --- a/demo/src/font.c +++ b/demo/src/font.c @@ -31,8 +31,7 @@ void fontDraw() { text(x, y, "Here is the\nright aligned\ntext. VAW."); resetState(); - textFontDefault(); - + x = 196; y = 384; double w = 128; diff --git a/doc/helianthus-doc-ru.odt b/doc/helianthus-doc-ru.odt index 99de8cd..a66c167 100644 Binary files a/doc/helianthus-doc-ru.odt and b/doc/helianthus-doc-ru.odt differ diff --git a/src/drawing.c b/src/drawing.c index 64ba582..f6a4c27 100644 --- a/src/drawing.c +++ b/src/drawing.c @@ -258,6 +258,46 @@ void rect(double x, double y, double width, double height) { endPath(TRUE, TRUE, FALSE, FALSE); } +void rectRounded(double x, double y, double width, double height, double radius) { + radius = fabs(radius); + if (radius < HELI_PRECISION) + { rect(x, y, width, height); return; } + double x0 = x, y0 = y, x1 = x + width, y1 = y + height; + if (width < 0) { x0 = x1; x1 = x; } + if (height < 0) { y0 = y1; y1 = y; } + + double rw = 0.5*fabs(width); + double rh = 0.5*fabs(height); + if (radius > rw) radius = rw; + if (radius > rh) radius = rh; + int lw = fabs(rw - radius) > HELI_PRECISION; + int lh = fabs(rh - radius) > HELI_PRECISION; + double r2 = radius + radius; + + if (lw && lh) { + resetPath(); + arcPath( x0 , y0 , r2, r2, -180, -90 ); + arcPath( x1-r2, y0 , r2, r2, -90, 0 ); + arcPath( x1-r2, y1-r2, r2, r2, 0, 90 ); + arcPath( x0 , y1-r2, r2, r2, 90, 180 ); + closePath(); + } else + if (lw) { + resetPath(); + arcPath( x0 , y0, r2, y1-y0, 90, 270 ); + arcPath( x1-r2, y0, r2, y1-y0, -90, 90 ); + closePath(); + } else + if (lh) { + resetPath(); + arcPath( x0, y0 , x1-x0, y0+r2, -180, 0 ); + arcPath( x0, y1-r2, x1-x0, y1 , 0, 180 ); + closePath(); + } else { + circle(0.5*(x0 + x1), 0.5*(y0 + y1), radius); + } +} + void rectTextured(Animation animation, double x, double y, double width, double height) { saveState(); fillTexture(animation, x, y, width, height, FALSE); @@ -887,6 +927,7 @@ void resetStateEx(unsigned int flags) { if (flags & STATE_STROKE_WIDTH ) strokeWidth(1); if (flags & STATE_TEXT_ALIGN ) textAlign(HALIGN_LEFT, VALIGN_TOP); if (flags & STATE_TEXT_SIZE ) textSize(24); + if (flags & STATE_TEXT_FONT ) textFontDefault(); if (flags & STATE_TARGET_FRAMEBUFFER) targetEx(NULL, FALSE, FALSE); if (flags & STATE_TARGET_VIEWPORT ) viewportByWindow(); if (flags & STATE_TARGET_PROJECTION ) projectionByViewport(); diff --git a/src/drawing.h b/src/drawing.h index d2d00da..d22270b 100644 --- a/src/drawing.h +++ b/src/drawing.h @@ -119,6 +119,7 @@ double colorGetVChrominance(unsigned int colorCode); void rect(double x, double y, double width, double height); +void rectRounded(double x, double y, double width, double height, double radius); void rectTextured(Animation animation, double x, double y, double width, double height); void ellipse(double x, double y, double width, double height); void circle(double x, double y, double radius);