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


C++ Path2d::close方法代码示例

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


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

示例1: rect

    void CanvasContext::rect(float x, float y, float w, float h)
    {
        Path2d p;
        p.moveTo(x, y);
        p.lineTo(x, y + h);
        p.lineTo(x + w, y + h);
        p.lineTo(x + w, y);
        p.close();

        paths.push_back(p);
    }
开发者ID:caivega,项目名称:Mural,代码行数:11,代码来源:CanvasContext.cpp

示例2: draw

void Wall::draw()
{
	float pointsPerMeter = SceneController::getPointsPerMeter();
	auto pos = pointsPerMeter * mBody->GetPosition();

	Rectf wallRect( pos.x - mWidth, 0, pos.x + mWidth, app::getWindowHeight() );

	Path2d vibrationPath;
	vibrationPath.moveTo( wallRect.getUpperRight() );

	// right vibrating wall
	{
		Vec2f controlPoint1( wallRect.x2 + mVibrationLevel, wallRect.y1 + wallRect.getHeight() / 3.0f );
		Vec2f controlPoint2( wallRect.x2 + mVibrationLevel, wallRect.y1 + wallRect.getHeight() * 2.0f / 3.0f );
		vibrationPath.curveTo( controlPoint1, controlPoint2, wallRect.getLowerRight() );
	}

	vibrationPath.lineTo( wallRect.getLowerLeft() );

	// left vibrating wall
	{
		Vec2f controlPoint1( wallRect.x1 - mVibrationLevel, wallRect.y1 + wallRect.getHeight() * 2.0f / 3.0f );
		Vec2f controlPoint2( wallRect.x1 - mVibrationLevel, wallRect.y1 + wallRect.getHeight() / 3.0f );
		vibrationPath.curveTo( controlPoint1, controlPoint2, wallRect.getUpperLeft() );
	}

	vibrationPath.close();

	ColorA vibrationColor = ColorA::gray( 0.2f, 0.6f );
	vibrationColor.g += mVibrationLevel * 0.01f;
	vibrationColor.b += mVibrationLevel * 0.03f;

	gl::color( vibrationColor );
	gl::drawSolid( vibrationPath );

	ColorA wallColor = ColorA::gray( 0.2f, 1.0f );
	wallColor.g += mVibrationLevel * 0.01f;
	wallColor.b += mVibrationLevel * 0.015f;

	gl::color( wallColor );
	gl::drawSolidRect( wallRect );
}
开发者ID:CinimodStudio,项目名称:Cinder,代码行数:42,代码来源:SceneObjects.cpp

示例3: draw

void SeaFloor:: draw(){
    
    float globalOpacityMod = 1.0f;
    
    globalOpacityMod = (offset.y + 1000) * 0.002f;
    if( globalOpacityMod >= 1.0f ) globalOpacityMod = 1.0f;

    for(int n = 0; n < rows.size(); n++){
        Path2d path;
        path.moveTo( paths.at(n).at(0) );
        for(int i = 1; i < paths.at(n).size(); i++ )
            path.lineTo( paths.at(n).at(i) );
        path.lineTo( vec2( cinder::app::getWindowWidth(), cinder::app::getWindowHeight()) );
        path.lineTo( vec2( 0.0, cinder::app::getWindowHeight() ) );
        path.close();
        gl::color(ColorA8u(192,177,139, rows.at(n)->depth * 30.0f * globalOpacityMod ) );
        gl::drawSolid(path);
        gl::draw(path);
    }
}
开发者ID:amputek,项目名称:CELL,代码行数:20,代码来源:SeaFloor.cpp

示例4: draw

void SeaSurface:: draw(){

    float globalOpacityMod = 1.0f;
    
    globalOpacityMod = -(offset.y + 6000) * 0.002f;
    if( globalOpacityMod >= 1.0f ) globalOpacityMod = 1.0f;
    
    for(int n = 0; n < rows.size(); n++){
        Path2d path;
        path.moveTo( paths.at(n).at(0) );
        for(int i = 1; i < paths.at(n).size(); i++ )
            path.lineTo( paths.at(n).at(i) );
        path.lineTo( vec2( cinder::app::getWindowWidth(), 0.0 ) );
        path.lineTo( vec2( 0.0, 0.0 ) );
        path.close();
        gl::color(ColorA8u(237,160, 135, rows.at(n)->depth * 20.0f * globalOpacityMod ) );
        gl::drawSolid(path);
        gl::draw(path);
    }
}
开发者ID:amputek,项目名称:CELL,代码行数:20,代码来源:SeaSurface.cpp

示例5: makeBumpers

void Island::makeBumpers()
{
	CI_ASSERT( mOuterVerts.size() == 6 && mInnerVerts.size() == 5 );

	mBumpers.clear();
	mBumperBoundingBoxes.clear();
	mBumperVibrationLevels.clear();

	const float padding = 4;
	const float crookedPaddingPercent = 0.036f;
	const float boundingBoxExpansion = 1.1f;

	// left base
	{
		Path2d bumper;
		bumper.moveTo( mOuterVerts[0] );
		bumper.lineTo( mOuterVerts[1].x, mOuterVerts[1].y + padding );
		bumper.lineTo( mInnerVerts[1].x, mInnerVerts[1].y + padding );
		bumper.lineTo( mInnerVerts[0] );
		bumper.close();
		mBumpers.push_back( bumper );
	}

	// left top
	{
		Vec2f offsetOuter = ( mOuterVerts[2] - mOuterVerts[1] ) * crookedPaddingPercent;
		Vec2f offsetInner = ( Vec2f( mOuterVerts[2].x, mInnerVerts[2].y ) - mInnerVerts[1] ) * crookedPaddingPercent;

		Path2d bumper;
		bumper.moveTo( mOuterVerts[1] + offsetOuter );
		bumper.lineTo( mOuterVerts[2] );
		bumper.lineTo( mOuterVerts[2].x, mInnerVerts[2].y );
		bumper.lineTo( mInnerVerts[1] + offsetInner );
		bumper.close();
		mBumpers.push_back( bumper );
	}

	// right top
	{
		Vec2f offsetOuter = ( mOuterVerts[3] - mOuterVerts[4] ) * crookedPaddingPercent;
		Vec2f offsetInner = ( Vec2f( mOuterVerts[3].x, mInnerVerts[2].y ) - mInnerVerts[3] ) * crookedPaddingPercent;

		Path2d bumper;
		bumper.moveTo( mOuterVerts[3] );
		bumper.lineTo( mOuterVerts[4] + offsetOuter );
		bumper.lineTo( mInnerVerts[3] + offsetInner );
		bumper.lineTo( mOuterVerts[3].x, mInnerVerts[2].y );
		bumper.close();
		mBumpers.push_back( bumper );
	}

	// right base
	{
		Path2d bumper;
		bumper.moveTo( mOuterVerts[4].x, mOuterVerts[4].y + padding );
		bumper.lineTo( mOuterVerts[5] );
		bumper.lineTo( mInnerVerts[4] );
		bumper.lineTo( mInnerVerts[3].x, mInnerVerts[3].y + padding );
		bumper.close();
		mBumpers.push_back( bumper );
	}

	for( size_t i = 0; i < mBumpers.size(); i++ ) {
		mBumperVibrationLevels.push_back( 0 );

		// calculate an expanded bounding box for each bumper to do hit detection, ensuring that the entire edge is covered.
		Rectf bbox = mBumpers[i].calcBoundingBox();

		Vec2f center = bbox.getCenter();
		bbox -= center;
		bbox *= boundingBoxExpansion;
		bbox += center;

		mBumperBoundingBoxes.push_back( bbox );
	}
}
开发者ID:CinimodStudio,项目名称:Cinder,代码行数:76,代码来源:SceneObjects.cpp

示例6: draw

void Ribbon::draw()
{
	Vec2i	normPos1, normPos2;
	normPos1 = Vec2f::zero();
	normPos2 = Vec2f::zero();
	
	for(list<RibbonParticle *>::iterator p = mParticles.begin(); p != mParticles.end(); ++p){
		
		int x1 = (*p)->mPos.x - (*p)->mVel.x;
		int x2 = (*p)->mPos.x;
		int y1 = (*p)->mPos.y - (*p)->mVel.y;
		int y2 = (*p)->mPos.y;
		
		// Capture the previous normal positions
		Vec2i prevNormPos1(normPos1);
		Vec2i prevNormPos2(normPos2);
		
		// If this is the first segment, make the normals the 
		// same as the position (we want it to taper in)		
		if(prevNormPos1 == Vec2i::zero() &&
		   prevNormPos2 == Vec2i::zero()){
			
			normPos1 = Vec2i(x1, y1);
			normPos2 = Vec2i(x2, y2);
			
			prevNormPos1 = normPos1;
			prevNormPos2 = normPos2;
			
		}else{
			
			int normX1 = (*p)->mPos.x - ((*p)->mVelNormal.x * 0.5);
			int normX2 = (*p)->mPos.x + ((*p)->mVelNormal.x * 0.5);
			int normY1 = (*p)->mPos.y - ((*p)->mVelNormal.y * 0.5);
			int normY2 = (*p)->mPos.y + ((*p)->mVelNormal.y * 0.5);
			normPos1 = Vec2i(normX1,normY1);
			normPos2 = Vec2i(normX2,normY2);			
			
		}
		
		// Draw the shape between the normals
		Path2d path;		
		path.moveTo(prevNormPos1.x, prevNormPos1.y);
		path.lineTo(normPos1.x, normPos1.y);
		path.lineTo(normPos2.x, normPos2.y);
		path.lineTo(prevNormPos2.x, prevNormPos2.y);
		path.close();
		
		//		float value = ((*p)->mAge / 200.0);
		
		// Draw the filled ribbon
        // Defaults to yellow
        float red = 1.0;
        float green = 1.0;
        float blue = 0.5;
        if(mAgeConnectedAt > 0){
            int lastConnected = mAge - mAgeConnectedAt;
            if(lastConnected < 20){
				if(mCapturedGoal){
					red = lastConnected * 0.05;
				}else{
					green = lastConnected * 0.05;
				}
				blue = lastConnected * 0.025;
            }
        }
		gl::color(Color(red,green,blue));
		gl::drawSolid(path);
		
        /*
		 // Draw the surface normal
		 gl::color(Color(1.0-value,0,0));
		 gl::drawLine(normPos1, normPos2);
		 
		 // Draw a line indicating it's position w/ velocity
		 gl::color(Color::black());
		 gl::drawLine(Vec2i(x1,y1), Vec2i(x2, y2));		
		 */
		
	}
}
开发者ID:wdlindmeier,项目名称:Kinect-Ribbons,代码行数:80,代码来源:Ribbon.cpp

示例7: draw

void GesichtertauschApp::draw() {
    
    glClearColor( 0, 0, 0, 1.0 );
    glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
    
    if ( ! mCameraTexture ) {
        return;
    }
        
//    gl::setMatricesWindow( getWindowSize() ),
    gl::setMatricesWindow(WINDOW_WIDTH, WINDOW_HEIGHT);
    gl::enableAlphaBlending();
    glScalef(-1.0, 1.0, 1.0);
    glTranslatef(-WINDOW_WIDTH, 0, 0);
    
    /* shader */
    // TODO make this more opt'd
    if (ENABLE_SHADER) {
        mShader.bind();
        const int STEPS = 32;
        float mThresholds[STEPS];// = {0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0};
        for (int i=0; i < STEPS; ++i) {
            mThresholds[i] = float(i) / float(STEPS - 1);
        }
        mShader.uniform("thresholds", mThresholds, STEPS);   
        mShader.uniform( "tex0", 0 );
    }

    /* draw the webcam image */
    gl::color( BACKGROUND_IMAGE_COLOR );
    gl::draw( mCameraTexture, Rectf(0, 0, WINDOW_WIDTH, WINDOW_HEIGHT) );
    mCameraTexture.disable();
    
    /* normalize texture coordinates */
    Vec2f mNormalizeScale = Vec2f(1.0 / float(WINDOW_WIDTH), 1.0 / float(WINDOW_HEIGHT));
    glMatrixMode(GL_TEXTURE);
    glPushMatrix();
    glScalef(mNormalizeScale.x, mNormalizeScale.y, 1.0);
    glMatrixMode(GL_MODELVIEW);
    
    /* draw orgiginal faces */
    if (mEntities.size() < 2) {
        gl::enableAlphaBlending();
        mCameraTexture.enableAndBind();
        for( vector<FaceEntity>::const_iterator mIter = mEntities.begin(); mIter != mEntities.end(); ++mIter ) {
            drawEntity(*mIter, FACE_COLOR_UNO);
        }    
        mCameraTexture.disable();
        gl::disableAlphaBlending();
    }
    
    /* HACK // swap faces */
    mCameraTexture.enableAndBind();
    if (mEntities.size() >= 2) {
        const FaceEntity A = mEntities[0];
        const FaceEntity B = mEntities[1];
        if (A.visible && B.visible) {
            FaceEntity mEntityA = FaceEntity();
            FaceEntity mEntityB = FaceEntity();
            
            mEntityA.border = B.border;
            mEntityB.border = A.border;
            mEntityA.slice = A.slice;
            mEntityB.slice = B.slice;
            mEntityA.visible = A.visible;
            mEntityB.visible = B.visible;
            mEntityA.ID = A.ID;
            mEntityB.ID = B.ID;
            
            drawEntity(mEntityA, FACE_COLOR_DUO);
            drawEntity(mEntityB, FACE_COLOR_DUO);
        }
    }

    /* restore texture coordinates */
    glMatrixMode(GL_TEXTURE);
    glPopMatrix();
    glMatrixMode(GL_MODELVIEW);

    mCameraTexture.disable();

    /* shader */
    if (ENABLE_SHADER) {
        mShader.unbind();
    }

    /* mask */
    float MASK_LEFT_TOP = 1;
    float MASK_LEFT_BOTTOM = 1;
    float MASK_RIGHT_TOP = 1;
    float MASK_RIGHT_BOTTOM = 1;
    
    gl::color(0, 0, 0, 1);

    Path2d mPathLeft;
    mPathLeft.moveTo(0, 0);
    mPathLeft.lineTo(MASK_LEFT_TOP, 0);
    mPathLeft.lineTo(MASK_LEFT_BOTTOM, WINDOW_HEIGHT);
    mPathLeft.lineTo(0, WINDOW_HEIGHT);
    mPathLeft.close();    
//.........这里部分代码省略.........
开发者ID:TheProduct,项目名称:Gesichtertausch,代码行数:101,代码来源:GesichtertauschApp.cpp

示例8: randFloat

void Path2DSamplesApp::setup()
{
	
	// lineTo
	path1.moveTo( vec2( 0.0, 0.0 ) );
	path1.lineTo( vec2( 100.0, 100.0 ) );
	path1.lineTo( vec2( 200.0, 0.0 ) );
	path1.lineTo( vec2( 300.0, 100.0 ) );
	path1.lineTo( vec2( 400.0, 0.0 ) );
	
	// quadTo - waves
	float waveWidth = 100.0;
	path2.moveTo( vec2( 0.0, 50.0 ) );
	for( int i = 0; i < 5; i++ ) {
		float startX = i * waveWidth;
		path2.quadTo( vec2( startX, 0.0 ), vec2( startX + waveWidth / 2.0, 0.0 ) );
		path2.quadTo( vec2( startX + waveWidth / 2.0, 50.0 ), vec2( startX + waveWidth, 50.0 ) );
	}
	
	// curveTo
	path3.moveTo( vec2( 0 ) );
	path3.curveTo( vec2( 25.0, 0.0 ), vec2( 50.0, 25.0 ), vec2( 50.0, 50.0 ) );
	
	// arc & arcTo
//	path4.moveTo( zero<vec2>() );
//	path4.arc( vec2( 25.0, 25.0 ), 25.0, 0.0, glm::pi<float> );
	path4.arc( vec2( 25.0, 25.0 ), 25.0, 0.0, M_PI );
	
	
	path5.moveTo( vec2( 0.0, 0.0 ) );
	// end point, tangent position, radius
	path5.arcTo( vec2( 50.0, 50.0 ), vec2( 50.0, 0.0 ), 25.0 );
	
	// path for contains
	path6.moveTo( vec2( 0.0, 0.0 ) );
	path6.quadTo( vec2( 80.0, 30.0), vec2( 100, 50) );
	path6.quadTo( vec2( 180.0, 50.0), vec2( 210.0, 20.0) );
	path6.quadTo( vec2( 270.0, 10.0), vec2( 280.0, 100.0) );
	path6.quadTo( vec2( 200.0, 150.0), vec2( 140.0, 100.0) );
	path6.quadTo( vec2( 100.0, 150.0), vec2( 50.0, 80.0) );
	path6.close();
	
	// points to look for intersection
	for( int i = 0; i < 50; i++ ) {
		auto bounds = path6.calcBoundingBox();
		std::pair<vec2, vec2> pair;
		pair.first = vec2( randFloat( bounds.x1 , bounds.x2), randFloat( bounds.y1, bounds.y2 ) );
		pair.second = vec2( randFloat( -1, 1), randFloat( -1, 1) );
		intersectPts.push_back( pair );
	}
	
	
	// move over a bit and dot affine matrix copies and rotate
	{
		int amount = 10;
		
		for( int i = 0; i < amount; i++ ){
			MatrixAffine2<float> affineMtrx;
			affineMtrx.scale( 0.3 );
			affineMtrx.rotate( ( ( M_PI * 2) / 8 ) * i );
			auto pathCopy = path2.transformCopy( affineMtrx );
			pathCaches.emplace_back( pathCopy );
		}
	}

	
	
	// snowflake using 
	
	
}
开发者ID:gregkepler,项目名称:cinder-path2d-docs,代码行数:71,代码来源:Path2DSamplesApp.cpp


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