190 {
193 float dx = x1 - x0;
194 float dy = y1 - y0;
196 float invSteps = 1.0f / (float)
steps;
197
198 for (
int i = 0; i <=
steps; i++) {
199 float u = i * invSteps;
200 float px = x0 + dx * u;
201 float py = y0 + dy * u;
203
206 float fx = px - ix;
207 float fy = py - iy;
208
209 float weights[4] = {
210 (1.0f - fx) * (1.0f - fy),
211 fx * (1.0f - fy),
212 (1.0f - fx) * fy,
213 fx * fy,
214 };
215 int offX[4] = {0, 1, 0, 1};
216 int offY[4] = {0, 0, 1, 1};
217
218 for (int j = 0; j < 4; j++) {
219 int cx = ix + offX[j];
220 int cy = iy + offY[j];
221 if (cx < 0 || cx >= w || cy < 0 || cy >= h)
222 continue;
223 float wt = weights[j];
224 if (wt <= 0.0f)
225 continue;
226 int gi =
idx(cy, cx);
227 float inv = 1.0f - wt;
228 mR[gi] =
mR[gi] * inv + c.r * wt;
229 mG[gi] =
mG[gi] * inv + c.g * wt;
230 mB[gi] =
mB[gi] * inv + c.b * wt;
231 }
232 }
233}
fl::UISlider colorShift("Color Shift", 0.04f, 0.0f, 0.5f, 0.01f)
int idx(int y, int x) const
fl::UISlider steps("Steps", 100.0f, 1.0f, 200.0f, 1.0f)
constexpr common_type_t< T, U > max(T a, U b) FL_NOEXCEPT
float floorf(float value) FL_NOEXCEPT
float fabsf(float value) FL_NOEXCEPT