api: renamed api for consistency

API modification:
- Shape::fillColor() -> Shape::fill()

issue: https://github.com/thorvg/thorvg/issues/3116
This commit is contained in:
Hermet Park 2025-01-13 16:38:26 +09:00 committed by Hermet Park
parent a31eceeafa
commit f5aa347a70
8 changed files with 9 additions and 9 deletions

View file

@ -48,7 +48,7 @@ struct UserExample : tvgexam::Example
auto shape = (tvg::Shape*) paint; auto shape = (tvg::Shape*) paint;
//override color? //override color?
uint8_t r, g, b; uint8_t r, g, b;
shape->fillColor(&r, &g, &b); shape->fill(&r, &g, &b);
if (r == 255 && g == 180 && b == 0) if (r == 255 && g == 180 && b == 0)
shape->fill(0, 0, 255); shape->fill(0, 0, 255);

View file

@ -1183,7 +1183,7 @@ public:
* @param[out] a The alpha channel value in the range [0 ~ 255], where 0 is completely transparent and 255 is opaque. * @param[out] a The alpha channel value in the range [0 ~ 255], where 0 is completely transparent and 255 is opaque.
* *
*/ */
Result fillColor(uint8_t* r, uint8_t* g, uint8_t* b, uint8_t* a = nullptr) const noexcept; Result fill(uint8_t* r, uint8_t* g, uint8_t* b, uint8_t* a = nullptr) const noexcept;
/** /**
* @brief Gets the fill rule value. * @brief Gets the fill rule value.

View file

@ -510,7 +510,7 @@ TVG_API Tvg_Result tvg_shape_set_fill_color(Tvg_Paint* paint, uint8_t r, uint8_t
TVG_API Tvg_Result tvg_shape_get_fill_color(const Tvg_Paint* paint, uint8_t* r, uint8_t* g, uint8_t* b, uint8_t* a) TVG_API Tvg_Result tvg_shape_get_fill_color(const Tvg_Paint* paint, uint8_t* r, uint8_t* g, uint8_t* b, uint8_t* a)
{ {
if (!paint) return TVG_RESULT_INVALID_ARGUMENT; if (!paint) return TVG_RESULT_INVALID_ARGUMENT;
return (Tvg_Result) reinterpret_cast<const Shape*>(paint)->fillColor(r, g, b, a); return (Tvg_Result) reinterpret_cast<const Shape*>(paint)->fill(r, g, b, a);
} }

View file

@ -224,7 +224,7 @@ RenderData Paint::Impl::update(RenderMethod* renderer, const Matrix& pm, Array<R
if (target->type() == Type::Shape) { if (target->type() == Type::Shape) {
auto shape = static_cast<Shape*>(target); auto shape = static_cast<Shape*>(target);
uint8_t a; uint8_t a;
shape->fillColor(nullptr, nullptr, nullptr, &a); shape->fill(nullptr, nullptr, nullptr, &a);
//no gradient fill & no maskings of the masking target. //no gradient fill & no maskings of the masking target.
if (!shape->fill() && !(PAINT(shape)->maskData)) { if (!shape->fill() && !(PAINT(shape)->maskData)) {
if ((method == MaskMethod::Alpha && a == 255 && PAINT(shape)->opacity == 255) || (method == MaskMethod::InvAlpha && (a == 0 || PAINT(shape)->opacity == 0))) { if ((method == MaskMethod::Alpha && a == 255 && PAINT(shape)->opacity == 255) || (method == MaskMethod::InvAlpha && (a == 0 || PAINT(shape)->opacity == 0))) {

View file

@ -124,7 +124,7 @@ Result Shape::fill(Fill* f) noexcept
} }
Result Shape::fillColor(uint8_t* r, uint8_t* g, uint8_t* b, uint8_t* a) const noexcept Result Shape::fill(uint8_t* r, uint8_t* g, uint8_t* b, uint8_t* a) const noexcept
{ {
SHAPE(this)->rs.fillColor(r, g, b, a); SHAPE(this)->rs.fillColor(r, g, b, a);
return Result::Success; return Result::Success;

View file

@ -88,7 +88,7 @@ struct Shape::Impl : Paint::Impl
auto shape = static_cast<const Shape*>(target); auto shape = static_cast<const Shape*>(target);
if (!shape->fill()) { if (!shape->fill()) {
uint8_t r, g, b, a; uint8_t r, g, b, a;
shape->fillColor(&r, &g, &b, &a); shape->fill(&r, &g, &b, &a);
if (a == 0 || a == 255) { if (a == 0 || a == 255) {
if (method == MaskMethod::Luma || method == MaskMethod::InvLuma) { if (method == MaskMethod::Luma || method == MaskMethod::InvLuma) {
if ((r == 255 && g == 255 && b == 255) || (r == 0 && g == 0 && b == 0)) return false; if ((r == 255 && g == 255 && b == 255) || (r == 0 && g == 0 && b == 0)) return false;

View file

@ -66,7 +66,7 @@ TEST_CASE("Set", "[tvgAccessor]")
if (paint->type() == Type::Shape) { if (paint->type() == Type::Shape) {
auto shape = (tvg::Shape*) paint; auto shape = (tvg::Shape*) paint;
uint8_t r, g, b; uint8_t r, g, b;
shape->fillColor(&r, &g, &b); shape->fill(&r, &g, &b);
if (r == 37 && g == 47 && b == 53) { if (r == 37 && g == 47 && b == 53) {
shape->fill(0, 0, 255); shape->fill(0, 0, 255);
shape->id = Accessor::id("TestAccessor"); shape->id = Accessor::id("TestAccessor");

View file

@ -208,10 +208,10 @@ TEST_CASE("Shape Filling", "[tvgShape]")
//Fill Color //Fill Color
uint8_t r, g, b, a; uint8_t r, g, b, a;
REQUIRE(shape->fill(255, 100, 50, 5) == Result::Success); REQUIRE(shape->fill(255, 100, 50, 5) == Result::Success);
REQUIRE(shape->fillColor(&r, nullptr, &b, nullptr) == Result::Success); REQUIRE(shape->fill(&r, nullptr, &b, nullptr) == Result::Success);
REQUIRE(r == 255); REQUIRE(r == 255);
REQUIRE(b == 50); REQUIRE(b == 50);
REQUIRE(shape->fillColor(&r, &g, &b, &a) == Result::Success); REQUIRE(shape->fill(&r, &g, &b, &a) == Result::Success);
REQUIRE(g == 100); REQUIRE(g == 100);
REQUIRE(a == 5); REQUIRE(a == 5);