setfillstyle not working
Brought to you by:
daniil_guit
Hi!
SetFillStyle is not working as expected for some patterns. See:
int main(void) {
int gdriver = DETECT, gmode, errorcode;
initgraph(&gdriver, &gmode, "");
setfillstyle(SLASH_FILL, RED);
bar(200, 200, 300, 300);
getch();
closegraph();
return 0;
}
This fills the bar with solid pattern, not the desired slashed.
With best regards,
Luiz Curado
Sorry, I posted twice.
Last edit: Luiz Curado 2015-05-25
Hi! Thanx for bug report. Will look into it today.
I found the solution to this bug. Just replace the following functions:
void setfillstyle(int pattern, int color)
{
CHECK_GRAPHCS_INITED
CHECK_COLOR_RANGE(color)
if(fillSettings.pattern == pattern)
{
if(fillSettings.color != color)
{
fillSettings.color = color;
updateBrush(CHANGED_COLOR);
}
}
else
{
fillSettings.pattern = pattern;
fillSettings.color = color; // I just added this line
updateBrush(CHANGED_ALL);
}
}
static void updateBrush(int whatChanged)
{
//COLORREF c = translateColor(fillSettings.color); // I commented this line
COLORREF c = fillSettings.color ; // I added this line
if(whatChanged & CHANGED_STYLE)
{
currentBrush = stdBrushes[fillSettings.pattern];
selectObject(stdBrushes[fillSettings.pattern], 0);
}
if(whatChanged & CHANGED_COLOR)
{
SetBkColor(pages[0].dc, c);
SetBkColor(pages[1].dc, c);
SetBkColor(windowDC, c);
}
}
With best regards,
Luiz Curado