KDvoid GestureShapeLayer::draw ( KDvoid )
{	
	// Set line width.
	ccLineWidth ( 4.0f );
	
	// Set point size
	ccPointSize ( 16 );
	
	// Set color to blue
	ccDrawColor4B ( 255, 0, 0, 255 );

	// We either draw a circle or a series of lines
	if ( m_bDrawCircle )
	{
		// Draw a circle using circleRect information
		ccDrawCircle ( m_tCircleRect.origin, m_tCircleRect.size.cx, 0.0f, 100, KD_FALSE );
	}
	else if ( m_bDrawLines )
	{
		// Draw all lines
		for ( KDuint i = 0; i < m_pLines->count ( ); i++ )
		{
			GestureLine*	pLine = (GestureLine*) m_pLines->objectAtIndex ( i );
			ccDrawLine ( pLine->getPoint1 ( ), pLine->getPoint2 ( ) );
		}
	}
		
	// Restore original values
	ccLineWidth ( 1 );	
	ccDrawColor4B ( 255, 255, 255, 255 );
	ccPointSize ( 1 );		
}
Ejemplo n.º 2
0
void RippleNode::draw()
{
    CCNodeRGBA::draw();
    
    ccGLBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    
    ccDrawInit();
    
    ccDrawColor4B(getColor().r, getColor().g, getColor().b, getOpacity());
    
    glLineWidth(3.f * SCREEN_SCALE());
    ccPointSize(3.f * SCREEN_SCALE() * 0.5f);
    
    Rig rig;
    rig.reserve(RIG_VERTEXES());
    for(int i = 0; i < RIG_VERTEXES(); i++)
    {
        CCPoint vertex = ccpRotateByAngle(CCPointMake(0, 200.f * SCREEN_SCALE()), CCPointZero, M_PI * 2 * i / RIG_VERTEXES() + getRotation());
        rig.push_back(vertex);
    }
    
    ccDrawPoly(&rig[0], rig.size(), true);
    
    ccDrawPoint(CCPointZero);
    
    ccDrawFree();
    
    ccGLBlendFunc(CC_BLEND_SRC, CC_BLEND_DST);
    
    CC_INCREMENT_GL_DRAWS(1);
}
Ejemplo n.º 3
0
 virtual void draw()
 {
     ccDrawColor4B(m_TouchColor.r, m_TouchColor.g, m_TouchColor.b, 255);
     glLineWidth(10);
     ccDrawLine( ccp(0, m_pTouchPoint.y), ccp(getContentSize().width, m_pTouchPoint.y) );
     ccDrawLine( ccp(m_pTouchPoint.x, 0), ccp(m_pTouchPoint.x, getContentSize().height) );
     glLineWidth(1);
     ccPointSize(30);
     ccDrawPoint(m_pTouchPoint);
 }
		virtual KDvoid	draw ( KDvoid )
		{
			ccDrawColor4B ( m_tTouchColor.r, m_tTouchColor.g, m_tTouchColor.b, 200 );
			ccLineWidth ( 10 );
			ccDrawLine	( ccp ( 0, m_tTouchPoint.y ), ccp ( getContentSize ( ).cx, m_tTouchPoint.y ) );
			ccDrawLine	( ccp ( m_tTouchPoint.x, 0 ), ccp ( m_tTouchPoint.x, getContentSize ( ).cy ) );
			glLineWidth	( 1 );
			ccPointSize ( 30 );
			ccDrawPoint ( m_tTouchPoint );
		}
Ejemplo n.º 5
0
void GestureScene::draw() {
	if(isOnTouch) {
		ccPointSize(15);  
		ccDrawColor4B(255, 255, 0, 64);  

		if(mPoints.size() > 0) {
			glLineWidth( 50.0f );
			ccDrawPoint(mPoints[0]);  
			for(int i=1; i<mPoints.size(); i++)
				ccDrawLine(mPoints[i-1], mPoints[i]);
		}
		
	}
}
Ejemplo n.º 6
0
void CCSkeleton::draw () {
	CC_NODE_DRAW_SETUP();

	ccGLBlendFunc(blendFunc.src, blendFunc.dst);
	ccColor3B color = getColor();
	skeleton->r = color.r / (float)255;
	skeleton->g = color.g / (float)255;
	skeleton->b = color.b / (float)255;
	skeleton->a = getOpacity() / (float)255;

	quadCount = 0;
	for (int i = 0, n = skeleton->slotCount; i < n; i++)
		if (skeleton->slots[i]->attachment) Attachment_draw(skeleton->slots[i]->attachment, skeleton->slots[i]);
	if (atlas) atlas->drawNumberOfQuads(quadCount);

	if (debugSlots) {
		// Slots.
		ccDrawColor4B(0, 0, 255, 255);
		glLineWidth(1);
		CCPoint points[4];
		for (int i = 0, n = skeleton->slotCount; i < n; i++) {
			if (!skeleton->slots[i]->attachment) continue;
			ccV3F_C4B_T2F_Quad* quad = &((Cocos2dxRegionAttachment*)skeleton->slots[i]->attachment)->quad;
			points[0] = ccp(quad->bl.vertices.x, quad->bl.vertices.y);
			points[1] = ccp(quad->br.vertices.x, quad->br.vertices.y);
			points[2] = ccp(quad->tr.vertices.x, quad->tr.vertices.y);
			points[3] = ccp(quad->tl.vertices.x, quad->tl.vertices.y);
			ccDrawPoly(points, 4, true);
		}
	}
	if (debugBones) {
		// Bone lengths.
		glLineWidth(2);
		ccDrawColor4B(255, 0, 0, 255);
		for (int i = 0, n = skeleton->boneCount; i < n; i++) {
			Bone *bone = skeleton->bones[i];
			float x = bone->data->length * bone->m00 + bone->worldX;
			float y = bone->data->length * bone->m10 + bone->worldY;
			ccDrawLine(ccp(bone->worldX, bone->worldY), ccp(x, y));
		}
		// Bone origins.
		ccPointSize(4);
		ccDrawColor4B(0, 0, 255, 255); // Root bone is blue.
		for (int i = 0, n = skeleton->boneCount; i < n; i++) {
			Bone *bone = skeleton->bones[i];
			ccDrawPoint(ccp(bone->worldX, bone->worldY));
			if (i == 0) ccDrawColor4B(0, 255, 0, 255);
		}
	}
}
void CtinyWingsTerrainSprite::drawWire(){
    vector<CCPoint>&pointList=m_pointMat[0];
    //draw segList
    {
        glLineWidth(2);
        ccPointSize(4);
        int nPoint=(int)pointList.size();
        int nSeg=nPoint-1;
        for(int i=0;i<nSeg;i++){
            CCPoint point=pointList[i];
            CCPoint pointn=pointList[i+1];
            ccDrawLine(point, pointn);
            ccDrawPoint(point);
            ccDrawPoint(pointn);
        }
    }
    
    //draw mesh
    {
        glLineWidth(2);
        int nRow=(int)m_pointMat.size();
        for(int i=0;i<nRow-1;i++){
            int nPoint=(int)m_pointMat[i].size();
            for(int j=0;j<nPoint-1;j++){
                const CCPoint&pLU=m_pointMat[i][j];
                const CCPoint&pLD=m_pointMat[i+1][j];
                const CCPoint&pRU=m_pointMat[i][j+1];
                const CCPoint&pRD=m_pointMat[i+1][j+1];
            
                ccDrawLine(pLU, pLD);
                ccDrawLine(pLD, pRD);
                ccDrawLine(pRD, pRU);
                ccDrawLine(pRU, pLU);
            }
        }
        
    }
    

    
    
}
Ejemplo n.º 8
0
void CCSkeleton::draw () {
	CC_NODE_DRAW_SETUP();

	ccGLBlendFunc(blendFunc.src, blendFunc.dst);
	ccColor3B color = getColor();
	skeleton->r = color.r / (float)255;
	skeleton->g = color.g / (float)255;
	skeleton->b = color.b / (float)255;
	skeleton->a = getOpacity() / (float)255;

	CCTextureAtlas* textureAtlas = 0;
	ccV3F_C4B_T2F_Quad quad;
	quad.tl.vertices.z = 0;
	quad.tr.vertices.z = 0;
	quad.bl.vertices.z = 0;
	quad.br.vertices.z = 0;
	for (int i = 0, n = skeleton->slotCount; i < n; i++) {
		Slot* slot = skeleton->slots[i];
		if (!slot->attachment || slot->attachment->type != ATTACHMENT_REGION) continue;
		RegionAttachment* attachment = (RegionAttachment*)slot->attachment;
		CCTextureAtlas* regionTextureAtlas = (CCTextureAtlas*)((AtlasRegion*)attachment->rendererObject)->page->rendererObject;
		if (regionTextureAtlas != textureAtlas) {
			if (textureAtlas) {
				textureAtlas->drawQuads();
				textureAtlas->removeAllQuads();
			}
		}
		textureAtlas = regionTextureAtlas;
		if (textureAtlas->getCapacity() == textureAtlas->getTotalQuads() &&
			!textureAtlas->resizeCapacity(textureAtlas->getCapacity() * 2)) return;
		RegionAttachment_updateQuad(attachment, slot, &quad);
		textureAtlas->updateQuad(&quad, textureAtlas->getTotalQuads());
	}
	if (textureAtlas) {
		textureAtlas->drawQuads();
		textureAtlas->removeAllQuads();
	}

	if (debugSlots) {
		// Slots.
		ccDrawColor4B(0, 0, 255, 255);
		glLineWidth(1);
		CCPoint points[4];
		ccV3F_C4B_T2F_Quad quad;
		for (int i = 0, n = skeleton->slotCount; i < n; i++) {
			Slot* slot = skeleton->slots[i];
			if (!slot->attachment || slot->attachment->type != ATTACHMENT_REGION) continue;
			RegionAttachment* attachment = (RegionAttachment*)slot->attachment;
			RegionAttachment_updateQuad(attachment, slot, &quad);
			points[0] = ccp(quad.bl.vertices.x, quad.bl.vertices.y);
			points[1] = ccp(quad.br.vertices.x, quad.br.vertices.y);
			points[2] = ccp(quad.tr.vertices.x, quad.tr.vertices.y);
			points[3] = ccp(quad.tl.vertices.x, quad.tl.vertices.y);
			ccDrawPoly(points, 4, true);
		}
	}
	if (debugBones) {
		// Bone lengths.
		glLineWidth(2);
		ccDrawColor4B(255, 0, 0, 255);
		for (int i = 0, n = skeleton->boneCount; i < n; i++) {
			Bone *bone = skeleton->bones[i];
			float x = bone->data->length * bone->m00 + bone->worldX;
			float y = bone->data->length * bone->m10 + bone->worldY;
			ccDrawLine(ccp(bone->worldX, bone->worldY), ccp(x, y));
		}
		// Bone origins.
		ccPointSize(4);
		ccDrawColor4B(0, 0, 255, 255); // Root bone is blue.
		for (int i = 0, n = skeleton->boneCount; i < n; i++) {
			Bone *bone = skeleton->bones[i];
			ccDrawPoint(ccp(bone->worldX, bone->worldY));
			if (i == 0) ccDrawColor4B(0, 255, 0, 255);
		}
	}
}
Ejemplo n.º 9
0
void CCDrawLineLayer::drawLine()
{
    
    for (int i=0; i<m_deleteCountOfTick ; i++) 
    {
        if (m_pointList.size() >0)
        {
            m_pointList.pop_front();
        }
        else 
        {
            break;
        }
    }
	while (m_pointList.size() > m_pointListKeepCount) 
    {
		m_pointList.pop_front();
	}
    
    
    if(m_isRandColor)
    {
        int  R = arc4random()%255;
        int  G = arc4random()%255;
        int  B = arc4random()%255;
        
        m_lineColor.r = R;
        m_lineColor.g = G;
        m_lineColor.b = B;
    }
    
    int pointListCount = m_pointList.size();
	std::list <CCPoint>::iterator it = m_pointList.begin();
    int pointIndex = 0;
	for(;it!=m_pointList.end();it++)
	{
        int maxPointIndex =  pointListCount * m_percentOfMaxPoint;
        
        int distanceToMiddle = pointIndex-maxPointIndex;
        
        float countPercent = 0;
        if(distanceToMiddle < 0)
        {
             distanceToMiddle = fabs(distanceToMiddle);
             countPercent = distanceToMiddle/(float)maxPointIndex;
        }
        else
        {
             countPercent = distanceToMiddle/(float)(pointListCount - maxPointIndex);
        }
       
        float percent = 1.0 - countPercent;
        float lintWidth = m_lineWidthMin + (m_lineWidthMax-m_lineWidthMin)*percent;
        int alpha = m_lineAlphaMin + (m_lineAlphaMax-m_lineAlphaMin)*percent;
        
        ccDrawColor4B(m_lineColor.r,m_lineColor.g,m_lineColor.b,alpha );
        ccPointSize(lintWidth);
        ccDrawPoint( *it );
        
        pointIndex++;
	}
}
Ejemplo n.º 10
0
//virtual 
void SpellDiagramNode::draw()
{
	CCNode::draw();

	float ptSz = 5;

	ccDrawInit();
	ccPointSize(ptSz);
	glLineWidth(ptSz);
	//ccDrawColor4B(0, 0, 256, 256);
	ccDrawColor4F(0.0f, 0.0f, 1.0f, 1.0f);
    //ccDrawLine(ccp(0,0), ccp(100, 100));

	Json::Value& lines = m_spellDiagrams[m_type]["lines"];
	for( int i=0; i< lines.size(); i++)
	{
		std::string type = lines[i].get("type", "circle").asString();
		if( type.compare("circle") == 0 ) {
			ccDrawCircle(ccp(0,0), size/2, 0, 32, false);
		}else if( type.compare("bezier") == 0 ) {
			Json::Value& pts = lines[i]["points"];
			ccDrawCubicBezier(ccp(size*pts[0u].asDouble(), size*pts[1].asDouble()), 
							ccp(size*pts[2].asDouble(), size*pts[3].asDouble()),
							ccp(size*pts[4].asDouble(), size*pts[5].asDouble()),
							ccp(size*pts[6].asDouble(), size*pts[7].asDouble()), 32);
		}else if( type.compare("line") == 0 ) {
			Json::Value& pts = lines[i]["points"];
			ccDrawLine(ccp(size*pts[0u].asDouble(), size*pts[1].asDouble()), 
							ccp(size*pts[2].asDouble(), size*pts[3].asDouble()) );
		}
	}


/*

	if( m_type == SD_08_FORTRESS )  {
		//square shape
		ccDrawLine(ccp(-size/2 - ptSz/2, size/2), ccp(size/2 + ptSz/2, size/2)); //top
		ccDrawLine(ccp(-size/2 - ptSz/2, -size/2), ccp(size/2 + ptSz/2, -size/2)); //btm

		ccDrawLine(ccp(size/2, size/2), ccp(size/2 , -size/2)); //right
		ccDrawLine(ccp(-size/2, size/2), ccp(-size/2 , -size/2)); //left
	}

	if( m_type == SD_06_LESSER_TRIQUESTRA || m_type == SD_11_LEAF || 
		m_type == SD_13_GREATER_TRIQUETRA ) 
	{
		float topY = tA.y;
		float botY = tB.y;
		float midY = 0;

		CCPoint lcp1 = ccp(size*0.1666, -size*0.2167);
		CCPoint lcp2 = ccp(size*0.3335, size*0.1233);
		ccDrawCubicBezier(tC, lcp1, lcp2, tA, 32); //left

		CCPoint rcp1 = ccp(-size*0.1666, -size*0.2167);
		CCPoint rcp2 = ccp(-size*0.3335, size*0.1233);
		ccDrawCubicBezier(tB, rcp1, rcp2, tA, 32); //right

		CCPoint bcp1 = ccp(-size*0.25, size*0.286);
		CCPoint bcp2 = ccp( size*0.25, size*0.286);
		ccDrawCubicBezier(tC, bcp1, bcp2, tB, 32); //bottom
	}

	if( m_type == SD_07_COMPASS || m_type == SD_03_ADEPTS_CIRCLE ) {
		ccDrawLine(ccp(0, size/2), ccp(0, -size/2)); 
	}

	if( m_type == SD_05_SERPENTS_EYE ) {
		//shorter verticle line for eye
		ccDrawLine( seT, seB);
	}

	if( m_type == SD_11_LEAF ) {
		//offset verticle line for leaf
		ccDrawLine(leT, leB);
	}

	if( m_type == SD_09_DRAGONS_EYE ) {
		//shorter eye
		CCPoint t = ccp(0, size*0.38);
		CCPoint b = ccp(0, -size*0.38);
		CCPoint rcp1 = ccp(size/3,size/5);
		CCPoint rcp2 = ccp(size/3,-size/5);
		ccDrawCubicBezier(t, rcp1, rcp2, b, 32);
		CCPoint lcp1 = ccp(-size/3,size/5);
		CCPoint lcp2 = ccp(-size/3,-size/5);
		ccDrawCubicBezier(t, lcp1, lcp2, b, 32);
	}

	if( m_type == SD_10_SEEING_EYE ) {
		//shorter eye
		ccDrawCubicBezier(ccp(-size/2, 0), ccp(-size/3, size/4), ccp(size/3,size/4), ccp(size/2,0), 32);
		ccDrawCubicBezier(ccp(-size/2, 0), ccp(-size/3, -size/4), ccp(size/3,-size/4), ccp(size/2,0), 32);
	}

	if( m_type == SD_07_COMPASS  ) {
		//horizontal line
		ccDrawLine(ccp(-size/2, 0), ccp(size/2, 0));
	}
	*/
}