Skip to content

Commit

Permalink
added opacity() and has_alpha to pixel
Browse files Browse the repository at this point in the history
  • Loading branch information
codewitch-honey-crisis committed Jun 22, 2024
1 parent 22c1e5e commit 9010804
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions include/gfx_pixel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ namespace gfx {
constexpr static const size_t bit_depth = helpers::bit_depth<ChannelTraits...>::value;
// the bit depth of the color channels in the pixel
constexpr static const size_t color_bit_depth = helpers::color_bit_depth<ChannelTraits...>::value;

constexpr static const bool has_alpha = helpers::has_channel_names_impl<type,channel_name::A>::value;
// the minimum number of bytes needed to store the pixel
constexpr static const size_t packed_size = (bit_depth+7) / 8;
// true if the pixel is a whole number of bytes
Expand Down Expand Up @@ -688,7 +688,9 @@ namespace gfx {
blend(rhs,ratio,&result);
return result;
}

constexpr auto opacity() const {
return helpers::pixel_get_alpha<type,has_alpha>::valuer(*this);
}
static_assert(sizeof...(ChannelTraits)>0,"A pixel must have at least one channel trait");
static_assert(bit_depth<=HTCW_MAX_WORD,"Bit depth must be less than or equal to the maximum machine word size");
};
Expand Down
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "htcw_gfx",
"version": "1.674",
"version": "1.675",
"description": "A device independent graphics library for embedded and IoT devices",
"keywords": ["tft", "lcd","e-paper","e-ink", "graphics", "spi", "parallel", "i2c", "drawing", "jpg", "ttf","vlw", "font", "svg","2d", "vector"],
"authors": {
Expand Down

0 comments on commit 9010804

Please sign in to comment.