From 148908350577ba8949ad574406cfcc80fb9fd752 Mon Sep 17 00:00:00 2001 From: "Lou (loha)" Date: Mon, 5 Aug 2024 04:20:41 +0200 Subject: [PATCH] merge Lou's and Clem's Radius/Radiis, Paint/fill and ToFloat/Cast --- src/libs/karm-math/path.cpp | 16 ++++++++-------- src/web/vaev-layout/frag.h | 10 +++++----- src/web/vaev-layout/sizing.cpp | 16 ++++++++-------- src/web/vaev-paint/borders.h | 12 ++++++------ 4 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/libs/karm-math/path.cpp b/src/libs/karm-math/path.cpp index 64f3728173..9dc33f2194 100644 --- a/src/libs/karm-math/path.cpp +++ b/src/libs/karm-math/path.cpp @@ -297,14 +297,14 @@ void Path::rect(Math::Rectf rect, Math::Radiif radii) { } else { radii = radii.reduceOverlap(rect.size()); - f64 cpa = radius.a * 0.5522847498; - f64 cpb = radius.b * 0.5522847498; - f64 cpc = radius.c * 0.5522847498; - f64 cpd = radius.d * 0.5522847498; - f64 cpe = radius.e * 0.5522847498; - f64 cpf = radius.f * 0.5522847498; - f64 cpg = radius.g * 0.5522847498; - f64 cph = radius.h * 0.5522847498; + f64 cpa = radii.a * 0.5522847498; + f64 cpb = radii.b * 0.5522847498; + f64 cpc = radii.c * 0.5522847498; + f64 cpd = radii.d * 0.5522847498; + f64 cpe = radii.e * 0.5522847498; + f64 cpf = radii.f * 0.5522847498; + f64 cpg = radii.g * 0.5522847498; + f64 cph = radii.h * 0.5522847498; moveTo({rect.x + radii.b, rect.y}); diff --git a/src/web/vaev-layout/frag.h b/src/web/vaev-layout/frag.h index 2b3e748871..bed7dd61f0 100644 --- a/src/web/vaev-layout/frag.h +++ b/src/web/vaev-layout/frag.h @@ -66,21 +66,21 @@ struct Frag { // FIXME colorContext should be context dependant box.borders = Paint::Borders(); - box.borders.radii = _box.radius.cast(); + box.borders.radii = _box.radii.cast(); - box.borders.top.width = _box.borders.top.toFloat(); + box.borders.top.width = _box.borders.top.cast(); box.borders.top.style = style().borders->top.style; box.borders.top.fill = colorContext.resolve(style().borders->top.color); - box.borders.bottom.width = _box.borders.bottom.toFloat(); + box.borders.bottom.width = _box.borders.bottom.cast(); box.borders.bottom.style = style().borders->bottom.style; box.borders.bottom.fill = colorContext.resolve(style().borders->bottom.color); - box.borders.start.width = _box.borders.start.toFloat(); + box.borders.start.width = _box.borders.start.cast(); box.borders.start.style = style().borders->start.style; box.borders.start.fill = colorContext.resolve(style().borders->start.color); - box.borders.end.width = _box.borders.end.toFloat(); + box.borders.end.width = _box.borders.end.cast(); box.borders.end.style = style().borders->end.style; box.borders.end.fill = colorContext.resolve(style().borders->end.color); diff --git a/src/web/vaev-layout/sizing.cpp b/src/web/vaev-layout/sizing.cpp index 4466e3e24e..7041dc77c1 100644 --- a/src/web/vaev-layout/sizing.cpp +++ b/src/web/vaev-layout/sizing.cpp @@ -219,14 +219,14 @@ Box computeBox(Context &ctx, RectPx borderBox) { if (ctx.style().borders->start.style != BorderStyle::NONE) res.borders.start = computeInset(ctx, Axis::HORIZONTAL, ctx.style().borders->start.width); - res.radius.a = computeInset(ctx, Axis::VERTICAL, ctx.style().borders->radii.a); - res.radius.b = computeInset(ctx, Axis::HORIZONTAL, ctx.style().borders->radii.b); - res.radius.c = computeInset(ctx, Axis::HORIZONTAL, ctx.style().borders->radii.c); - res.radius.d = computeInset(ctx, Axis::VERTICAL, ctx.style().borders->radii.d); - res.radius.e = computeInset(ctx, Axis::VERTICAL, ctx.style().borders->radii.e); - res.radius.f = computeInset(ctx, Axis::HORIZONTAL, ctx.style().borders->radii.f); - res.radius.g = computeInset(ctx, Axis::HORIZONTAL, ctx.style().borders->radii.g); - res.radius.h = computeInset(ctx, Axis::VERTICAL, ctx.style().borders->radii.h); + res.radii.a = computeInset(ctx, Axis::VERTICAL, ctx.style().borders->radii.a); + res.radii.b = computeInset(ctx, Axis::HORIZONTAL, ctx.style().borders->radii.b); + res.radii.c = computeInset(ctx, Axis::HORIZONTAL, ctx.style().borders->radii.c); + res.radii.d = computeInset(ctx, Axis::VERTICAL, ctx.style().borders->radii.d); + res.radii.e = computeInset(ctx, Axis::VERTICAL, ctx.style().borders->radii.e); + res.radii.f = computeInset(ctx, Axis::HORIZONTAL, ctx.style().borders->radii.f); + res.radii.g = computeInset(ctx, Axis::HORIZONTAL, ctx.style().borders->radii.g); + res.radii.h = computeInset(ctx, Axis::VERTICAL, ctx.style().borders->radii.h); res.borderBox = borderBox; diff --git a/src/web/vaev-paint/borders.h b/src/web/vaev-paint/borders.h index 0ab5788ca2..b310d7b3ed 100644 --- a/src/web/vaev-paint/borders.h +++ b/src/web/vaev-paint/borders.h @@ -1,9 +1,9 @@ #pragma once #include -#include +#include #include -#include +#include #include #include "karm-logger/logger.h" @@ -19,7 +19,7 @@ struct BorderPaint { // https://drafts.csswg.org/css-backgrounds/#borders struct Borders { BorderCollapse collapse; - Math::Radiusf radii; + Math::Radiif radii; BorderPaint top = BorderPaint{ 0, @@ -73,7 +73,7 @@ struct Borders { } } - Math::Radiusf paint(Gfx::Canvas &ctx, Math::Rectf rect) { + Math::Radiif paint(Gfx::Canvas &ctx, Math::Rectf rect) { ctx.begin(); Math::Vec2f const cornerTopStart = {rect.x - start.width, rect.y - top.width}; @@ -182,7 +182,7 @@ struct Borders { return curves; } - Array computeInnerCurves(Math::Vec2f topStart, Math::Rectf content, Math::Radiusf const &radii) { + Array computeInnerCurves(Math::Vec2f topStart, Math::Rectf content, Math::Radiif const &radii) { Array curves = {}; // corner top-end @@ -388,7 +388,7 @@ struct Borders { } } - Math::Radiusf computeInternalRadii(Math::Radiusf radii) { + Math::Radiif computeInternalRadii(Math::Radiif radii) { if (radii.a >= top.width) { radii.a = radii.a - top.width;