Another simple question


#1

Make great progress learning Juce (and still lots to go). Simple question is if all I want is a component that is blue, red, grey or anything really is there an easy way to do this?

I use a lot of colors as backgrounds and then put other controls on top of them. In the past I would use a UIView and just set the background color.

Thanks

Michael


#2

Use graphics to draw an image that is just a block of colour.

Graphics::drawImageAt (const Image& imageToDraw, const int topLeftX, const int topLeftY, const bool fillAlphaChannelWithCurrentBrush) const
Make an image

Image image(Image::RGB, [i]width in pixels[/i], [i]height in pixels[/i], true)
Graphics g (image)
g.fillAll(Colours:: [i]whatever colour you want[/i])

Then draw it with graphics


#3

Do you just mean:

class MyComp : public Component
{
public:

  virtual void paint(Graphics& g)
  {
    g.fillAll(Colours::red);
  }

};

?


#4

This is exactly what I did. Made a ColorComponent to handle it. Super easy but I also thought there was a chance that basic Component handled it.

Thanks for keeping me on the right track.

[quote=“valley”]Do you just mean:

class MyComp : public Component
{
public:

  virtual void paint(Graphics& g)
  {
    g.fillAll(Colours::red);
  }

};

?[/quote]