OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
filament_mixer Namespace Reference

Namespaces

namespace  detail

Classes

struct  RGB

Functions

void lerp (unsigned char r1, unsigned char g1, unsigned char b1, unsigned char r2, unsigned char g2, unsigned char b2, float t, unsigned char *out_r, unsigned char *out_g, unsigned char *out_b)
RGB lerp (unsigned char r1, unsigned char g1, unsigned char b1, unsigned char r2, unsigned char g2, unsigned char b2, float t)

Class Documentation

◆ filament_mixer::RGB

struct filament_mixer::RGB
Class Members
unsigned char b
unsigned char g
unsigned char r

Function Documentation

◆ lerp() [1/2]

RGB filament_mixer::lerp ( unsigned char r1,
unsigned char g1,
unsigned char b1,
unsigned char r2,
unsigned char g2,
unsigned char b2,
float t )
inline

Convenience overload returning an RGB struct.

811 {
812 RGB result;
813 lerp(r1, g1, b1, r2, g2, b2, t, &result.r, &result.g, &result.b);
814 return result;
815}
unsigned char b
Definition FilamentMixerModel.hpp:753
unsigned char r
Definition FilamentMixerModel.hpp:753
void lerp(unsigned char r1, unsigned char g1, unsigned char b1, unsigned char r2, unsigned char g2, unsigned char b2, float t, unsigned char *out_r, unsigned char *out_g, unsigned char *out_b)
Definition FilamentMixerModel.hpp:766
unsigned char g
Definition FilamentMixerModel.hpp:753
Definition FilamentMixerModel.hpp:752

References filament_mixer::RGB::b, filament_mixer::RGB::g, lerp(), and filament_mixer::RGB::r.

Here is the call graph for this function:

◆ lerp() [2/2]

void filament_mixer::lerp ( unsigned char r1,
unsigned char g1,
unsigned char b1,
unsigned char r2,
unsigned char g2,
unsigned char b2,
float t,
unsigned char * out_r,
unsigned char * out_g,
unsigned char * out_b )
inline

Mix two RGB colors using polynomial pigment mixing.

This performs polynomial pigment-style RGB interpolation.

Parameters
r1,g1,b1First color (0-255)
r2,g2,b2Second color (0-255)
tMixing ratio: 0.0 = all color1, 1.0 = all color2
out_r,out_g,out_bOutput color (0-255)
769 {
770 // Clamp t
771 if (t <= 0.0f) {
772 *out_r = r1; *out_g = g1; *out_b = b1;
773 return;
774 }
775 if (t >= 1.0f) {
776 *out_r = r2; *out_g = g2; *out_b = b2;
777 return;
778 }
779
780 double x[7] = {
781 static_cast<double>(r1), static_cast<double>(g1), static_cast<double>(b1),
782 static_cast<double>(r2), static_cast<double>(g2), static_cast<double>(b2),
783 static_cast<double>(t)
784 };
785
786 double features[330];
788
789 // Dot product: features @ COEF + INTERCEPT
790 for (int c = 0; c < 3; ++c) {
791 double sum = detail::INTERCEPT[c];
792 for (int i = 0; i < detail::N_FEATURES; ++i) {
793 sum += features[i] * detail::COEF[i][c];
794 }
795 // Clamp to [0, 255] and truncate (matches numpy astype(int) behavior)
796 int val = static_cast<int>(sum);
797 if (val < 0) val = 0;
798 if (val > 255) val = 255;
799
800 if (c == 0) *out_r = static_cast<unsigned char>(val);
801 else if (c == 1) *out_g = static_cast<unsigned char>(val);
802 else *out_b = static_cast<unsigned char>(val);
803 }
804}
void compute_poly_features(const double x[7], double out[330])
Definition FilamentMixerModel.hpp:732
static const double INTERCEPT[3]
Definition FilamentMixerModel.hpp:725
static const double COEF[330][3]
Definition FilamentMixerModel.hpp:392
static const int N_FEATURES
Definition FilamentMixerModel.hpp:56

References filament_mixer::detail::COEF, filament_mixer::detail::compute_poly_features(), filament_mixer::detail::INTERCEPT, and filament_mixer::detail::N_FEATURES.

Referenced by Slic3r::filament_mixer_lerp(), and lerp().

Here is the call graph for this function:
Here is the caller graph for this function: