Menu

#12 setfillstyle not working

v1.0 (example)
open
nobody
None
5
2015-06-19
2015-05-25
Luiz Curado
No

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

Discussion

  • Luiz Curado

    Luiz Curado - 2015-05-25

    Sorry, I posted twice.

     

    Last edit: Luiz Curado 2015-05-25
  • Daniil Guitelson

    Hi! Thanx for bug report. Will look into it today.

     
  • Luiz Curado

    Luiz Curado - 2015-06-19

    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

     

Log in to post a comment.