void ShapesBuilder::outputTokens(const std::list<FILLSTYLE>& styles, tokensVector& tokens) { joinOutlines(); //Try to greedily condense as much as possible the output map< unsigned int, vector< vector<ShapePathSegment> > >::iterator it=filledShapesMap.begin(); //For each color for(; it!=filledShapesMap.end(); ++it) { assert(!it->second.empty()); //Find the style given the index std::list<FILLSTYLE>::const_iterator stylesIt=styles.begin(); assert(it->first); for(unsigned int i=0; i<it->first-1; i++) { ++stylesIt; assert(stylesIt!=styles.end()); } //Set the fill style tokens.emplace_back(GeomToken(SET_FILL,*stylesIt)); vector<vector<ShapePathSegment> >& outlinesForColor=it->second; for(unsigned int i=0; i<outlinesForColor.size(); i++) { vector<ShapePathSegment>& segments=outlinesForColor[i]; assert (segments[0].type == PATH_START); tokens.push_back(GeomToken(MOVE, getVertex(segments[0].i))); for(unsigned int j=1; j<segments.size(); j++) { ShapePathSegment segment = segments[j]; assert(segment.type != PATH_START); if (segment.type == PATH_STRAIGHT) tokens.push_back(GeomToken(STRAIGHT, getVertex(segment.i))); if (segment.type == PATH_CURVE_QUADRATIC) tokens.push_back(GeomToken(CURVE_QUADRATIC, getVertex(segment.i), getVertex(segments[++j].i))); } } } }
void GraphicsBitmapFill::appendToTokens(tokensVector& tokens) { tokens.emplace_back(GeomToken(SET_FILL, toFillStyle())); }