本文整理汇总了C++中ColourGradient类的典型用法代码示例。如果您正苦于以下问题:C++ ColourGradient类的具体用法?C++ ColourGradient怎么用?C++ ColourGradient使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ColourGradient类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drawDemo
void drawDemo (Graphics& g) override
{
const Path& p = logoPath;
if (useLinearGradient || useRadialGradient)
{
Colour c1 (gradientColours[0].getValue(), gradientColours[1].getValue(), gradientColours[2].getValue(), 1.0f);
Colour c2 (gradientColours[3].getValue(), gradientColours[4].getValue(), gradientColours[5].getValue(), 1.0f);
Colour c3 (gradientColours[6].getValue(), gradientColours[7].getValue(), gradientColours[8].getValue(), 1.0f);
float x1 = gradientPositions[0].getValue() * getWidth() * 0.25f;
float y1 = gradientPositions[1].getValue() * getHeight() * 0.25f;
float x2 = gradientPositions[2].getValue() * getWidth() * 0.75f;
float y2 = gradientPositions[3].getValue() * getHeight() * 0.75f;
ColourGradient gradient (c1, x1, y1,
c2, x2, y2,
useRadialGradient);
gradient.addColour (gradientIntermediate.getValue(), c3);
g.setGradientFill (gradient);
}
else
{
g.setColour (Colours::blue);
}
g.setOpacity (getAlpha());
g.fillPath (p, getTransform());
}
示例2: cg
void DropShadow::drawForRectangle (Graphics& g, const Rectangle<int>& targetArea) const
{
ColourGradient cg (colour, 0, 0, colour.withAlpha (0.0f), 0, 0, false);
for (float i = 0.05f; i < 1.0f; i += 0.1f)
cg.addColour (1.0 - i, colour.withMultipliedAlpha (i * i));
const float radiusInset = radius / 2.0f;
const float expandedRadius = radius + radiusInset;
auto area = targetArea.toFloat().reduced (radiusInset) + offset.toFloat();
auto r = area.expanded (expandedRadius);
auto top = r.removeFromTop (expandedRadius);
auto bottom = r.removeFromBottom (expandedRadius);
drawShadowSection (g, cg, top.removeFromLeft (expandedRadius), true, 1.0f, 1.0f, 0, 1.0f);
drawShadowSection (g, cg, top.removeFromRight (expandedRadius), true, 0, 1.0f, 1.0f, 1.0f);
drawShadowSection (g, cg, top, false, 0, 1.0f, 0, 0);
drawShadowSection (g, cg, bottom.removeFromLeft (expandedRadius), true, 1.0f, 0, 0, 0);
drawShadowSection (g, cg, bottom.removeFromRight (expandedRadius), true, 0, 0, 1.0f, 0);
drawShadowSection (g, cg, bottom, false, 0, 0, 0, 1.0f);
drawShadowSection (g, cg, r.removeFromLeft (expandedRadius), false, 1.0f, 0, 0, 0);
drawShadowSection (g, cg, r.removeFromRight (expandedRadius), false, 0, 0, 1.0f, 0);
g.setColour (colour);
g.fillRect (area);
}
示例3: baseColour
void DemoLookAndFeel::drawButtonBackground (Graphics& g,
Button& button,
const Colour& backgroundColour,
bool isMouseOverButton,
bool isButtonDown)
{
const int width = button.getWidth();
const int height = button.getHeight();
// const float outlineThickness = button.isEnabled() ? ((isButtonDown || isMouseOverButton) ? 1.2f : 0.7f) : 0.4f;
// const float halfThickness = outlineThickness * 0.5f;
// const float indentL = button.isConnectedOnLeft() ? 0.1f : halfThickness;
// const float indentR = button.isConnectedOnRight() ? 0.1f : halfThickness;
// const float indentT = button.isConnectedOnTop() ? 0.1f : halfThickness;
// const float indentB = button.isConnectedOnBottom() ? 0.1f : halfThickness;
const Colour baseColour (GuiHelpers::createBaseColour (backgroundColour,
button.hasKeyboardFocus (true),
isMouseOverButton, isButtonDown)
.withMultipliedAlpha (button.isEnabled() ? 1.0f : 0.5f));
ColourGradient cg (baseColour.brighter (0.5f), 0.0f, 0.0f,
baseColour.darker (0.5f), 0.0f, (float)height,
false);
Rectangle<float> bounds (g.getClipBounds().toFloat().reduced (0.0f, 1.0f));
g.setGradientFill (cg);
g.fillRoundedRectangle (bounds, 4.0f);
bounds.setX (bounds.getX() + 0.5f);
bounds.setWidth (bounds.getWidth() - 1.0f);
bounds.setY (bounds.getY() - 0.5f);
bounds.setHeight (bounds.getHeight());
g.setColour (Colours::black);
g.drawRoundedRectangle (bounds, 4.0f, 1.0f);
ColourGradient highlight (Colours::white.withAlpha (0.1f), 2.0f, (float)height,
Colours::white.withAlpha (0.1f), width - 2.0f, (float)height,
false);
highlight.addColour (2.0f / (width - 4.0f),
Colours::white.withAlpha (0.5f));
highlight.addColour (1.0f - (2.0f / (width - 4.0f)),
Colours::white.withAlpha (0.5f));
g.setGradientFill (highlight);
g.drawLine (2.0f, height - 0.5f, width - 2.0f, height - 0.5f, 0.5f);
// drawGlassLozenge (g,
// indentL,
// indentT,
// width - indentL - indentR,
// height - indentT - indentB,
// baseColour, outlineThickness, -1.0f,
// button.isConnectedOnLeft(),
// button.isConnectedOnRight(),
// button.isConnectedOnTop(),
// button.isConnectedOnBottom());
}
示例4: knobColour
void CustomLookAndFeel::drawLinearSliderThumb (Graphics& g, int x, int y, int width,
int height, float sliderPos,
float minSliderPos, float maxSliderPos,
const Slider::SliderStyle style,
Slider& slider)
{
if (style == Slider::LinearVertical)
{
bool isDownOrDragging = slider.isEnabled() && (slider.isMouseOverOrDragging() || slider.isMouseButtonDown());
Colour knobColour (slider.findColour (Slider::thumbColourId).withMultipliedSaturation ((slider.hasKeyboardFocus (false) || isDownOrDragging) ? 1.3f : 0.9f)
.withMultipliedAlpha (slider.isEnabled() ? 1.0f : 0.7f));
const float thumbWidth = jmin (slider.getWidth() - 2 * spaceBetweenThumbAndComponentBorder,
maxThumbWidthVertical);
const float thumbHeight = thumbWidth * heightToWidthRatioVertical;
const float xCenter = x + width * 0.5f;
// Originally it was yCenter = sliderPos. But that way the thumb (and especially the center line) did
// not always look the same because of aliasing. With this additional rounding it is ensured that the
// vertical position of the thumb "snaps" to the closest pixel and therefore looks always the same.
const float yCenter = (int)(sliderPos) + 0.5f;
const float xThumb = xCenter - 0.5f * thumbWidth;
const float yThumb = yCenter - 0.5f * thumbHeight;
// The shape of the thumb
Path p;
p.addRoundedRectangle(xThumb, yThumb, thumbWidth, thumbHeight, 5.0f);
// Drop shadow
const DropShadow ds (Colours::black, 4, Point<int> (0, 0));
ds.drawForPath (g, p);
// Outline
const float outlineThickness = slider.isEnabled() ? 0.8f : 0.3f;
g.setColour (Colours::black);
//g.setColour (knobColour.darker());
g.strokePath (p, PathStrokeType (outlineThickness));
// Fill
ColourGradient gradient (knobColour.darker(), xThumb, yThumb,
knobColour.darker(), xThumb, yThumb + thumbHeight, false);
gradient.addColour (0.5, knobColour.brighter());
g.setGradientFill(gradient);
g.fillPath (p);
// g.setColour (knobColour);
// g.fillPath (p);
// Middle line
g.setColour(Colours::black);
g.drawLine(xThumb, yCenter, xThumb + thumbWidth, yCenter);
}
else
{
// Just call the base class for the demo
LookAndFeel_V3::drawLinearSliderThumb (g, x, y, width, height, sliderPos, minSliderPos, maxSliderPos, style, slider);
}
}
示例5: cg
void ProjectContentComponent::paintOverChildren (Graphics& g)
{
if (resizerBar != nullptr)
{
const int shadowSize = 15;
const int x = resizerBar->getX();
ColourGradient cg (Colours::black.withAlpha (0.25f), (float) x, 0,
Colours::transparentBlack, (float) (x - shadowSize), 0, false);
cg.addColour (0.4, Colours::black.withAlpha (0.07f));
cg.addColour (0.6, Colours::black.withAlpha (0.02f));
g.setGradientFill (cg);
g.fillRect (x - shadowSize, 0, shadowSize, getHeight());
}
}
示例6: newType
bool DrawableShape::RelativeFillType::readFrom (const ValueTree& v, ComponentBuilder::ImageProvider* imageProvider)
{
const String newType (v [FillAndStrokeState::type].toString());
if (newType == "solid")
{
const String colourString (v [FillAndStrokeState::colour].toString());
fill.setColour (Colour (colourString.isEmpty() ? (uint32) 0xff000000
: (uint32) colourString.getHexValue32()));
return true;
}
else if (newType == "gradient")
{
ColourGradient g;
g.isRadial = v [FillAndStrokeState::radial];
StringArray colourSteps;
colourSteps.addTokens (v [FillAndStrokeState::colours].toString(), false);
for (int i = 0; i < colourSteps.size() / 2; ++i)
g.addColour (colourSteps[i * 2].getDoubleValue(),
Colour ((uint32) colourSteps[i * 2 + 1].getHexValue32()));
fill.setGradient (g);
gradientPoint1 = RelativePoint (v [FillAndStrokeState::gradientPoint1]);
gradientPoint2 = RelativePoint (v [FillAndStrokeState::gradientPoint2]);
gradientPoint3 = RelativePoint (v [FillAndStrokeState::gradientPoint3]);
return true;
}
else if (newType == "image")
{
Image im;
if (imageProvider != nullptr)
im = imageProvider->getImageForIdentifier (v [FillAndStrokeState::imageId]);
fill.setTiledImage (im, AffineTransform::identity);
fill.setOpacity ((float) v.getProperty (FillAndStrokeState::imageOpacity, 1.0f));
return true;
}
jassertfalse;
return false;
}
示例7: throw
//==============================================================================
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));
}
示例8: widgetData
//add any new custom widgets here to avoid having to edit makefiles and projects
// ===========================================================================
CabbageMeter::CabbageMeter (ValueTree wData, CabbagePluginEditor* _owner):
widgetData (wData),
owner (_owner),
overlayRect (Colour::fromString (CabbageWidgetData::getProperty (wData, CabbageIdentifierIds::overlaycolour).toString())),
isVertical (CabbageWidgetData::getProperty (wData, CabbageIdentifierIds::orientation).toString() == "vertical" ? true : false),
outlineColour (Colour::fromString (CabbageWidgetData::getProperty (wData, CabbageIdentifierIds::outlinecolour).toString())),
outlineThickness (CabbageWidgetData::getNumProp (wData, CabbageIdentifierIds::outlinethickness)),
corners (CabbageWidgetData::getNumProp (wData, CabbageIdentifierIds::corners))
{
setName (CabbageWidgetData::getStringProp (wData, CabbageIdentifierIds::name));
widgetData.addListener (this); //add listener to valueTree so it gets notified when a widget's property changes
initialiseCommonAttributes (this, wData); //initialise common attributes such as bounds, name, rotation, etc..
for (int i = 0; i < CabbageWidgetData::getProperty (wData, CabbageIdentifierIds::metercolour).size(); i++)
{
gradientColours.add (Colour::fromString (CabbageWidgetData::getProperty (wData, CabbageIdentifierIds::metercolour)[i].toString()));
}
if (isVertical)
{
ColourGradient vGradient (gradientColours[0], 0.f, 0.f, gradientColours[gradientColours.size() - 1], getWidth(), getHeight(), false);
for (int i = 1; i < gradientColours.size() - 1; i++)
vGradient.addColour ((float)i / (float)gradientColours.size(), gradientColours[i]);
colourGradient = vGradient;
}
else
{
ColourGradient hGradient (gradientColours[0], 0.f, getHeight(), gradientColours[gradientColours.size() - 1], getWidth(), getHeight(), false);
for (int i = 1; i < gradientColours.size() - 1; i++)
hGradient.addColour ((float)i / (float)gradientColours.size(), gradientColours[i]);
colourGradient = hGradient;
}
addAndMakeVisible (overlayRect);
}
示例9: getLocalBounds
void JUCESplashScreen::paint (Graphics& g)
{
auto r = getLocalBounds().toFloat();
Point<float> bottomRight (0.9f * r.getWidth(),
0.9f * r.getHeight());
ColourGradient cg (Colour (0x00000000), Line<float> (0.0f, r.getHeight(), r.getWidth(), 0.0f)
.findNearestPointTo (bottomRight),
Colour (0xff000000), bottomRight, false);
cg.addColour (0.25f, Colour (0x10000000));
cg.addColour (0.50f, Colour (0x30000000));
cg.addColour (0.75f, Colour (0x70000000));
g.setFillType (cg);
g.fillAll();
content->drawWithin (g, getLogoArea (r), RectanglePlacement::centred, 1.0f);
if (splashDisplayTime == 0)
splashDisplayTime = Time::getMillisecondCounter();
if (! isTimerRunning())
startTimer (millisecondsToDisplaySplash);
}