예제 #1
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);
}
예제 #2
0
void TokenContainer::FromShaperecordListToShapeVector(const std::vector<SHAPERECORD>& shapeRecords,
        tokensVector& tokens,
        const std::list<FILLSTYLE>& fillStyles,
        const MATRIX& matrix)
{
    Vector2 cursor;
    unsigned int color0=0;
    unsigned int color1=0;

    ShapesBuilder shapesBuilder;

    for(unsigned int i=0; i<shapeRecords.size(); i++)
    {
        const SHAPERECORD* cur=&shapeRecords[i];
        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);
            }
            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);
            }
        }
        else
        {
            if(cur->StateMoveTo)
            {
                cursor.x=cur->MoveDeltaX;
                cursor.y=cur->MoveDeltaY;
            }
            /*			if(cur->StateLineStyle)
            			{
            				cur_path->state.validStroke=true;
            				cur_path->state.stroke=cur->LineStyle;
            			}*/
            if(cur->StateFillStyle1)
            {
                color1=cur->FillStyle1;
            }
            if(cur->StateFillStyle0)
            {
                color0=cur->FillStyle0;
            }
        }
    }

    shapesBuilder.outputTokens(fillStyles, tokens);
}
예제 #3
0
void TokenContainer::FromShaperecordListToShapeVector(const std::vector<SHAPERECORD>& shapeRecords,
								  tokensVector& tokens,
								  const std::list<FILLSTYLE>& fillStyles,
								  const Vector2& offset, int scaling)
{
	int startX=offset.x;
	int startY=offset.y;
	unsigned int color0=0;
	unsigned int color1=0;

	ShapesBuilder shapesBuilder;

	for(unsigned int i=0;i<shapeRecords.size();i++)
	{
		const SHAPERECORD* cur=&shapeRecords[i];
		if(cur->TypeFlag)
		{
			if(cur->StraightFlag)
			{
				Vector2 p1(startX,startY);
				startX+=cur->DeltaX * scaling;
				startY+=cur->DeltaY * scaling;
				Vector2 p2(startX,startY);

				if(color0)
					shapesBuilder.extendFilledOutlineForColor(color0,p1,p2);
				if(color1)
					shapesBuilder.extendFilledOutlineForColor(color1,p1,p2);
			}
			else
			{
				Vector2 p1(startX,startY);
				startX+=cur->ControlDeltaX * scaling;
				startY+=cur->ControlDeltaY * scaling;
				Vector2 p2(startX,startY);
				startX+=cur->AnchorDeltaX * scaling;
				startY+=cur->AnchorDeltaY * scaling;
				Vector2 p3(startX,startY);

				if(color0)
					shapesBuilder.extendFilledOutlineForColorCurve(color0,p1,p2,p3);
				if(color1)
					shapesBuilder.extendFilledOutlineForColorCurve(color1,p1,p2,p3);
			}
		}
		else
		{
			if(cur->StateMoveTo)
			{
				startX=cur->MoveDeltaX * scaling + offset.x;
				startY=cur->MoveDeltaY * scaling + offset.y;
			}
/*			if(cur->StateLineStyle)
			{
				cur_path->state.validStroke=true;
				cur_path->state.stroke=cur->LineStyle;
			}*/
			if(cur->StateFillStyle1)
			{
				color1=cur->FillStyle1;
			}
			if(cur->StateFillStyle0)
			{
				color0=cur->FillStyle0;
			}
		}
	}

	shapesBuilder.outputTokens(fillStyles, tokens);
}