コード例 #1
0
void OVGFont::DrawLine(VGFont &vgFont, VGint i32Size, VGuint *pStr, float fHeight, float fScale)
{
	static float fOrigin[] = {0.0f, 0.0f};

	/*
		Everytime vgDrawGlyph(s) is called the glyph(s) are drawn at the position
		defined by VG_GLYPH_ORIGIN. This value is updated after each call by the
		escapement vector defined by the glyph.

		As we don't want our text to follow any of the text previously drawn we're
		setting the glyph orign to 0,0.
	*/
	vgSetfv(VG_GLYPH_ORIGIN, 2, fOrigin);

	/*
		Using the matrix mode MATRIX_GLYPH_USER_TO_SURFACE translate and scale
		the font.
	*/
	vgLoadIdentity();
	vgTranslate(0.0f, fHeight);
	vgScale(fScale, fScale);

	/*
		Our string is only a few glyphs long so we're going to repeatedly
		draw it until the x value of the GLYPH_ORIGIN is greater than the
		scaled width.
	*/

	float fGlyphOrigin[2];
	fGlyphOrigin[0] = 0.0f;
	fGlyphOrigin[1] = 0.0f;

	float fScaledWidth = m_ui32ScreenWidth / fScale;

	while(fGlyphOrigin[0] < fScaledWidth)
	{
		/*
			Draw i32Size no of glyphs from pStr. The VG_FILL_PATH parameter
			defines how you would like the glyph (if a path) to be displayed.
			You can also have it stroked by using VG_STROKE_PATH. This parameter
			doesn't affect image based glyphs unless it's value is set to 0
			in which case no glyph (path or image based) will be drawn.

			The fourth and fifth parameters are the x and y adjustments
			for each glyph. These can be set to adjust the position of the glyphs
			drawn or can be set to NULL.

			The final parameter (set to VG_TRUE) disables or enables autohinting.
			If equal to true autohinting may be applied to alter the glyphs slightly
			to improve the render quality.
		*/
		vgDrawGlyphs(vgFont, i32Size, &pStr[0], NULL,NULL, VG_FILL_PATH, VG_TRUE);

		// Get the updated GLYPH_ORIGIN
		vgGetfv(VG_GLYPH_ORIGIN, 2, &fGlyphOrigin[0]);
	}
}
コード例 #2
0
void CHuiVg10CanvasGc::DoClearRenderBuffer( CHuiCanvasRenderBuffer& aImage, const TRect & aRect )
    {
    HUIFX_VG_INVARIANT();   
    const CHuiVg10CanvasRenderBuffer* vg10RenderBuffer = (const CHuiVg10CanvasRenderBuffer*) &aImage;    

    const TInt COLOR_COMPONENTS = 4;
    VGfloat savedColor[COLOR_COMPONENTS];
    vgGetfv(VG_CLEAR_COLOR, COLOR_COMPONENTS, savedColor);
    
    VGfloat color[COLOR_COMPONENTS] = 
                {
                 0.0f, 0.0f, 0.0f, 0.0f
                };
    vgSetfv(VG_CLEAR_COLOR, COLOR_COMPONENTS, color);
    vgClearImage(vg10RenderBuffer->Image(), aRect.iTl.iX, aRect.iTl.iY, aRect.Size().iWidth, aRect.Size().iHeight);
    vgSetfv(VG_CLEAR_COLOR, COLOR_COMPONENTS, savedColor);
    HUIFX_VG_INVARIANT();   
    }