Skip to content

Commit

Permalink
♻️consistent literal formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
lamarrr committed Nov 28, 2024
1 parent b99650b commit bca1b04
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 36 deletions.
40 changes: 20 additions & 20 deletions ashura/engine/canvas.cc
Original file line number Diff line number Diff line change
Expand Up @@ -76,20 +76,20 @@ void path::rrect(Vec<Vec2> &vtx, Vec4 radii, u32 segments)
}

radii = radii * 2;
radii.x = min(radii.x, 2.0f);
radii.y = min(radii.y, 2.0f);
radii.z = min(radii.z, 2.0f);
radii.w = min(radii.w, 2.0f);
radii.x = min(radii.x, 2.0F);
radii.y = min(radii.y, 2.0F);
radii.z = min(radii.z, 2.0F);
radii.w = min(radii.w, 2.0F);

/// clipping
radii.y = min(radii.y, 2.0f - radii.x);
f32 max_radius_z = min(2.0f - radii.x, 1.0f - radii.y);
radii.y = min(radii.y, 2.0F - radii.x);
f32 max_radius_z = min(2.0F - radii.x, 1.0F - radii.y);
radii.z = min(radii.z, max_radius_z);
f32 max_radius_w = min(max_radius_z, 1.0f - radii.z);
f32 max_radius_w = min(max_radius_z, 1.0F - radii.z);
radii.w = min(radii.w, max_radius_w);

u32 const curve_segments = (segments - 8) / 4;
f32 const step = (curve_segments == 0) ? 0.0f : ((PI / 2) / curve_segments);
f32 const step = (curve_segments == 0) ? 0.0F : ((PI / 2) / curve_segments);
u32 const first = vtx.size32();

vtx.extend_uninit(segments).unwrap();
Expand Down Expand Up @@ -129,24 +129,24 @@ void path::rrect(Vec<Vec2> &vtx, Vec4 radii, u32 segments)
for (u32 s = 0; s < curve_segments; s++)
{
vtx[first + i++] = Vec2{1 - radii.y, (-1 + radii.y)} +
radii.y * rotor(PI * 3.0f / 2.0f + s * step);
radii.y * rotor(PI * 3.0F / 2.0F + s * step);
}

vtx[first + i++] = Vec2{1, -1 + radii.y};
}

void path::brect(Vec<Vec2> &vtx, Vec4 slant)
{
slant = slant * 2.0f;
slant.x = min(slant.x, 2.0f);
slant.y = min(slant.y, 2.0f);
slant.z = min(slant.z, 2.0f);
slant.w = min(slant.w, 2.0f);
slant = slant * 2.0F;
slant.x = min(slant.x, 2.0F);
slant.y = min(slant.y, 2.0F);
slant.z = min(slant.z, 2.0F);
slant.w = min(slant.w, 2.0F);

slant.y = min(slant.y, 2.0f - slant.x);
f32 max_radius_z = min(2.0f - slant.x, 2.0f - slant.y);
slant.y = min(slant.y, 2.0F - slant.x);
f32 max_radius_z = min(2.0F - slant.x, 2.0F - slant.y);
slant.z = min(slant.z, max_radius_z);
f32 max_radius_w = min(max_radius_z, 2.0f - slant.z);
f32 max_radius_w = min(max_radius_z, 2.0F - slant.z);
slant.w = min(slant.w, max_radius_w);

Vec2 const vertices[] = {{-1 + slant.x, -1}, {1 - slant.y, -1},
Expand All @@ -168,7 +168,7 @@ void path::bezier(Vec<Vec2> &vtx, Vec2 cp0, Vec2 cp1, Vec2 cp2, u32 segments)

vtx.extend_uninit(segments).unwrap();

f32 const step = 1.0f / (segments - 1);
f32 const step = 1.0F / (segments - 1);

for (u32 i = 0; i < segments; i++)
{
Expand All @@ -189,7 +189,7 @@ void path::cubic_bezier(Vec<Vec2> &vtx, Vec2 cp0, Vec2 cp1, Vec2 cp2, Vec2 cp3,

vtx.extend_uninit(segments).unwrap();

f32 const step = 1.0f / (segments - 1);
f32 const step = 1.0F / (segments - 1);

for (u32 i = 0; i < segments; i++)
{
Expand All @@ -211,7 +211,7 @@ void path::catmull_rom(Vec<Vec2> &vtx, Vec2 cp0, Vec2 cp1, Vec2 cp2, Vec2 cp3,

vtx.extend_uninit(segments).unwrap();

f32 const step = 1.0f / (segments - 1);
f32 const step = 1.0F / (segments - 1);

for (u32 i = 0; i < segments; i++)
{
Expand Down
4 changes: 2 additions & 2 deletions ashura/engine/canvas.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ struct ShapeInfo

Vec4 corner_radii = {0, 0, 0, 0};

f32 stroke = 0.0f;
f32 stroke = 0.0F;

f32 thickness = 1.0f;
f32 thickness = 1.0F;

ColorGradient tint = {};

Expand Down
2 changes: 1 addition & 1 deletion ashura/engine/text.cc
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ static inline void insert_run(TextLayout &l, FontStyle const &s, u32 first,
.num_codepoints = count,
.style = style,
.font_height = s.font_height,
.line_height = max(s.line_height, 1.0f),
.line_height = max(s.line_height, 1.0F),
.first_glyph = first_glyph,
.num_glyphs = num_glyphs,
.metrics = TextRunMetrics{.advance = advance,
Expand Down
2 changes: 1 addition & 1 deletion ashura/engine/text.h
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ struct FontStyle
{
Font *font = nullptr;
f32 font_height = 20;
f32 line_height = 1.2f;
f32 line_height = 1.2F;
};

/// @param shadow_scale relative. multiplied by font_height
Expand Down
4 changes: 2 additions & 2 deletions ashura/engine/views.h
Original file line number Diff line number Diff line change
Expand Up @@ -1325,7 +1325,7 @@ struct CheckBox : View
.stroke = 0,
.thickness = styling.tick_thickness,
.tint = styling.tick_color},
span<Vec2>({{0.125f, 0.5f}, {0.374f, 0.75f}, {0.775f, 0.25f}}));
span<Vec2>({{0.125F, 0.5F}, {0.374F, 0.75F}, {0.775F, 0.25F}}));
}

if (state.press.focus.focused)
Expand Down Expand Up @@ -2347,7 +2347,7 @@ struct ScrollBar : View
state.t =
clamp((ctx.mouse.position[main_axis] - region.extent[main_axis] / 2) /
region.extent[main_axis],
0.0f, 1.0f);
0.0F, 1.0F);
cb.scrolled(state.t);
}

Expand Down
14 changes: 7 additions & 7 deletions ashura/std/tests/option.cc
Original file line number Diff line number Diff line change
Expand Up @@ -436,22 +436,22 @@ TEST(OptionLifetimeTest, MapOrElse)
TEST(OptionTest, AndThen)
{
auto &&a = Option(Some(90)).and_then(
[](int &x) { return Option(Some(static_cast<float>(x) + 90.0f)); });
[](int &x) { return Option(Some(static_cast<float>(x) + 90.0F)); });

EXPECT_FLOAT_EQ(std::move(a).unwrap(), 180.0f);
EXPECT_FLOAT_EQ(std::move(a).unwrap(), 180.0F);

auto &&b = make_none<int>().and_then(
[](int &x) { return Option(Some(static_cast<float>(x) + 90.0f)); });
[](int &x) { return Option(Some(static_cast<float>(x) + 90.0F)); });
EXPECT_EQ(b, None);
}

TEST(OptionTest, OrElse)
{
auto &&a = Option(Some(90.0f)).or_else([]() { return Option(Some(0.5f)); });
EXPECT_FLOAT_EQ(std::move(a).unwrap(), 90.0f);
auto &&a = Option(Some(90.0F)).or_else([]() { return Option(Some(0.5F)); });
EXPECT_FLOAT_EQ(std::move(a).unwrap(), 90.0F);

auto &&b = Option<float>(None).or_else([]() { return Option(Some(0.5f)); });
EXPECT_FLOAT_EQ(std::move(b).unwrap(), 0.5f);
auto &&b = Option<float>(None).or_else([]() { return Option(Some(0.5F)); });
EXPECT_FLOAT_EQ(std::move(b).unwrap(), 0.5F);

auto &&c = Option<float>(None).or_else([]() { return Option<float>(None); });
EXPECT_EQ(c, None);
Expand Down
6 changes: 3 additions & 3 deletions ashura/std/tests/result.cc
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ TEST(ResultTest, MapOrElse)

TEST(ResultTest, AndThen)
{
auto a = [](int v) -> Result<float, int> { return Ok{v * 2.0f}; };
EXPECT_FLOAT_EQ((make_ok<int, int>(20).and_then(a).unwrap()), 40.0f);
auto a = [](int v) -> Result<float, int> { return Ok{v * 2.0F}; };
EXPECT_FLOAT_EQ((make_ok<int, int>(20).and_then(a).unwrap()), 40.0F);

EXPECT_TRUE((make_err<int, int>(-20).and_then(a).is_err()));

Expand All @@ -179,7 +179,7 @@ TEST(ResultTest, AndThen)
return Ok{res};
};

EXPECT_EQ((make_ok<int, int>(80).and_then(b).unwrap()), (std::vector{80.0f}));
EXPECT_EQ((make_ok<int, int>(80).and_then(b).unwrap()), (std::vector{80.0F}));

EXPECT_TRUE((make_err<int, int>(-20).and_then(b).is_err()));
EXPECT_EQ((make_err<int, int>(-20).and_then(b).unwrap_err()), -20);
Expand Down

0 comments on commit bca1b04

Please sign in to comment.