I am drawing a grid and it seems that drawRect is rounding the inner corner for some of the cells. Anyone have any ideas? Here is the code and magnified screen capture. In the screen capture notice the upper two rows appear as expected, and the lower two rows have the rounded inner corner.
Not seeing this here, tested on 10.0.17134. Can you try this PIP and see if it the issue is there for you?
/*******************************************************************************
The block below describes the properties of this PIP. A PIP is a short snippet
of code that can be read by the Projucer and used to generate a JUCE project.
BEGIN_JUCE_PIP_METADATA
name: RoundRectangleTest
dependencies: juce_core, juce_data_structures, juce_events, juce_graphics, juce_gui_basics
exporters: linux_make, vs2017, xcode_mac
moduleFlags: JUCE_STRICT_REFCOUNTEDPOINTER=1
type: Component
mainClass: MyComponent
END_JUCE_PIP_METADATA
*******************************************************************************/
#pragma once
//==============================================================================
class MyComponent : public Component
{
public:
//==============================================================================
MyComponent()
{
setSize (1000, 1000);
}
~MyComponent()
{
}
//==============================================================================
void paint (Graphics& g) override
{
// (Our component is opaque, so we must completely fill the background with a solid colour)
g.fillAll (getLookAndFeel().findColour (ResizableWindow::backgroundColourId));
static Array<Colour> colours { Colours::red, Colours::green, Colours::blue, Colours::hotpink, Colours::black };
auto b = getLocalBounds();
auto width = b.getWidth() / 5;
for (int i = 0; i < 5; ++i)
{
auto slice = b.removeFromLeft (width);
for (int s = 0; s < 5; ++s)
{
g.setColour (colours[i]);
g.fillRect (slice.removeFromTop (width).reduced (5));
}
}
}
void resized() override
{
// This is called when the MyComponent is resized.
// If you add any child components, this is where you should
// update their positions.
}
private:
//==============================================================================
// Your private member variables go here...
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MyComponent)
};
You PIP doesn’t produce the results, but this one does. It seems like it might somehow be related to the color… very odd
/*******************************************************************************
The block below describes the properties of this PIP. A PIP is a short snippet
of code that can be read by the Projucer and used to generate a JUCE project.
BEGIN_JUCE_PIP_METADATA
name: RoundRectangleTest
dependencies: juce_core, juce_data_structures, juce_events, juce_graphics, juce_gui_basics
exporters: linux_make, vs2017, xcode_mac
moduleFlags: JUCE_STRICT_REFCOUNTEDPOINTER=1
type: Component
mainClass: MyComponent
END_JUCE_PIP_METADATA
*******************************************************************************/
#pragma once
//==============================================================================
class MyComponent : public Component
{
public:
//==============================================================================
MyComponent()
{
setSize (1000, 1000);
}
~MyComponent()
{
}
//==============================================================================
void paint (Graphics& g) override
{
// (Our component is opaque, so we must completely fill the background with a solid colour)
g.fillAll (getLookAndFeel().findColour (ResizableWindow::backgroundColourId));
const auto gridWidth = 10;
const auto gridHeight = 6;
const auto numColours = (gridWidth * gridHeight) - 4;
const auto colourStep = 1.0f / (float)numColours;
std::vector<Colour> colours;
for (auto colourIndex = 0; colourIndex < numColours; ++colourIndex)
colours.push_back (Colour (colourStep * (float)colourIndex, 1.0f, 1.0f, 1.0f));
colours.push_back (Colour (0x00, 0x00, 0x00));
colours.push_back (Colour (0x00, 0x00, 0x00));
colours.push_back (Colour (0xFF, 0xFF, 0xFF));
colours.push_back (Colour (0xFF, 0xFF, 0xFF));
const auto cellWidth = getWidth () / gridWidth;
const auto cellHeight = getHeight () / gridHeight;
auto b = getLocalBounds();
auto width = b.getWidth() / gridWidth;
for (int i = 0; i < gridHeight; ++i)
{
auto slice = b.removeFromTop (width);
for (int s = 0; s < gridWidth; ++s)
{
const auto colorIndex = (i * gridWidth) + s;
const auto cell = slice.removeFromLeft (width);
g.setColour (colours[colorIndex]);
g.fillRect (cell);
g.setColour (Colours::grey);
g.drawRect (cell);
}
}
}
void resized() override
{
// This is called when the MyComponent is resized.
// If you add any child components, this is where you should
// update their positions.
}
private:
//==============================================================================
// Your private member variables go here...
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MyComponent)
};
That’s definitely some sort of OS-level interpolating going on there, I can just barely see some sort of rounding if I zoom in on my laptop to 1100% but it’s not at all noticeable at a normal level. There’s nothing we can do in JUCE to change this - even zooming in on the Windows cursor shows some rounded edges on the pointy bits.