Rectangle on the left is the desired output,
where the rectangle is filled with blue color and a random shape filled with yellow.
Rectangle on the right is the what I can produce,
where the rectangle is filled with blue color and a random shape only the outline is yellow, inside it shows the blue color only not yellow.
Here the code
Rectangle
// For drawing the rectangle
cr->set_line_width(1);
cr->move_to(int(rectangle.x ), int(rectangle.y ));
cr->rectangle(int(rectangle.x ), int(rectangle.y ), int(rectangle.width ), int(rectangle.height ));
cr->set_source_rgba(getColor().r, getColor().g, getColor().b, getColor().a);
cr->fill_preserve();
cr->stroke();
// cr->save();
if(subtractionDrawing.size() != 0)
{
for (int i = 0; i < subtractionDrawing.size(); ++i)
{
subtractionDrawing[i]->drawTo(cr);
}
}
Subtraction Region
cr->set_source_rgba(1.0,1.0,1.0, 1.0);
for(size_t i = 0; i < contourPoints.size(); i++)
{
if(i == contourPoints.size() - 1)
{
// std::cout<<"HERE DO NOT PLOT\n";
}
else
{
cr->move_to(contourPoints[i].x, contourPoints[i].y );
cr->line_to(contourPoints[i+1].x, contourPoints[i+1].y );
}
}
// cr->set_fill_rule(Cairo::WINDING);
cr->close_path();
cr->stroke_preserve();
cr->fill_preserve();
Could anyone point out where I am getting this wrong?