mirror of
https://github.com/thorvg/thorvg.git
synced 2025-07-23 06:38:43 +00:00
api: renamed api for consistency
API modification: - Shape::fillColor() -> Shape::fill() issue: https://github.com/thorvg/thorvg/issues/3116
This commit is contained in:
parent
a31eceeafa
commit
f5aa347a70
8 changed files with 9 additions and 9 deletions
|
@ -48,7 +48,7 @@ struct UserExample : tvgexam::Example
|
|||
auto shape = (tvg::Shape*) paint;
|
||||
//override color?
|
||||
uint8_t r, g, b;
|
||||
shape->fillColor(&r, &g, &b);
|
||||
shape->fill(&r, &g, &b);
|
||||
if (r == 255 && g == 180 && b == 0)
|
||||
shape->fill(0, 0, 255);
|
||||
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
*/
|
||||
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.
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -224,7 +224,7 @@ RenderData Paint::Impl::update(RenderMethod* renderer, const Matrix& pm, Array<R
|
|||
if (target->type() == Type::Shape) {
|
||||
auto shape = static_cast<Shape*>(target);
|
||||
uint8_t a;
|
||||
shape->fillColor(nullptr, nullptr, nullptr, &a);
|
||||
shape->fill(nullptr, nullptr, nullptr, &a);
|
||||
//no gradient fill & no maskings of the masking target.
|
||||
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))) {
|
||||
|
|
|
@ -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);
|
||||
return Result::Success;
|
||||
|
|
|
@ -88,7 +88,7 @@ struct Shape::Impl : Paint::Impl
|
|||
auto shape = static_cast<const Shape*>(target);
|
||||
if (!shape->fill()) {
|
||||
uint8_t r, g, b, a;
|
||||
shape->fillColor(&r, &g, &b, &a);
|
||||
shape->fill(&r, &g, &b, &a);
|
||||
if (a == 0 || a == 255) {
|
||||
if (method == MaskMethod::Luma || method == MaskMethod::InvLuma) {
|
||||
if ((r == 255 && g == 255 && b == 255) || (r == 0 && g == 0 && b == 0)) return false;
|
||||
|
|
|
@ -66,7 +66,7 @@ TEST_CASE("Set", "[tvgAccessor]")
|
|||
if (paint->type() == Type::Shape) {
|
||||
auto shape = (tvg::Shape*) paint;
|
||||
uint8_t r, g, b;
|
||||
shape->fillColor(&r, &g, &b);
|
||||
shape->fill(&r, &g, &b);
|
||||
if (r == 37 && g == 47 && b == 53) {
|
||||
shape->fill(0, 0, 255);
|
||||
shape->id = Accessor::id("TestAccessor");
|
||||
|
|
|
@ -208,10 +208,10 @@ TEST_CASE("Shape Filling", "[tvgShape]")
|
|||
//Fill Color
|
||||
uint8_t r, g, b, a;
|
||||
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(b == 50);
|
||||
REQUIRE(shape->fillColor(&r, &g, &b, &a) == Result::Success);
|
||||
REQUIRE(shape->fill(&r, &g, &b, &a) == Result::Success);
|
||||
REQUIRE(g == 100);
|
||||
REQUIRE(a == 5);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue