Color3f operator-(Color3f const& lhs, Color3f const& rhs) { Color3f result; result.r(lhs.r() - rhs.r()); result.g(lhs.g() - rhs.g()); result.b(lhs.b() - rhs.b()); return result; }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- TEST(VariantTest, TypeColor3f) { const Color3f val(0.2f, 0.2f, 0.3f); Variant var(val); ASSERT_EQ(Variant::COLOR3F, var.type()); ASSERT_TRUE(var.isValid()); Color3f v = var.getColor3f(); ASSERT_EQ(val.r(), v.r()); ASSERT_EQ(val.g(), v.g()); ASSERT_EQ(val.b(), v.b()); }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- Color4f::Color4f(const Color3f& rgbColor, float alpha) { m_rgba[0] = rgbColor.r(); m_rgba[1] = rgbColor.g(); m_rgba[2] = rgbColor.b(); m_rgba[3] = alpha; }
//-------------------------------------------------------------------------------------------------- /// Construct from 3 component RGB color. Alpha value will be set to 1.0 //-------------------------------------------------------------------------------------------------- Color4f::Color4f(const Color3f& rgbColor) { m_rgba[0] = rgbColor.r(); m_rgba[1] = rgbColor.g(); m_rgba[2] = rgbColor.b(); m_rgba[3] = 1.0f; }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void UniformFloat::set(const Color3f& value) { m_type = FLOAT_VEC3; m_data.resize(3); m_data[0] = value.r(); m_data[1] = value.g(); m_data[2] = value.b(); }
void FrameBufferObject:: clear_color_buffers(RenderContext const& ctx, Color3f const& color) { if (ctx.id < fbos_.size()) ctx.render_context->clear_color_buffers( fbos_[ctx.id], math::vec4(color.r(), color.g(), color.b(), 0.f)); }
void ShaderProgram:: set_color3f(RenderContext const& context, std::string const& color_name, Color3f const& color) { if (programs_.size() > context.id) programs_[context.id]->uniform( color_name, math::vec3(color.r(), color.g(), color.b())); }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- String PropertyXmlSerializer::valueTextFromColor3fVariant(const Variant& variant) { CVF_ASSERT(variant.type() == Variant::COLOR3F); Color3f val = variant.getColor3f(); String txt = String::number(val.r()) + " " + String::number(val.g()) + " " + String::number(val.b()); return txt; }
void ColorTest::access() { Color3f c3(15, 255, 10); const Color3f cc3(15, 255, 10); CORRADE_COMPARE(c3.r(), 15); CORRADE_COMPARE(c3.g(), 255); CORRADE_COMPARE(c3.b(), 10); CORRADE_COMPARE(cc3.r(), 15); CORRADE_COMPARE(cc3.g(), 255); CORRADE_COMPARE(cc3.b(), 10); Color4 c4(125, 98, 51, 22); const Color4f cc4(125, 98, 51, 22); CORRADE_COMPARE(c4.r(), 125); CORRADE_COMPARE(c4.g(), 98); CORRADE_COMPARE(c4.b(), 51); CORRADE_COMPARE(c4.a(), 22); CORRADE_COMPARE(cc4.r(), 125); CORRADE_COMPARE(cc4.g(), 98); CORRADE_COMPARE(cc4.b(), 51); CORRADE_COMPARE(cc4.a(), 22); }
bool operator==(Color3f const& lhs, Color3f const& rhs) { return lhs.r() == rhs.r() && lhs.g() == rhs.g() && lhs.b() == rhs.b(); }
Color3f operator/(Color3f const& lhs, float rhs) { return Color3f(lhs.r() / rhs, lhs.g() / rhs, lhs.b() / rhs); }
Color3f operator*(float const& lhs, Color3f rhs) { return Color3f(rhs.r() * lhs, rhs.g() * lhs, rhs.b() * lhs); }
Color3f operator*(float _f, const Color3f& _c) { return Color3f(_c.r()*_f, _c.g()*_f, _c.b()*_f); }
Color3f operator+(const Color3f& _c1, const Color3f& _c2) { return Color3f(_c1.r()+_c2.r(), _c1.g()+_c2.g(), _c1.b()+_c2.b()); }
void Color3f::operator+=(const Color3f& _c) { r_ += _c.r(); g_ += _c.g(); b_ += _c.b(); }
Color3f::Color3f(const Color3f& _c) : r_(_c.r()), g_(_c.g()), b_(_c.b()) {}