2012-01-19 3 views
2

코어 그래픽을 사용하여 고전적인 선 그래프를 생성하고 있습니다. enter image description here코어 그래픽이 포함 된 리본 그래프 (차트)

(나는 내가 위해 사용하고있는 코드를 게시 할 수 있습니다 : "layer.zPosition"

-(void)drawRect:(CGRect)rect { 



     float colorChange = (0.1 * [self tag]); 

     theFillColor = [UIColor colorWithRed:(colorChange) green:(colorChange*0.50) blue:colorChange alpha:0.75f].CGColor; 


     CGContextRef c = UIGraphicsGetCurrentContext(); 
     CGFloat white[4] = {1.0f, 1.0f, 1.0f, 1.0f};  
     CGContextSetFillColorWithColor(c, theFillColor); 
     CGContextSetStrokeColor(c, white); 
     CGContextSetLineWidth(c, 2.0f); 
     CGContextBeginPath(c); 
     // 
     CGContextMoveToPoint(c, 0.0f, 200-[[array objectAtIndex:0] floatValue]); 
     CGContextAddLineToPoint(c, 0.0f, 200-[[array objectAtIndex:0] floatValue]); 
     // 
     distancePerPoint = (rect.size.width/[array count]); 
     float lastPointX = 750.0; 
     for (int i = 0 ; i < [array count] ; i++) 
     { 


      CGContextAddLineToPoint(c, (i*distancePerPoint), 200-[[array objectAtIndex:i] floatValue]); 


      lastPointX = (i*distancePerPoint); 
     } 
     // 
     CGContextAddLineToPoint(c, lastPointX, 200.0); 
     CGContextAddLineToPoint(c, 0, 200); 
     CGContextClosePath(c); 
     // 
     //CGContextFillPath(c); 
     CGContextDrawPath(c, kCGPathFillStroke); 
     //CGContextDrawPath(c, kCGPathStroke); 

    } 

(위의 코드는 다음과 같은 결과를 생성하는)를 사용하여 차례로 쌓아 여러 줄이 있습니다 필요,하지만 난 그것을 할 방법이 CATransform3D rotationAndPerspectiveTransform = CATransform3DIdentity에 의해 일반적으로 경우 3D 효과)

질문 : 가 어떻게 TRAN 수 내 선 그래프에 깊이가 있는지 확인 하시겠습니까? I는 나중에 내가 그들 (위 언급 한 바와 같이) 회전과 관점이

enter image description here

답변

0
변환을 사용하여 표현하고자하는 (따라서 그들에게 리본을) 라인 (들) 그래프에 "깊이"를하고 싶습니다

CALayers는 "평면"이므로 종이 접기, 3D 공간에서 직사각형을 연결하여 3D 구조를 만들 수 있지만 임의의 다각형 3D 모양을 가질 수 없으므로 Core Graphics 또는 Core animation으로 쉽게 처리 할 수 ​​없습니다.

실제로 사실은 아니지만, CADhapeLayers를 사용하여 드로잉을 한 다음 3D로 조작 할 수는 있지만, 일반적으로 각 셰이프를 배치 할 위치를 계산하고 계산하는 것이 매우 힘들다고 생각합니다. 가장자리가 올바르게 정렬됩니다.

이런 종류의 3D 구조를 만드는 방법은 OpenGL을 직접 사용하는 것입니다.

로우 레벨 OpenGL 프로그래밍에 익숙하지 않다면 Galaxy Engine 또는 Cocos3D를 확인해보십시오.

+0

감사합니다. 귀하의 질문이 모두 동일하면 조금만 더 열어 둡니다. 나는 주변에 다른 방법이 있을지도 모른다는 느낌이 들었다. - 그래도 고마워, – chewy

관련 문제