/*! @brief Fill in the values for a vertex. @param[in,out] vertexList The vertex data list to be updated. @param[in] px The x coordinate (and x normal) of the vertex. @param[in] py The y coordinate (and y normal) of the vertex. @param[in] pz The z coordinate (and z normal) of the vertex. @param[in] colr The colour of the vertex. @param[in] ts The s texture coordinate of the vertex. @param[in] tt The t texture coordinate of the vertex. */ static void setVertexData(Array<Vertex> & vertexList, const double px, const double py, const double pz, const Colour & colr, const float ts, const float tt) { ODL_ENTER(); ODL_P2("vertexList = ", &vertexList, "color = ", &colr); //#### ODL_D4("px = ", px, "py = ", py, "pz = ", pz, "ts = ", ts);//#### ODL_D1("tt = ", tt); //#### Vertex aVertex; aVertex._position[0] = static_cast<float>(kTipScale * px); aVertex._position[1] = static_cast<float>(kTipScale * py); aVertex._position[2] = static_cast<float>(kTipScale * pz); aVertex._normal[0] = static_cast<float>(px); aVertex._normal[1] = static_cast<float>(py); aVertex._normal[2] = static_cast<float>(pz); aVertex._colour[0] = colr.getFloatRed(); aVertex._colour[1] = colr.getFloatGreen(); aVertex._colour[2] = colr.getFloatBlue(); aVertex._colour[3] = colr.getFloatAlpha(); aVertex._texCoord[0] = ts; aVertex._texCoord[1] = tt; vertexList.add(aVertex); ODL_EXIT(); } // setVertexData
void OpenGLHelpers::clear (Colour colour) { glClearColor (colour.getFloatRed(), colour.getFloatGreen(), colour.getFloatBlue(), colour.getFloatAlpha()); glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); }
void TCATLookAndFeel::drawGlassSphere (Graphics& g, float x, float y, float diameter, const Colour& colour, const float outlineThickness) { if (diameter <= outlineThickness) return; Path p; p.addEllipse (x, y, diameter, diameter); { ColourGradient cg (Colours::white.overlaidWith (colour.withMultipliedAlpha (0.3f)), 0, y, Colours::white.overlaidWith (colour.withMultipliedAlpha (0.3f)), 0, y + diameter, false); cg.addColour (0.4, Colours::white.overlaidWith (colour)); g.setGradientFill(cg); g.fillPath (p); } { ColourGradient cg (Colours::white, 0, y + diameter * 0.06f, Colours::transparentWhite, 0, y + diameter * 0.3f, false); g.setGradientFill(cg); g.fillEllipse (x + diameter * 0.2f, y + diameter * 0.05f, diameter * 0.6f, diameter * 0.4f); } { ColourGradient cg (Colours::transparentBlack, x + diameter * 0.5f, y + diameter * 0.5f, Colours::black.withAlpha (0.5f * outlineThickness * colour.getFloatAlpha()), x, y + diameter * 0.5f, true); cg.addColour (0.7, Colours::transparentBlack); cg.addColour (0.8, Colours::black.withAlpha (0.1f * outlineThickness)); g.setGradientFill(cg); g.fillPath (p); } g.setColour (Colours::black.withAlpha (0.5f * colour.getFloatAlpha())); g.drawEllipse (x, y, diameter, diameter, outlineThickness); }
//============================================================================== void NonShinyLookAndFeel::drawGlassPointer (Graphics& g, const float x, const float y, const float diameter, const Colour& colour, const float outlineThickness, const int direction) throw() { if (diameter <= outlineThickness) return; Path p; p.startNewSubPath (x + diameter * 0.5f, y); p.lineTo (x + diameter, y + diameter * 0.6f); p.lineTo (x + diameter, y + diameter); p.lineTo (x, y + diameter); p.lineTo (x, y + diameter * 0.6f); p.closeSubPath(); p.applyTransform (AffineTransform::rotation (direction * (float_Pi * 0.5f), x + diameter * 0.5f, y + diameter * 0.5f)); { ColourGradient cg (Colours::white.overlaidWith (colour.withMultipliedAlpha (0.3f)), 0, y, Colours::white.overlaidWith (colour.withMultipliedAlpha (0.3f)), 0, y + diameter, false); cg.addColour (0.4, Colours::white.overlaidWith (colour)); g.setGradientFill (cg); g.fillPath (p); } ColourGradient cg (Colours::transparentBlack, x + diameter * 0.5f, y + diameter * 0.5f, Colours::black.withAlpha (0.5f * outlineThickness * colour.getFloatAlpha()), x - diameter * 0.2f, y + diameter * 0.5f, true); cg.addColour (0.5, Colours::transparentBlack); cg.addColour (0.7, Colours::black.withAlpha (0.07f * outlineThickness)); g.setGradientFill (cg); g.fillPath (p); g.setColour (Colours::black.withAlpha (0.5f * colour.getFloatAlpha())); g.strokePath (p, PathStrokeType (outlineThickness)); }
void Quadmesh::setShaderVariableFromColorTrait(OpenGLShaderProgram *shader, const char *key) { OpenGLShaderProgram::Uniform variable(*shader, key); Colour solidColor = Colour::fromString(getTrait(key).toString()); float r = solidColor.getFloatRed(); float g = solidColor.getFloatGreen(); float b = solidColor.getFloatBlue(); float a = solidColor.getFloatAlpha(); if (variable.uniformID < 0) { return; } else { variable.set(r, g, b, a); } }
void IntrojucerLookAndFeel::drawButtonBackground (Graphics& g, Button& button, const Colour& backgroundColour, bool isMouseOverButton, bool isButtonDown) { const bool flatOnLeft = button.isConnectedOnLeft(); const bool flatOnRight = button.isConnectedOnRight(); const bool flatOnTop = button.isConnectedOnTop(); const bool flatOnBottom = button.isConnectedOnBottom(); const float width = (float) button.getWidth(); const float height = (float) button.getHeight(); const float x = 0.5f; const float y = 0.5f; const float w = width - 1.0f; const float h = height - 1.0f; const float cornerSize = 4.0f; Colour baseColour (backgroundColour.withMultipliedSaturation (button.hasKeyboardFocus (true) ? 1.3f : 0.9f) .withMultipliedAlpha (button.isEnabled() ? 0.9f : 0.5f)); if (isButtonDown) baseColour = baseColour.contrasting (0.2f); else if (isMouseOverButton) baseColour = baseColour.contrasting (0.1f); const float mainBrightness = baseColour.getBrightness(); const float mainAlpha = baseColour.getFloatAlpha(); Path outline; outline.addRoundedRectangle (x, y, w, h, cornerSize, cornerSize, ! (flatOnLeft || flatOnTop), ! (flatOnRight || flatOnTop), ! (flatOnLeft || flatOnBottom), ! (flatOnRight || flatOnBottom)); g.setGradientFill (ColourGradient (baseColour.brighter (0.2f), 0.0f, 0.0f, baseColour.darker (0.25f), 0.0f, height, false)); g.fillPath (outline); g.setColour (Colours::white.withAlpha (0.4f * mainAlpha * mainBrightness * mainBrightness)); g.strokePath (outline, PathStrokeType (1.0f), AffineTransform::translation (0.0f, 1.0f) .scaled (1.0f, (h - 1.6f) / h)); g.setColour (Colours::black.withAlpha (0.4f * mainAlpha)); g.strokePath (outline, PathStrokeType (1.0f)); }
static void drawButtonShape (Graphics& g, const Path& outline, Colour baseColour, float height) { const float mainBrightness = baseColour.getBrightness(); const float mainAlpha = baseColour.getFloatAlpha(); g.setGradientFill (ColourGradient (baseColour.brighter (0.2f), 0.0f, 0.0f, baseColour.darker (0.25f), 0.0f, height, false)); g.fillPath (outline); g.setColour (Colours::white.withAlpha (0.4f * mainAlpha * mainBrightness * mainBrightness)); g.strokePath (outline, PathStrokeType (1.0f), AffineTransform::translation (0.0f, 1.0f) .scaled (1.0f, (height - 1.6f) / height)); g.setColour (Colours::black.withAlpha (0.4f * mainAlpha)); g.strokePath (outline, PathStrokeType (1.0f)); }
void preenfmLookAndFeel::drawButtonBackground (Graphics& g, Button& button, const Colour& backgroundColour, bool isMouseOverButton, bool isButtonDown) { if (!button.isEnabled()) { return; } Colour baseColour (backgroundColour.withMultipliedSaturation (button.hasKeyboardFocus (true) ? 1.3f : 0.9f) .withMultipliedAlpha (button.isEnabled() ? 0.9f : 0.5f)); if (isButtonDown || isMouseOverButton) baseColour = baseColour.contrasting (isButtonDown ? 0.2f : 0.1f); const bool flatOnLeft = button.isConnectedOnLeft(); const bool flatOnRight = button.isConnectedOnRight(); const bool flatOnTop = button.isConnectedOnTop(); const bool flatOnBottom = button.isConnectedOnBottom(); const float width = button.getWidth() - 1.0f; const float height = button.getHeight() - 1.0f; if (width > 0 && height > 0) { const float cornerSize = 4.0f; Path outline; outline.addRoundedRectangle (0.5f, 0.5f, width, height, cornerSize, cornerSize, ! (flatOnLeft || flatOnTop), ! (flatOnRight || flatOnTop), ! (flatOnLeft || flatOnBottom), ! (flatOnRight || flatOnBottom)); const float mainBrightness = baseColour.getBrightness(); const float mainAlpha = baseColour.getFloatAlpha(); g.setColour (baseColour); g.fillPath (outline); g.setColour (Colours::black.withAlpha (0.4f * mainAlpha)); g.strokePath (outline, PathStrokeType (1.0f)); } }
static void createVertexListFromMesh (const WavefrontObjFile::Mesh& mesh, Array<Vertex>& list, Colour colour) { const float scale = 0.2f; WavefrontObjFile::TextureCoord defaultTexCoord = { 0.5f, 0.5f }; WavefrontObjFile::Vertex defaultNormal = { 0.5f, 0.5f, 0.5f }; for (int i = 0; i < mesh.vertices.size(); ++i) { const WavefrontObjFile::Vertex& v = mesh.vertices.getReference (i); const WavefrontObjFile::Vertex& n = i < mesh.normals.size() ? mesh.normals.getReference (i) : defaultNormal; const WavefrontObjFile::TextureCoord& tc = i < mesh.textureCoords.size() ? mesh.textureCoords.getReference (i) : defaultTexCoord; Vertex vert = { { scale * v.x, scale * v.y, scale * v.z, }, { scale * n.x, scale * n.y, scale * n.z, }, { colour.getFloatRed(), colour.getFloatGreen(), colour.getFloatBlue(), colour.getFloatAlpha() }, { tc.x, tc.y } }; list.add (vert); } }
const D2D1_COLOR_F Direct2DLowLevelGraphicsContext::colourToD2D (const Colour& c) { return D2D1::ColorF::ColorF (c.getFloatRed(), c.getFloatGreen(), c.getFloatBlue(), c.getFloatAlpha()); }
void OpenGLHelpers::setColour (const Colour& colour) { glColor4f (colour.getFloatRed(), colour.getFloatGreen(), colour.getFloatBlue(), colour.getFloatAlpha()); }
void AttributeColorComponent::valueChanged(Value& val) { if (val == m_color) { const Colour col = getColour(); if (col != m_lastcolor) setAttributeValue({(double)col.getFloatRed(), (double)col.getFloatGreen(), (double)col.getFloatBlue(), (double)col.getFloatAlpha()}); m_lastcolor = col; } }
explicit GLColor( const Colour& juceColor ) : r(juceColor.getFloatRed()), g(juceColor.getFloatGreen()), b(juceColor.getFloatBlue()), a(juceColor.getFloatAlpha()) {}