OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::ColorRGBA Class Reference

#include </home/runner/work/OrcaSlicer/OrcaSlicer/src/libslic3r/Color.hpp>

Collaboration diagram for Slic3r::ColorRGBA:

Public Member Functions

 ColorRGBA ()=default
 ColorRGBA (float r, float g, float b, float a)
 ColorRGBA (unsigned char r, unsigned char g, unsigned char b, unsigned char a)
 ColorRGBA (const ColorRGBA &other)=default
ColorRGBA & operator= (const ColorRGBA &other)
bool operator== (const ColorRGBA &other) const
bool operator!= (const ColorRGBA &other) const
bool operator< (const ColorRGBA &other) const
bool operator> (const ColorRGBA &other) const
float operator[] (int i) const
float & operator[] (int i)
ColorRGBA operator+ (const ColorRGBA &other) const
ColorRGBA operator* (float value) const
const float *const data () const
float r () const
float g () const
float b () const
float a () const
void r (float r)
void g (float g)
void b (float b)
void a (float a)
void set (unsigned int comp, float value)
unsigned char r_uchar () const
unsigned char g_uchar () const
unsigned char b_uchar () const
unsigned char a_uchar () const
bool is_transparent () const

Static Public Member Functions

static const ColorRGBA BLACK ()
static const ColorRGBA BLUE ()
static const ColorRGBA BLUEISH ()
static const ColorRGBA CYAN ()
static const ColorRGBA DARK_GRAY ()
static const ColorRGBA DARK_YELLOW ()
static const ColorRGBA GRAY ()
static const ColorRGBA GREEN ()
static const ColorRGBA GREENISH ()
static const ColorRGBA LIGHT_GRAY ()
static const ColorRGBA MAGENTA ()
static const ColorRGBA ORANGE ()
static const ColorRGBA RED ()
static const ColorRGBA REDISH ()
static const ColorRGBA YELLOW ()
static const ColorRGBA WHITE ()
static const ColorRGBA ORCA ()
static const ColorRGBA X ()
static const ColorRGBA Y ()
static const ColorRGBA Z ()

Private Attributes

std::array< float, 4 > m_data { 1.0f, 1.0f, 1.0f, 1.0f }

Detailed Description

Constructor & Destructor Documentation

◆ ColorRGBA() [1/4]

Slic3r::ColorRGBA::ColorRGBA ( )
default

References a(), b(), g(), and r().

Referenced by ColorRGBA(), BLACK(), BLUE(), BLUEISH(), CYAN(), DARK_GRAY(), DARK_YELLOW(), GRAY(), GREEN(), GREENISH(), LIGHT_GRAY(), MAGENTA(), operator!=(), operator*(), operator+(), operator<(), operator=(), operator==(), operator>(), ORANGE(), ORCA(), RED(), REDISH(), WHITE(), X(), Y(), YELLOW(), and Z().

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

◆ ColorRGBA() [2/4]

Slic3r::ColorRGBA::ColorRGBA ( float r,
float g,
float b,
float a )
188: m_data({ std::clamp(r, 0.0f, 1.0f), std::clamp(g, 0.0f, 1.0f), std::clamp(b, 0.0f, 1.0f), std::clamp(a, 0.0f, 1.0f) })
189{
190}
float a() const
Definition Color.hpp:108
float b() const
Definition Color.hpp:107
float r() const
Definition Color.hpp:105
float g() const
Definition Color.hpp:106
std::array< float, 4 > m_data
Definition Color.hpp:81

References a(), b(), g(), m_data, and r().

Here is the call graph for this function:

◆ ColorRGBA() [3/4]

Slic3r::ColorRGBA::ColorRGBA ( unsigned char r,
unsigned char g,
unsigned char b,
unsigned char a )
193: m_data({ std::clamp(r * INV_255, 0.0f, 1.0f), std::clamp(g * INV_255, 0.0f, 1.0f), std::clamp(b * INV_255, 0.0f, 1.0f), std::clamp(a * INV_255, 0.0f, 1.0f) })
194{
195}
static const float INV_255
Definition Color.cpp:14

References a(), b(), g(), INV_255, m_data, and r().

Here is the call graph for this function:

◆ ColorRGBA() [4/4]

Slic3r::ColorRGBA::ColorRGBA ( const ColorRGBA & other)
default

References ColorRGBA().

Here is the call graph for this function:

Member Function Documentation

◆ a() [1/2]

float Slic3r::ColorRGBA::a ( ) const
inline

◆ a() [2/2]

void Slic3r::ColorRGBA::a ( float a)
inline
113{ m_data[3] = std::clamp(a, 0.0f, 1.0f); }

References a(), and m_data.

Here is the call graph for this function:

◆ a_uchar()

unsigned char Slic3r::ColorRGBA::a_uchar ( ) const
inline
123{ return static_cast<unsigned char>(m_data[3] * 255.0f); }

References m_data.

◆ b() [1/2]

◆ b() [2/2]

void Slic3r::ColorRGBA::b ( float b)
inline
112{ m_data[2] = std::clamp(b, 0.0f, 1.0f); }

References b(), and m_data.

Here is the call graph for this function:

◆ b_uchar()

unsigned char Slic3r::ColorRGBA::b_uchar ( ) const
inline
122{ return static_cast<unsigned char>(m_data[2] * 255.0f); }

References m_data.

Referenced by Slic3r::GUI::GLCanvas3D::_render_paint_toolbar(), and Slic3r::GUI::DesignPanel::on_set_body_color().

Here is the caller graph for this function:

◆ BLACK()

const ColorRGBA Slic3r::ColorRGBA::BLACK ( )
inlinestatic
127{ return { 0.0f, 0.0f, 0.0f, 1.0f }; }

References ColorRGBA().

Referenced by Slic3r::decode_color(), Slic3r::GUI::decode_color_to_float_array(), Slic3r::decode_colors(), and Slic3r::GUI::GLCanvas3D::LayersEditing::render_profile().

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

◆ BLUE()

const ColorRGBA Slic3r::ColorRGBA::BLUE ( )
inlinestatic
128{ return { 0.0f, 0.0f, 1.0f, 1.0f }; }

References ColorRGBA().

Referenced by Slic3r::GUI::GLGizmoMeasure::render_dimensioning(), and Slic3r::GUI::GLCanvas3D::LayersEditing::render_profile().

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

◆ BLUEISH()

const ColorRGBA Slic3r::ColorRGBA::BLUEISH ( )
inlinestatic
129{ return { 0.5f, 0.5f, 1.0f, 1.0f }; }

References ColorRGBA().

Here is the call graph for this function:

◆ CYAN()

const ColorRGBA Slic3r::ColorRGBA::CYAN ( )
inlinestatic
130{ return { 0.0f, 1.0f, 1.0f, 1.0f }; }

References ColorRGBA().

Here is the call graph for this function:

◆ DARK_GRAY()

const ColorRGBA Slic3r::ColorRGBA::DARK_GRAY ( )
inlinestatic
131{ return { 0.25f, 0.25f, 0.25f, 1.0f }; }

References ColorRGBA().

Here is the call graph for this function:

◆ DARK_YELLOW()

const ColorRGBA Slic3r::ColorRGBA::DARK_YELLOW ( )
inlinestatic
132{ return { 0.5f, 0.5f, 0.0f, 1.0f }; }

References ColorRGBA().

Here is the call graph for this function:

◆ data()

const float *const Slic3r::ColorRGBA::data ( ) const
inline
103{ return m_data.data(); }

References m_data.

Referenced by Slic3r::GLShaderProgram::set_uniform().

Here is the caller graph for this function:

◆ g() [1/2]

◆ g() [2/2]

void Slic3r::ColorRGBA::g ( float g)
inline
111{ m_data[1] = std::clamp(g, 0.0f, 1.0f); }

References g(), and m_data.

Here is the call graph for this function:

◆ g_uchar()

unsigned char Slic3r::ColorRGBA::g_uchar ( ) const
inline
121{ return static_cast<unsigned char>(m_data[1] * 255.0f); }

References m_data.

Referenced by Slic3r::GUI::GLCanvas3D::_render_paint_toolbar(), and Slic3r::GUI::DesignPanel::on_set_body_color().

Here is the caller graph for this function:

◆ GRAY()

const ColorRGBA Slic3r::ColorRGBA::GRAY ( )
inlinestatic
133{ return { 0.5f, 0.5f, 0.5f, 1.0f }; }

References ColorRGBA().

Referenced by Slic3r::GUI::GLGizmoCut3D::render_cut_plane_grabbers().

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

◆ GREEN()

const ColorRGBA Slic3r::ColorRGBA::GREEN ( )
inlinestatic
134{ return { 0.0f, 1.0f, 0.0f, 1.0f }; }

References ColorRGBA().

Referenced by Slic3r::GUI::GLGizmoMeasure::render_dimensioning().

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

◆ GREENISH()

const ColorRGBA Slic3r::ColorRGBA::GREENISH ( )
inlinestatic
135{ return { 0.5f, 1.0f, 0.5f, 1.0f }; }

References ColorRGBA().

Here is the call graph for this function:

◆ is_transparent()

bool Slic3r::ColorRGBA::is_transparent ( ) const
inline
125{ return m_data[3] < 1.0f; }

References m_data.

Referenced by Slic3r::GUI::GLCanvas3D::_render_wireframe_overlay(), Slic3r::GUI::add_swatch(), Slic3r::GUI::Selection::clear(), and Slic3r::volumes_to_render().

Here is the caller graph for this function:

◆ LIGHT_GRAY()

const ColorRGBA Slic3r::ColorRGBA::LIGHT_GRAY ( )
inlinestatic
136{ return { 0.75f, 0.75f, 0.75f, 1.0f }; }

References ColorRGBA().

Referenced by Slic3r::GUI::GLGizmoMeasure::render_dimensioning().

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

◆ MAGENTA()

const ColorRGBA Slic3r::ColorRGBA::MAGENTA ( )
inlinestatic
137{ return { 1.0f, 0.0f, 1.0f, 1.0f }; }

References ColorRGBA().

Here is the call graph for this function:

◆ operator!=()

bool Slic3r::ColorRGBA::operator!= ( const ColorRGBA & other) const
inline
94{ return !operator==(other); }
bool operator==(const ColorRGBA &other) const
Definition Color.hpp:91

References ColorRGBA(), and operator==().

Here is the call graph for this function:

◆ operator*()

ColorRGBA Slic3r::ColorRGBA::operator* ( float value) const
231{
232 assert(value >= 0.0f);
233 ColorRGBA ret;
234 for (size_t i = 0; i < 3; ++i) {
235 ret.m_data[i] = std::clamp(value * m_data[i], 0.0f, 1.0f);
236 }
237 ret.m_data[3] = this->m_data[3];
238 return ret;
239}
ColorRGBA()=default

References ColorRGBA(), and m_data.

Here is the call graph for this function:

◆ operator+()

ColorRGBA Slic3r::ColorRGBA::operator+ ( const ColorRGBA & other) const
222{
223 ColorRGBA ret;
224 for (size_t i = 0; i < 3; ++i) {
225 ret.m_data[i] = std::clamp(m_data[i] + other.m_data[i], 0.0f, 1.0f);
226 }
227 return ret;
228}

References ColorRGBA(), and m_data.

Here is the call graph for this function:

◆ operator<()

bool Slic3r::ColorRGBA::operator< ( const ColorRGBA & other) const
198{
199 for (size_t i = 0; i < 3; ++i) {
200 if (m_data[i] < other.m_data[i])
201 return true;
202 else if (m_data[i] > other.m_data[i])
203 return false;
204 }
205
206 return false;
207}

References ColorRGBA(), and m_data.

Here is the call graph for this function:

◆ operator=()

ColorRGBA & Slic3r::ColorRGBA::operator= ( const ColorRGBA & other)
inline
89{ m_data = other.m_data; return *this; }

References ColorRGBA(), and m_data.

Here is the call graph for this function:

◆ operator==()

bool Slic3r::ColorRGBA::operator== ( const ColorRGBA & other) const
inline
91 {
92 return color_is_equal(m_data, other.m_data);
93 }
bool color_is_equal(const RGBA a, const RGBA &b)
Definition Color.cpp:17

References ColorRGBA(), Slic3r::color_is_equal(), and m_data.

Referenced by operator!=().

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

◆ operator>()

bool Slic3r::ColorRGBA::operator> ( const ColorRGBA & other) const
210{
211 for (size_t i = 0; i < 3; ++i) {
212 if (m_data[i] > other.m_data[i])
213 return true;
214 else if (m_data[i] < other.m_data[i])
215 return false;
216 }
217
218 return false;
219}

References ColorRGBA(), and m_data.

Here is the call graph for this function:

◆ operator[]() [1/2]

float & Slic3r::ColorRGBA::operator[] ( int i)
inline
98{ return m_data[i]; }

References m_data.

◆ operator[]() [2/2]

float Slic3r::ColorRGBA::operator[] ( int i) const
inline
97{ return m_data[i]; }

References m_data.

◆ ORANGE()

const ColorRGBA Slic3r::ColorRGBA::ORANGE ( )
inlinestatic
138{ return { 0.923f, 0.504f, 0.264f, 1.0f }; }

References ColorRGBA().

Referenced by Slic3r::GUI::GLGizmoTextureDisplacement::render_adjust_texture_gizmo().

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

◆ ORCA()

const ColorRGBA Slic3r::ColorRGBA::ORCA ( )
inlinestatic
143{ return {0.0f, 150.f / 255.0f, 136.0f / 255, 1.0f}; }

References ColorRGBA().

Referenced by Slic3r::GUI::GLSelectionRectangle::render().

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

◆ r() [1/2]

◆ r() [2/2]

void Slic3r::ColorRGBA::r ( float r)
inline
110{ m_data[0] = std::clamp(r, 0.0f, 1.0f); }

References m_data, and r().

Here is the call graph for this function:

◆ r_uchar()

unsigned char Slic3r::ColorRGBA::r_uchar ( ) const
inline
120{ return static_cast<unsigned char>(m_data[0] * 255.0f); }

References m_data.

Referenced by Slic3r::GUI::GLCanvas3D::_render_paint_toolbar(), and Slic3r::GUI::DesignPanel::on_set_body_color().

Here is the caller graph for this function:

◆ RED()

const ColorRGBA Slic3r::ColorRGBA::RED ( )
inlinestatic
139{ return { 1.0f, 0.0f, 0.0f, 1.0f }; }

References ColorRGBA().

Referenced by Slic3r::GUI::GLGizmoMeasure::render_dimensioning().

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

◆ REDISH()

const ColorRGBA Slic3r::ColorRGBA::REDISH ( )
inlinestatic
140{ return { 1.0f, 0.5f, 0.5f, 1.0f }; }

References ColorRGBA().

Here is the call graph for this function:

◆ set()

void Slic3r::ColorRGBA::set ( unsigned int comp,
float value )
inline
115 {
116 assert(0 <= comp && comp <= 3);
117 m_data[comp] = std::clamp(value, 0.0f, 1.0f);
118 }

References m_data.

Referenced by Slic3r::decode_color().

Here is the caller graph for this function:

◆ WHITE()

const ColorRGBA Slic3r::ColorRGBA::WHITE ( )
inlinestatic
142{ return { 1.0f, 1.0f, 1.0f, 1.0f }; }

References ColorRGBA().

Referenced by Slic3r::GUI::init_from_circle(), Slic3r::GUI::init_from_scale(), Slic3r::GUI::init_from_snap_radii(), Slic3r::GUI::GLGizmoCut3D::init_rendering_items(), Slic3r::GUI::GLGizmoSimplify::on_render(), Slic3r::GUI::UVEditorCanvas::render(), Slic3r::GUI::GLGizmoMeasure::render_dimensioning(), Slic3r::GUI::GCodeViewer::SequentialView::Marker::render_position_window(), Slic3r::GLVolume::SinkingContours::update(), and Slic3r::GUI::TriangleSelectorGUI::update_paint_contour().

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

◆ X()

const ColorRGBA Slic3r::ColorRGBA::X ( )
inlinestatic
145{ return { ColorRGB::X().r(), ColorRGB::X().g(), ColorRGB::X().b(), 1.f };}
static const ColorRGB X()
Definition Color.hpp:74
float b() const
Definition Color.hpp:40
float g() const
Definition Color.hpp:39
float r() const
Definition Color.hpp:38

References ColorRGBA(), Slic3r::ColorRGB::b(), Slic3r::ColorRGB::g(), Slic3r::ColorRGB::r(), and Slic3r::ColorRGB::X().

Referenced by Slic3r::GUI::GLCanvas3D::_render_3d_navigator(), Slic3r::GUI::GizmoObjectManipulation::do_render_move_window(), Slic3r::GUI::GizmoObjectManipulation::do_render_rotate_window(), Slic3r::GUI::GizmoObjectManipulation::do_render_scale_input_window(), Slic3r::GUI::GLGizmoBase::render_cross_mark(), Slic3r::GUI::GLGizmoCut3D::render_cut_plane_grabbers(), Slic3r::GUI::GCodeViewer::SequentialView::Marker::render_position_window(), and Slic3r::GUI::GLGizmoMeasure::show_distance_xyz_ui().

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

◆ Y()

const ColorRGBA Slic3r::ColorRGBA::Y ( )
inlinestatic
146{ return { ColorRGB::Y().r(), ColorRGB::Y().g(), ColorRGB::Y().b(), 1.f };}
static const ColorRGB Y()
Definition Color.hpp:75

References ColorRGBA(), Slic3r::ColorRGB::b(), Slic3r::ColorRGB::g(), Slic3r::ColorRGB::r(), and Slic3r::ColorRGB::Y().

Referenced by Slic3r::GUI::GLCanvas3D::_render_3d_navigator(), Slic3r::GUI::GizmoObjectManipulation::do_render_move_window(), Slic3r::GUI::GizmoObjectManipulation::do_render_rotate_window(), Slic3r::GUI::GizmoObjectManipulation::do_render_scale_input_window(), Slic3r::GUI::GLGizmoBase::render_cross_mark(), Slic3r::GUI::GLGizmoCut3D::render_cut_plane_grabbers(), Slic3r::GUI::GCodeViewer::SequentialView::Marker::render_position_window(), and Slic3r::GUI::GLGizmoMeasure::show_distance_xyz_ui().

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

◆ YELLOW()

const ColorRGBA Slic3r::ColorRGBA::YELLOW ( )
inlinestatic
141{ return { 1.0f, 1.0f, 0.0f, 1.0f }; }

References ColorRGBA().

Referenced by Slic3r::GUI::SceneRaycaster::SceneRaycaster(), and Slic3r::GUI::GLGizmoTextureDisplacement::render_adjust_texture_gizmo().

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

◆ Z()

const ColorRGBA Slic3r::ColorRGBA::Z ( )
inlinestatic
147{ return { ColorRGB::Z().r(), ColorRGB::Z().g(), ColorRGB::Z().b(), 1.f };}
static const ColorRGB Z()
Definition Color.hpp:76

References ColorRGBA(), Slic3r::ColorRGB::b(), Slic3r::ColorRGB::g(), Slic3r::ColorRGB::r(), and Slic3r::ColorRGB::Z().

Referenced by Slic3r::GUI::GLCanvas3D::_render_3d_navigator(), Slic3r::GUI::GizmoObjectManipulation::do_render_move_window(), Slic3r::GUI::GizmoObjectManipulation::do_render_rotate_window(), Slic3r::GUI::GizmoObjectManipulation::do_render_scale_input_window(), Slic3r::GUI::GLGizmoBase::render_cross_mark(), Slic3r::GUI::GLGizmoCut3D::render_cut_plane_grabbers(), Slic3r::GUI::GCodeViewer::SequentialView::Marker::render_position_window(), and Slic3r::GUI::GLGizmoMeasure::show_distance_xyz_ui().

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

Member Data Documentation

◆ m_data

std::array<float, 4> Slic3r::ColorRGBA::m_data { 1.0f, 1.0f, 1.0f, 1.0f }
private

The documentation for this class was generated from the following files:
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/libslic3r/Color.hpp
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/libslic3r/Color.cpp