Skip to content

Commit

Permalink
vaev-paint+layout: Updated usage of Radius/Radiis, Paint/fill, and To…
Browse files Browse the repository at this point in the history
…Float/Cast
  • Loading branch information
Louciole authored and sleepy-monax committed Aug 5, 2024
1 parent 98578bf commit b58b61c
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 27 deletions.
16 changes: 8 additions & 8 deletions src/libs/karm-math/path.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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});

Expand Down
10 changes: 5 additions & 5 deletions src/web/vaev-layout/frag.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,21 +66,21 @@ struct Frag {
// FIXME colorContext should be context dependant

box.borders = Paint::Borders();
box.borders.radii = _box.radius.cast<f64>();
box.borders.radii = _box.radii.cast<f64>();

box.borders.top.width = _box.borders.top.toFloat<f64>();
box.borders.top.width = _box.borders.top.cast<f64>();
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<f64>();
box.borders.bottom.width = _box.borders.bottom.cast<f64>();
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<f64>();
box.borders.start.width = _box.borders.start.cast<f64>();
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<f64>();
box.borders.end.width = _box.borders.end.cast<f64>();
box.borders.end.style = style().borders->end.style;
box.borders.end.fill = colorContext.resolve(style().borders->end.color);

Expand Down
16 changes: 8 additions & 8 deletions src/web/vaev-layout/sizing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
12 changes: 6 additions & 6 deletions src/web/vaev-paint/borders.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#pragma once

#include <karm-gfx/context.h>
#include <karm-gfx/paint.h>
#include <karm-gfx/fill.h>
#include <karm-math/curve.h>
#include <karm-math/radius.h>
#include <karm-math/radii.h>
#include <vaev-base/borders.h>

#include "karm-logger/logger.h"
Expand All @@ -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,
Expand Down Expand Up @@ -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};
Expand Down Expand Up @@ -182,7 +182,7 @@ struct Borders {
return curves;
}

Array<Math::Curvef, 8> computeInnerCurves(Math::Vec2f topStart, Math::Rectf content, Math::Radiusf const &radii) {
Array<Math::Curvef, 8> computeInnerCurves(Math::Vec2f topStart, Math::Rectf content, Math::Radiif const &radii) {
Array<Math::Curvef, 8> curves = {};

// corner top-end
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit b58b61c

Please sign in to comment.