예제 #1
0
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)));
            }
        }
    }
}
예제 #2
0
/* Find the size of the active texture (bitmap set by the latest SET_FILL). */
void TokenContainer::getTextureSize(tokensVector& tokens, int *width, int *height)
{
	*width=0;
	*height=0;

	for(int i=tokens.size()-1;i>=0;i--)
	{
		const FILLSTYLE& style=tokens[i].fillStyle;
		const FILL_STYLE_TYPE& fstype=style.FillStyleType;
		if(tokens[i].type==SET_FILL && 
		   (fstype==REPEATING_BITMAP ||
		    fstype==NON_SMOOTHED_REPEATING_BITMAP ||
		    fstype==CLIPPED_BITMAP ||
		    fstype==NON_SMOOTHED_CLIPPED_BITMAP))
		{
			if (style.bitmap.isNull())
				return;

			*width=style.bitmap->getWidth();
			*height=style.bitmap->getHeight();
			return;
		}
	}
}
예제 #3
0
TokenContainer::TokenContainer(DisplayObject* _o, const tokensVector& _tokens, float _scaling) :
    owner(_o), tokens(_tokens.begin(),_tokens.end()), scaling(_scaling)

{
}
예제 #4
0
void TokenContainer::FromDefineMorphShapeTagToShapeVector(SystemState* sys,DefineMorphShapeTag *tag, tokensVector &tokens, uint16_t ratio)
{
	LOG(LOG_NOT_IMPLEMENTED,"MorphShape currently ignores most morph settings and just displays the start/end shape. ID:"<<tag->getId()<<" ratio:"<<ratio);
	Vector2 cursor;
	unsigned int color0=0;
	unsigned int color1=0;
	unsigned int linestyle=0;

	const MATRIX matrix;
	ShapesBuilder shapesBuilder;

	// TODO compute SHAPERECORD entries based on ratio
	auto it = ratio == 65535 ? tag->EndEdges.ShapeRecords.begin() : tag->StartEdges.ShapeRecords.begin();
	auto last = ratio == 65535 ? tag->EndEdges.ShapeRecords.end() : tag->StartEdges.ShapeRecords.end();
	while (it != last)
	{
		const SHAPERECORD* cur=&(*it);
		it++;
		if(cur->TypeFlag)
		{
			if(cur->StraightFlag)
			{
				Vector2 p1(matrix.multiply2D(cursor));
				cursor.x += cur->DeltaX;
				cursor.y += cur->DeltaY;
				Vector2 p2(matrix.multiply2D(cursor));

				if(color0)
					shapesBuilder.extendFilledOutlineForColor(color0,p1,p2);
				if(color1)
					shapesBuilder.extendFilledOutlineForColor(color1,p1,p2);
				if(linestyle)
					shapesBuilder.extendStrokeOutline(linestyle,p1,p2);
			}
			else
			{
				Vector2 p1(matrix.multiply2D(cursor));
				cursor.x += cur->ControlDeltaX;
				cursor.y += cur->ControlDeltaY;
				Vector2 p2(matrix.multiply2D(cursor));
				cursor.x += cur->AnchorDeltaX;
				cursor.y += cur->AnchorDeltaY;
				Vector2 p3(matrix.multiply2D(cursor));

				if(color0)
					shapesBuilder.extendFilledOutlineForColorCurve(color0,p1,p2,p3);
				if(color1)
					shapesBuilder.extendFilledOutlineForColorCurve(color1,p1,p2,p3);
				if(linestyle)
					shapesBuilder.extendStrokeOutlineCurve(linestyle,p1,p2,p3);
			}
		}
		else
		{
			if(cur->StateMoveTo)
			{
				cursor.x=cur->MoveDeltaX;
				cursor.y=cur->MoveDeltaY;
			}
			if(cur->StateLineStyle)
			{
				linestyle = cur->LineStyle;
			}
			if(cur->StateFillStyle1)
			{
				color1=cur->FillStyle1;
			}
			if(cur->StateFillStyle0)
			{
				color0=cur->FillStyle0;
			}
		}
	}
	tokens.clear();
	shapesBuilder.outputMorphTokens(tag->MorphFillStyles.FillStyles,tag->MorphLineStyles.LineStyles2, tokens,ratio);
}
void GraphicsBitmapFill::appendToTokens(tokensVector& tokens)
{

	tokens.emplace_back(GeomToken(SET_FILL, toFillStyle()));
}
예제 #6
0
TokenContainer::TokenContainer(DisplayObject* _o, const tokensVector& _tokens, float _scaling) :
	owner(_o), tokens(_tokens.begin(),_tokens.end(),reporter_allocator<GeomToken>(_o->getSystemState()->unaccountedMemory)), scaling(_scaling)

{
}