mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-05 11:01:49 +00:00
add canvas:sub method
This commit is contained in:
parent
83f7bf80c4
commit
34d13442b6
5 changed files with 25 additions and 8 deletions
|
|
@ -448,7 +448,7 @@ void ImageData::mulColor(const glm::ivec4& color) {
|
|||
}
|
||||
}
|
||||
|
||||
void ImageData::addColor(const ImageData& other) {
|
||||
void ImageData::addColor(const ImageData& other, int multiplier) {
|
||||
check_matching(*this, other);
|
||||
|
||||
uint comps;
|
||||
|
|
@ -462,7 +462,7 @@ void ImageData::addColor(const ImageData& other) {
|
|||
for (uint x = 0; x < width; x++) {
|
||||
uint idx = (y * width + x) * comps;
|
||||
for (uint c = 0; c < comps; c++) {
|
||||
int val = data[idx + c] + other.data[idx + c];
|
||||
int val = data[idx + c] + other.data[idx + c] * multiplier;
|
||||
data[idx + c] =
|
||||
static_cast<ubyte>(std::min(std::max(val, 0), 255));
|
||||
}
|
||||
|
|
@ -470,7 +470,7 @@ void ImageData::addColor(const ImageData& other) {
|
|||
}
|
||||
}
|
||||
|
||||
void ImageData::addColor(const glm::ivec4& color) {
|
||||
void ImageData::addColor(const glm::ivec4& color, int multiplier) {
|
||||
uint comps;
|
||||
switch (format) {
|
||||
case ImageFormat::rgb888: comps = 3; break;
|
||||
|
|
@ -482,7 +482,7 @@ void ImageData::addColor(const glm::ivec4& color) {
|
|||
for (uint x = 0; x < width; x++) {
|
||||
uint idx = (y * width + x) * comps;
|
||||
for (uint c = 0; c < comps; c++) {
|
||||
int val = data[idx + c] + color[c];
|
||||
int val = data[idx + c] + color[c] * multiplier;
|
||||
data[idx + c] =
|
||||
static_cast<ubyte>(std::min(std::max(val, 0), 255));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue