public void addPoint(CGPoint location,float w){
  w=w * 0.5f;
  if (!pastFirstPoint_) {
    lastWidth_=w;
    lastLocation_=location;
    pastFirstPoint_=true;
    return;
  }
  CGPoint sub=CGPoint.ccpSub(lastLocation_,location);
  float r=CGPoint.ccpToAngle(sub) + (float)Math.PI * 2;
  CGPoint p1=CGPoint.ccpAdd(rotatePoint(CGPoint.ccp(-w,0),r),location);
  CGPoint p2=CGPoint.ccpAdd(rotatePoint(CGPoint.ccp(w,0),r),location);
  float len=(float)Math.sqrt((float)Math.pow(lastLocation_.x - location.x,2) + (float)Math.pow(lastLocation_.y - location.y,2));
  float tend=texVPos_ + len / textureLength_;
  CCRibbonSegment seg;
  seg=segments_.get(segments_.size() - 1);
  for (  CCRibbonSegment seg2 : segments_) {
    if (seg2 != seg && seg2.finished) {
      deletedSegments_.add(seg2);
    }
  }
  segments_.removeAll(deletedSegments_);
  if (seg.end >= 50)   segments_.removeAll(deletedSegments_);
  seg=segments_.get(segments_.size() - 1);
  if (seg.end >= 50) {
    CCRibbonSegment newSeg;
    if (deletedSegments_.size() > 0) {
      newSeg=deletedSegments_.get(0);
      deletedSegments_.remove(newSeg);
      newSeg.reset();
    }
 else {
      newSeg=new CCRibbonSegment();
    }
    int v=(seg.end - 1) * 6;
    int c=(seg.end - 1) * 4;
    newSeg.verts[0]=seg.verts[v];
    newSeg.verts[1]=seg.verts[v + 1];
    newSeg.verts[2]=seg.verts[v + 2];
    newSeg.verts[3]=seg.verts[v + 3];
    newSeg.verts[4]=seg.verts[v + 4];
    newSeg.verts[5]=seg.verts[v + 5];
    newSeg.coords[0]=seg.coords[c];
    newSeg.coords[1]=seg.coords[c + 1];
    newSeg.coords[2]=seg.coords[c + 2];
    newSeg.coords[3]=seg.coords[c + 3];
    newSeg.end++;
    seg=newSeg;
    segments_.add(seg);
  }
  if (seg.end == 0) {
    CGPoint lp1=CGPoint.ccpAdd(rotatePoint(CGPoint.ccp(-lastWidth_,0),r),lastLocation_);
    CGPoint lp2=CGPoint.ccpAdd(rotatePoint(CGPoint.ccp(+lastWidth_,0),r),lastLocation_);
    seg.creationTime[0]=curTime_ - delta_;
    seg.verts[0]=lp1.x;
    seg.verts[1]=lp1.y;
    seg.verts[2]=0.0f;
    seg.verts[3]=lp2.x;
    seg.verts[4]=lp2.y;
    seg.verts[5]=0.0f;
    seg.coords[0]=0.0f;
    seg.coords[1]=texVPos_;
    seg.coords[2]=1.0f;
    seg.coords[3]=texVPos_;
    seg.end++;
  }
  int v=seg.end * 6;
  int c=seg.end * 4;
  seg.creationTime[seg.end]=curTime_;
  seg.verts[v]=p1.x;
  seg.verts[v + 1]=p1.y;
  seg.verts[v + 2]=0.0f;
  seg.verts[v + 3]=p2.x;
  seg.verts[v + 4]=p2.y;
  seg.verts[v + 5]=0.0f;
  seg.coords[c]=0.0f;
  seg.coords[c + 1]=tend;
  seg.coords[c + 2]=1.0f;
  seg.coords[c + 3]=tend;
  texVPos_=tend;
  lastLocation_=location;
  lastPoint1_=p1;
  lastPoint2_=p2;
  lastWidth_=w;
  seg.end++;
}

public void addPoint ( CGPoint location , float w ) { w = w * 0.5f ; if ( ! pastFirstPoint_ ) { lastWidth_ = w ; lastLocation_ = location ; pastFirstPoint_ = true ; return ; } CGPoint sub = CGPoint . ccpSub ( lastLocation_ , location ) ; float r = CGPoint . ccpToAngle ( sub ) + ( float ) Math . PI * 2 ; CGPoint p1 = CGPoint . ccpAdd ( rotatePoint ( CGPoint . ccp ( - w , 0 ) , r ) , location ) ; CGPoint p2 = CGPoint . ccpAdd ( rotatePoint ( CGPoint . ccp ( w , 0 ) , r ) , location ) ; float len = ( float ) Math . sqrt ( ( float ) Math . pow ( lastLocation_ . x - location . x , 2 ) + ( float ) Math . pow ( lastLocation_ . y - location . y , 2 ) ) ; float tend = texVPos_ + len / textureLength_ ; CCRibbonSegment seg ; seg = segments_ . get ( segments_ . size ( ) - 1 ) ; for ( CCRibbonSegment seg2 : segments_ ) { if ( seg2 != seg && seg2 . finished ) { deletedSegments_ . add ( seg2 ) ; } } segments_ . removeAll ( deletedSegments_ ) ; if ( seg . end >= 50 ) segments_ . removeAll ( deletedSegments_ ) ; seg = segments_ . get ( segments_ . size ( ) - 1 ) ; if ( seg . end >= 50 ) { CCRibbonSegment newSeg ; if ( deletedSegments_ . size ( ) > 0 ) { newSeg = deletedSegments_ . get ( 0 ) ; deletedSegments_ . remove ( newSeg ) ; newSeg . reset ( ) ; } else { newSeg = new CCRibbonSegment ( ) ; } int v = ( seg . end - 1 ) * 6 ; int c = ( seg . end - 1 ) * 4 ; newSeg . verts [ 0 ] = seg . verts [ v ] ; newSeg . verts [ 1 ] = seg . verts [ v + 1 ] ; newSeg . verts [ 2 ] = seg . verts [ v + 2 ] ; newSeg . verts [ 3 ] = seg . verts [ v + 3 ] ; newSeg . verts [ 4 ] = seg . verts [ v + 4 ] ; newSeg . verts [ 5 ] = seg . verts [ v + 5 ] ; newSeg . coords [ 0 ] = seg . coords [ c ] ; newSeg . coords [ 1 ] = seg . coords [ c + 1 ] ; newSeg . coords [ 2 ] = seg . coords [ c + 2 ] ; newSeg . coords [ 3 ] = seg . coords [ c + 3 ] ; newSeg . end ++ ; seg = newSeg ; segments_ . add ( seg ) ; } if ( seg . end == 0 ) { CGPoint lp1 = CGPoint . ccpAdd ( rotatePoint ( CGPoint . ccp ( - lastWidth_ , 0 ) , r ) , lastLocation_ ) ; CGPoint lp2 = CGPoint . ccpAdd ( rotatePoint ( CGPoint . ccp ( + lastWidth_ , 0 ) , r ) , lastLocation_ ) ; seg . creationTime [ 0 ] = curTime_ - delta_ ; seg . verts [ 0 ] = lp1 . x ; seg . verts [ 1 ] = lp1 . y ; seg . verts [ 2 ] = 0.0f ; seg . verts [ 3 ] = lp2 . x ; seg . verts [ 4 ] = lp2 . y ; seg . verts [ 5 ] = 0.0f ; seg . coords [ 0 ] = 0.0f ; seg . coords [ 1 ] = texVPos_ ; seg . coords [ 2 ] = 1.0f ; seg . coords [ 3 ] = texVPos_ ; seg . end ++ ; } int v = seg . end * 6 ; int c = seg . end * 4 ; seg . creationTime [ seg . end ] = curTime_ ; seg . verts [ v ] = p1 . x ; seg . verts [ v + 1 ] = p1 . y ; seg . verts [ v + 2 ] = 0.0f ; seg . verts [ v + 3 ] = p2 . x ; seg . verts [ v + 4 ] = p2 . y ; seg . verts [ v + 5 ] = 0.0f ; seg . coords [ c ] = 0.0f ; seg . coords [ c + 1 ] = tend ; seg . coords [ c + 2 ] = 1.0f ; seg . coords [ c + 3 ] = tend ; texVPos_ = tend ; lastLocation_ = location ; lastPoint1_ = p1 ; lastPoint2_ = p2 ; lastWidth_ = w ; seg . end ++ ; }
add a point to the ribbon
