fix: TinySVG rect scaling

This commit is contained in:
relikd
2025-12-08 16:31:53 +01:00
parent e0cd04b882
commit 1589b23aa9

View File

@@ -168,6 +168,10 @@ void svgAddCircle(CGContextRef context, CGFloat scale, CGFloat x, CGFloat y, CGF
/// Calls @c CGContextAddRect or @c CGPathAddRoundedRect (optional). /// Calls @c CGContextAddRect or @c CGPathAddRoundedRect (optional).
/// @param cornerRadius Use @c <=0 for no corners. Use half of @c min(w,h) for a full circle. /// @param cornerRadius Use @c <=0 for no corners. Use half of @c min(w,h) for a full circle.
void svgAddRect(CGContextRef context, CGFloat scale, CGRect rect, CGFloat cornerRadius) { void svgAddRect(CGContextRef context, CGFloat scale, CGRect rect, CGFloat cornerRadius) {
if (scale != 1.0) {
rect = CGRectMake(rect.origin.x * scale, rect.origin.y * scale,
rect.size.width * scale, rect.size.height * scale);
}
if (cornerRadius > 0) { if (cornerRadius > 0) {
CGMutablePathRef tmp = CGPathCreateMutable(); CGMutablePathRef tmp = CGPathCreateMutable();
CGPathAddRoundedRect(tmp, NULL, rect, cornerRadius * scale, cornerRadius * scale); CGPathAddRoundedRect(tmp, NULL, rect, cornerRadius * scale, cornerRadius * scale);