当前位置: 首页>>代码示例>>C++>>正文


C++ FTPoint::X方法代码示例

本文整理汇总了C++中FTPoint::X方法的典型用法代码示例。如果您正苦于以下问题:C++ FTPoint::X方法的具体用法?C++ FTPoint::X怎么用?C++ FTPoint::X使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FTPoint的用法示例。


在下文中一共展示了FTPoint::X方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: vectoriser

FTPolyGlyph::FTPolyGlyph( FT_GlyphSlot glyph, bool useDisplayList)
:   FTGlyph( glyph),
    glList(0)
{
    if( ft_glyph_format_outline != glyph->format)
    {
        err = 0x14; // Invalid_Outline
        return;
    }

    FTVectoriser vectoriser( glyph);

    if(( vectoriser.ContourCount() < 1) || ( vectoriser.PointCount() < 3))
    {
        return;
    }
    
    unsigned int horizontalTextureScale = glyph->face->size->metrics.x_ppem * 64;
    unsigned int verticalTextureScale = glyph->face->size->metrics.y_ppem * 64;        
        
    vectoriser.MakeMesh( 1.0);
    
    if( useDisplayList)
    {
        glList = glGenLists( 1);
        glNewList( glList, GL_COMPILE);
    }

    const FTMesh* mesh = vectoriser.GetMesh();
    for( unsigned int index = 0; index < mesh->TesselationCount(); ++index)
    {
        const FTTesselation* subMesh = mesh->Tesselation( index);
        unsigned int polyonType = subMesh->PolygonType();

        glBegin( polyonType);
            for( unsigned int pointIndex = 0; pointIndex < subMesh->PointCount(); ++pointIndex)
            {
                FTPoint point = subMesh->Point(pointIndex);
                
                glTexCoord2f( point.X() / horizontalTextureScale,
                              point.Y() / verticalTextureScale);
                
                glVertex3f( point.X() / 64.0f,
                            point.Y() / 64.0f,
                            0.0f);
            }
        glEnd();
    }

    if(useDisplayList)
    {
        glEndList();
    }
}
开发者ID:Gi133,项目名称:NetworkingCoursework,代码行数:54,代码来源:FTPolyGlyph.cpp

示例2: testKerning

        void testKerning()
        {
            FTFace test(ARIAL_FONT_FILE);
            FTPoint kerningVector = test.KernAdvance('A', 'A');
            CPPUNIT_ASSERT_EQUAL(kerningVector.X(), 0.);
            CPPUNIT_ASSERT_EQUAL(kerningVector.Y(), 0.);
            CPPUNIT_ASSERT_EQUAL(kerningVector.Z(), 0.);

            kerningVector = test.KernAdvance(0x6FB3, 0x9580);
            CPPUNIT_ASSERT_EQUAL(kerningVector.X(), 0.);
            CPPUNIT_ASSERT_EQUAL(kerningVector.Y(), 0.);
            CPPUNIT_ASSERT_EQUAL(kerningVector.Z(), 0.);
        }
开发者ID:pjohalloran,项目名称:gameframework,代码行数:13,代码来源:FTFace-Test.cpp

示例3: ftglRenderGlyph

void ftglRenderGlyph(FTGLglyph *g, FTGL_DOUBLE penx, FTGL_DOUBLE peny,
                     int renderMode, FTGL_DOUBLE *advancex,
                     FTGL_DOUBLE *advancey)
{
    FTPoint pen(penx, peny);
    FTPoint ret = _ftglRenderGlyph(g, pen, renderMode);
    *advancex = ret.X();
    *advancey = ret.Y();
}
开发者ID:Felipeasg,项目名称:workbench,代码行数:9,代码来源:FTGlyphGlue.cpp

示例4: MeasureText

 Gwen::Point Chowdren::MeasureText( Gwen::Font* pFont,
     const Gwen::UnicodeString & text )
 {
     FTSimpleLayout layout;
     layout.SetLineLength(10000);
     layout.SetFont(get_font(pFont->size));
     FTBBox bbox = layout.BBox(text.c_str());
     FTPoint size = bbox.Upper() - bbox.Lower();
     return Gwen::Point((int)ceil(size.X()), (int)ceil(size.Y()));
 }
开发者ID:joaormatos,项目名称:anaconda,代码行数:10,代码来源:GwenChowdrenRender.cpp

示例5: testSetters

        void testSetters()
        {
            FTPoint point;
            FTPoint point1(1, 2, 3);

            point.X(1);
            point.Y(2);
            point.Z(3);

            CPPUNIT_ASSERT(point == point1);
        }
开发者ID:pjohalloran,项目名称:gameframework,代码行数:11,代码来源:FTPoint-Test.cpp

示例6: GetNormal

FTPoint FTExtrdGlyph::GetNormal( const FTPoint &a, const FTPoint &b)
{
    float vectorX = a.X() - b.X();
    float vectorY = a.Y() - b.Y();

    float length = sqrt( vectorX * vectorX + vectorY * vectorY );

    if( length > 0.01f)
    {
        length = 1 / length;
    }
    else
    {
        length = 0.0f;
    }

    return FTPoint( -vectorY * length,
                    vectorX * length,
                    0.0f);
}
开发者ID:bowlofstew,项目名称:Aquaria,代码行数:20,代码来源:FTExtrdGlyph.cpp

示例7: ComputeOutsetPoint

// This function is a bit tricky. Given a path ABC, it returns the
// coordinates of the outset point facing B on the left at a distance
// of 64.0.
//                                         M
//                            - - - - - - X
//                             ^         / '
//                             | 64.0   /   '
//  X---->-----X     ==>    X--v-------X     '
// A          B \          A          B \   .>'
//               \                       \<'  64.0
//                \                       \                  .
//                 \                       \                 .
//                C X                     C X
//
FTPoint FTContour::ComputeOutsetPoint(FTPoint A, FTPoint B, FTPoint C)
{
    /* Build the rotation matrix from 'ba' vector */
    FTPoint ba = (A - B).Normalise();
    FTPoint bc = C - B;

    /* Rotate bc to the left */
    FTPoint tmp(bc.X() * -ba.X() + bc.Y() * -ba.Y(),
                bc.X() * ba.Y() + bc.Y() * -ba.X());

    /* Compute the vector bisecting 'abc' */
    FTGL_DOUBLE norm = sqrt(tmp.X() * tmp.X() + tmp.Y() * tmp.Y());
    FTGL_DOUBLE dist = 64.0 * sqrt((norm - tmp.X()) / (norm + tmp.X()));
    tmp.X(tmp.Y() < 0.0 ? dist : -dist);
    tmp.Y(64.0);

    /* Rotate the new bc to the right */
    return FTPoint(tmp.X() * -ba.X() + tmp.Y() * ba.Y(),
                   tmp.X() * -ba.Y() + tmp.Y() * -ba.X());
}
开发者ID:joaocc,项目名称:ta3d-git,代码行数:34,代码来源:FTContour.cpp

示例8: printText

void cFont::printText(LPCSTR text, FTPoint textPos, colour3f textColour)
{
	glPushMatrix();

	glTranslatef(textPos.X(), textPos.Y(), 0);
	glScalef(1, -1, 1);
	glColor3f(textColour.r, textColour.g, textColour.b);
	theFont->Render(text);

	glPopMatrix();
}
开发者ID:Baranzo94,项目名称:GP3-Coursework,代码行数:11,代码来源:cFont.cpp

示例9: measureText

Font::FONT_RECT Font::measureText(const wchar_t* wText) throw(invalid_argument, runtime_error) {

    ASSERT(
        (wText != 0),
        invalid_argument("wText")
    );

    if(font_ == 0) {
        return Font::FONT_RECT();
    }

    FTBBox bbox = font_->BBox(wText, -1);

    FTPoint low = bbox.Lower();
    FTPoint hi  = bbox.Upper();

    Font::FONT_RECT rect;

    rect.width  = hi.X() - low.X();
    rect.height = hi.Y() - low.Y();

    return rect;

}
开发者ID:ElijahVlasov,项目名称:EGF,代码行数:24,代码来源:Font.cpp

示例10: vectoriser

FTOutlineGlyph::FTOutlineGlyph( FT_GlyphSlot glyph, bool useDisplayList)
:   FTGlyph( glyph),
    glList(0)
{
  if( ft_glyph_format_outline != glyph->format)
  {
    err = 0x14; // Invalid_Outline
    return;
  }

  FTVectoriser vectoriser( glyph);

  size_t numContours = vectoriser.ContourCount();
  if ( ( numContours < 1) || ( vectoriser.PointCount() < 3))
  {
    return;
  }

  if(useDisplayList)
  {
    // Check if we are out of display lists
    if (glList == 0)
    {
      useDisplayList = false;
    }
    else
      glNewList( glList, GL_COMPILE);
  }

  for( unsigned int c = 0; c < numContours; ++c)
  {
    const FTContour* contour = vectoriser.Contour(c);

    glBegin( GL_LINE_LOOP);
    for( unsigned int pointIndex = 0; pointIndex < contour->PointCount(); ++pointIndex)
    {
      FTPoint point = contour->Point(pointIndex);
      glVertex2f( point.X() / 64.0f, point.Y() / 64.0f);
    }
    glEnd();
  }

  if(useDisplayList)
  {
    glEndList();
  }
}
开发者ID:f2re,项目名称:diana_mod,代码行数:47,代码来源:FTOutlineGlyph.cpp

示例11: controlPoint

FTContour::FTContour( FT_Vector* contour, char* pointTags, unsigned int numberOfPoints)
{
    for( unsigned int pointIndex = 0; pointIndex < numberOfPoints; ++ pointIndex)
    {
        char pointTag = pointTags[pointIndex];
        
        if( pointTag == FT_Curve_Tag_On || numberOfPoints < 2)
        {
            AddPoint( contour[pointIndex].x, contour[pointIndex].y);
            continue;
        }
        
        FTPoint controlPoint( contour[pointIndex]);
        FTPoint previousPoint = ( 0 == pointIndex)
                                ? FTPoint( contour[numberOfPoints - 1])
                                : pointList[pointList.size() - 1];

        FTPoint nextPoint = ( pointIndex == numberOfPoints - 1)
                            ? pointList[0]
                            : FTPoint( contour[pointIndex + 1]);

        if( pointTag == FT_Curve_Tag_Conic)
        {
            char nextPointTag = ( pointIndex == numberOfPoints - 1)
                                ? pointTags[0]
                                : pointTags[pointIndex + 1];
            
            while( nextPointTag == FT_Curve_Tag_Conic)
            {
                nextPoint = ( controlPoint + nextPoint) * 0.5f;

                controlPoints[0][0] = previousPoint.X(); controlPoints[0][1] = previousPoint.Y();
                controlPoints[1][0] = controlPoint.X();  controlPoints[1][1] = controlPoint.Y();
                controlPoints[2][0] = nextPoint.X();     controlPoints[2][1] = nextPoint.Y();
                
                evaluateQuadraticCurve();
                ++pointIndex;
                
                previousPoint = nextPoint;
                controlPoint = FTPoint( contour[pointIndex]);
                nextPoint = ( pointIndex == numberOfPoints - 1)
                            ? pointList[0]
                            : FTPoint( contour[pointIndex + 1]);
                nextPointTag = ( pointIndex == numberOfPoints - 1)
                               ? pointTags[0]
                               : pointTags[pointIndex + 1];
            }
            
            controlPoints[0][0] = previousPoint.X(); controlPoints[0][1] = previousPoint.Y();
            controlPoints[1][0] = controlPoint.X();  controlPoints[1][1] = controlPoint.Y();
            controlPoints[2][0] = nextPoint.X();     controlPoints[2][1] = nextPoint.Y();
            
            evaluateQuadraticCurve();
            continue;
        }

        if( pointTag == FT_Curve_Tag_Cubic)
        {
            FTPoint controlPoint2 = nextPoint;
            
            FTPoint nextPoint = ( pointIndex == numberOfPoints - 2)
                                ? pointList[0]
                                : FTPoint( contour[pointIndex + 2]);
            
            controlPoints[0][0] = previousPoint.X(); controlPoints[0][1] = previousPoint.Y();
            controlPoints[1][0] = controlPoint.X();  controlPoints[1][1] = controlPoint.Y();
            controlPoints[2][0] = controlPoint2.X(); controlPoints[2][1] = controlPoint2.Y();
            controlPoints[3][0] = nextPoint.X();     controlPoints[3][1] = nextPoint.Y();
        
            evaluateCubicCurve();
            ++pointIndex;
            continue;
        }
    }
}
开发者ID:OpenXIP,项目名称:xip-libraries,代码行数:75,代码来源:FTContour.cpp

示例12: ProcessContours

void FTVectoriser::ProcessContours()
{
    short contourLength = 0;
    short startIndex = 0;
    short endIndex = 0;

    contourList = new FTContour*[ftContourCount];

    for(int i = 0; i < ftContourCount; ++i)
    {
        FT_Vector* pointList = &outline.points[startIndex];
        char* tagList = &outline.tags[startIndex];

        endIndex = outline.contours[i];
        contourLength =  (endIndex - startIndex) + 1;

        FTContour* contour = new FTContour(pointList, tagList, contourLength);

        contourList[i] = contour;

        startIndex = endIndex + 1;
    }

    // Compute each contour's parity. FIXME: see if FT_Outline_Get_Orientation
    // can do it for us.
    for(int i = 0; i < ftContourCount; i++)
    {
        FTContour *c1 = contourList[i];

        // 1. Find the leftmost point.
        FTPoint leftmost(65536.0, 0.0);

        for(size_t n = 0; n < c1->PointCount(); n++)
        {
            FTPoint p = c1->Point(n);
            if(p.X() < leftmost.X())
            {
                leftmost = p;
            }
        }

        // 2. Count how many other contours we cross when going further to
        // the left.
        int parity = 0;

        for(int j = 0; j < ftContourCount; j++)
        {
            if(j == i)
            {
                continue;
            }

            FTContour *c2 = contourList[j];

            for(size_t n = 0; n < c2->PointCount(); n++)
            {
                FTPoint p1 = c2->Point(n);
                FTPoint p2 = c2->Point((n + 1) % c2->PointCount());

                /* FIXME: combinations of >= > <= and < do not seem stable */
                if((p1.Y() < leftmost.Y() && p2.Y() < leftmost.Y())
                    || (p1.Y() >= leftmost.Y() && p2.Y() >= leftmost.Y())
                    || (p1.X() > leftmost.X() && p2.X() > leftmost.X()))
                {
                    continue;
                }
                else if(p1.X() < leftmost.X() && p2.X() < leftmost.X())
                {
                    parity++;
                }
                else
                {
                    FTPoint a = p1 - leftmost;
                    FTPoint b = p2 - leftmost;
                    if(b.X() * a.Y() > b.Y() * a.X())
                    {
                        parity++;
                    }
                }
            }
        }

        // 3. Make sure the glyph has the proper parity.
        c1->SetParity(parity);
    }
}
开发者ID:AbdelghaniDr,项目名称:mirror,代码行数:86,代码来源:FTVectoriser.cpp

示例13: vectoriser

FTExtrdGlyph::FTExtrdGlyph( FT_GlyphSlot glyph, float depth, bool useDisplayList)
    :   FTGlyph( glyph),
        glList(0)
{
    bBox.SetDepth( -depth);

    if( ft_glyph_format_outline != glyph->format)
    {
        err = 0x14; // Invalid_Outline
        return;
    }

    FTVectoriser vectoriser( glyph);
    if( ( vectoriser.ContourCount() < 1) || ( vectoriser.PointCount() < 3))
    {
        return;
    }

    unsigned int tesselationIndex;

    if(useDisplayList)
    {
        glList = glGenLists(1);
        glNewList( glList, GL_COMPILE);
    }

    vectoriser.MakeMesh( 1.0);
    glNormal3d(0.0, 0.0, 1.0);

    unsigned int horizontalTextureScale = glyph->face->size->metrics.x_ppem * 64;
    unsigned int verticalTextureScale = glyph->face->size->metrics.y_ppem * 64;

    const FTMesh* mesh = vectoriser.GetMesh();
    for( tesselationIndex = 0; tesselationIndex < mesh->TesselationCount(); ++tesselationIndex)
    {
        const FTTesselation* subMesh = mesh->Tesselation( tesselationIndex);
        unsigned int polyonType = subMesh->PolygonType();

        glBegin( polyonType);
        for( unsigned int pointIndex = 0; pointIndex < subMesh->PointCount(); ++pointIndex)
        {
            FTPoint point = subMesh->Point(pointIndex);

            glTexCoord2f( point.X() / horizontalTextureScale,
                          point.Y() / verticalTextureScale);

            glVertex3f( point.X() / 64.0f,
                        point.Y() / 64.0f,
                        0.0f);
        }
        glEnd();
    }

    vectoriser.MakeMesh( -1.0);
    glNormal3d(0.0, 0.0, -1.0);

    mesh = vectoriser.GetMesh();
    for( tesselationIndex = 0; tesselationIndex < mesh->TesselationCount(); ++tesselationIndex)
    {
        const FTTesselation* subMesh = mesh->Tesselation( tesselationIndex);
        unsigned int polyonType = subMesh->PolygonType();

        glBegin( polyonType);
        for( unsigned int pointIndex = 0; pointIndex < subMesh->PointCount(); ++pointIndex)
        {
            FTPoint point = subMesh->Point(pointIndex);

            glTexCoord2f( subMesh->Point(pointIndex).X() / horizontalTextureScale,
                          subMesh->Point(pointIndex).Y() / verticalTextureScale);

            glVertex3f( subMesh->Point( pointIndex).X() / 64.0f,
                        subMesh->Point( pointIndex).Y() / 64.0f,
                        -depth);
        }
        glEnd();
    }

    int contourFlag = vectoriser.ContourFlag();

    for( size_t c = 0; c < vectoriser.ContourCount(); ++c)
    {
        const FTContour* contour = vectoriser.Contour(c);
        unsigned int numberOfPoints = contour->PointCount();

        glBegin( GL_QUAD_STRIP);
        for( unsigned int j = 0; j <= numberOfPoints; ++j)
        {
            unsigned int pointIndex = ( j == numberOfPoints) ? 0 : j;
            unsigned int nextPointIndex = ( pointIndex == numberOfPoints - 1) ? 0 : pointIndex + 1;

            FTPoint point = contour->Point(pointIndex);

            FTPoint normal = GetNormal( point, contour->Point(nextPointIndex));
            if(normal != FTPoint( 0.0f, 0.0f, 0.0f))
            {
                glNormal3dv(static_cast<const FTGL_DOUBLE*>(normal));
            }

            if( contourFlag & ft_outline_reverse_fill)
            {
//.........这里部分代码省略.........
开发者ID:bowlofstew,项目名称:Aquaria,代码行数:101,代码来源:FTExtrdGlyph.cpp

示例14: WrapTextI

inline void FTSimpleLayoutImpl::WrapTextI(const T *buf, const int len,
                                          FTPoint position, int renderMode,
                                          FTBBox *bounds)
{
    FTUnicodeStringItr<T> breakItr(buf);          // points to the last break character
    FTUnicodeStringItr<T> lineStart(buf);         // points to the line start
    float nextStart = 0.0;     // total width of the current line
    float breakWidth = 0.0;    // width of the line up to the last word break
    float currentWidth = 0.0;  // width of all characters on the current line
    float prevWidth;           // width of all characters but the current glyph
    float wordLength = 0.0;    // length of the block since the last break char
    int charCount = 0;         // number of characters so far on the line
    int breakCharCount = 0;    // number of characters before the breakItr
    float glyphWidth, advance;
    FTBBox glyphBounds;
	bool refresh = false;
	
    // Reset the pen position
    pen.Y(0);
	
    // If we have bounds mark them invalid
    if(bounds)
    {
		bounds->Invalidate();
    }
	//XLOGXN("FTGL1");
	// Check if the incoming string is different to the previously
	// cached string.
	unsigned int i = 0;
	for (FTUnicodeStringItr<T> itr(buf); *itr; itr++)
	{
		XBREAK(i >= 4096);
		if (i >= stringCacheCount ||
			stringCache[i++] != (unsigned int)*itr)
		{
			refresh = true;
			break;
		}
	}
	
	//XLOGXN("FTGL2");
	if (refresh)
	{
		//XLOGXN("FTGL3");
		stringCacheCount = 0;
        layoutGlyphCache.clear();
		
		// Scan the input for all characters that need output
		FTUnicodeStringItr<T> prevItr(buf);
		for (FTUnicodeStringItr<T> itr(buf); *itr; prevItr = itr++, charCount++)
		{
			XBREAK(stringCacheCount >= 4096);
			stringCache[stringCacheCount++] = (unsigned int)*itr;
			
			// Find the width of the current glyph
			glyphBounds = currentFont->BBox(itr.getBufferFromHere(), 1);
			glyphWidth = glyphBounds.Upper().Xf() - glyphBounds.Lower().Xf();
			
			advance = currentFont->Advance(itr.getBufferFromHere(), 1);
			prevWidth = currentWidth;
			// Compute the width of all glyphs up to the end of buf[i]
			currentWidth = nextStart + glyphWidth;
			// Compute the position of the next glyph
			nextStart += advance;
			
			// See if the current character is a space, a break or a regular character
			if((currentWidth > lineLength) || (*itr == '\n'))
			{
				// A non whitespace character has exceeded the line length.  Or a
				// newline character has forced a line break.  Output the last
				// line and start a new line after the break character.
				// If we have not yet found a break, break on the last character
				if(breakItr == lineStart || (*itr == '\n'))
				{
					// Break on the previous character
					breakItr = prevItr;
					breakCharCount = charCount - 1;
					breakWidth = prevWidth;
					// None of the previous words will be carried to the next line
					wordLength = 0;
					// If the current character is a newline discard its advance
					if(*itr == '\n') advance = 0;
				}
				
				float remainingWidth = lineLength - breakWidth;
				
				// Render the current substring
				FTUnicodeStringItr<T> breakChar = breakItr;
				// move past the break character and don't count it on the next line either
				++breakChar; --charCount;
				// If the break character is a newline do not render it
				if(*breakChar == '\n')
				{
					++breakChar; --charCount;
				}
				
				layoutGlyphCacheItem_t cacheItem;
				cacheItem.buf = (T*)lineStart.getBufferFromHere();
				cacheItem.charCount = breakCharCount;
				cacheItem.position = FTPoint(position.X(), position.Y(), position.Z());
//.........这里部分代码省略.........
开发者ID:xahgo,项目名称:tama,代码行数:101,代码来源:FTSimpleLayout.cpp


注:本文中的FTPoint::X方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。