2014년 11월 9일 일요일

아이폰 - 아이폰 - 쿼츠로 2D 그래픽 그리는 코드 입니다.

아이폰 - 쿼츠로 2D 그래픽 그리는 코드 입니다.
 조회 : 123
나의 폴더 > 아이폰 | 2012-12-13 (Thu) 14:50http://blog.dreamwiz.com/papasmf1/13911373
//
//  draw2D.h
//  DemoDraw2D
//
//  Created by JONG DUK KIM on 12. 12. 13..
//  Copyright (c) 2012 JONG DUK KIM. All rights reserved.
//

#import <UIKit/UIKit.h>
//0) 탭기반 애플리케이션 템플릿으로 DemoDraw2D라는 이름의 프로젝트를
//생성합니다.
//1)UIView 상속받은 draw2D 추가(xib없음)
// 새로운 파일을 프로젝트에 추가하면서 UIView를 상속받으면 됩니다.
//2)drawRect 재정의한다
@interface draw2D : UIView

@end

//
//  draw2D.m
//  DemoDraw2D
//
//  Created by JONG DUK KIM on 12. 12. 13..
//  Copyright (c) 2012 JONG DUK KIM. All rights reserved.
//

#import "draw2D.h"

@implementation draw2D

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
    }
    return self;
}


// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    //--------------------------
    //1) 직선 그리기 
    //뷰의 그래픽 컨텍스트 얻기 
    CGContextRef context = UIGraphicsGetCurrentContext();
    //그리기에 사용할 선의 두께
    CGContextSetLineWidth(context, 5.0);
    //색공간
    CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
    //불투명한 파란색
    CGFloat components[] = { 0.00.01.01.0};
    CGColorRef color = CGColorCreate(colorSpace, components);
    //선을 그리는데 사용할 색상을 지정 
    CGContextSetStrokeColorWithColor(context, color);
    //시작점으로 이동 
    CGContextMoveToPoint(context, 00);
    //여기까지 그린다
    CGContextAddLineToPoint(context, 300400);
    
    CGContextStrokePath(context);
    CGColorSpaceRelease(colorSpace);
    CGColorRelease(color);
     //--------------------------

}


@end


// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    //2) 경로 그리기
    //--------------------------
    CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextSetLineWidth(context, 5.0);
    //  쉽게 색상 구하는 코드
    CGContextSetStrokeColorWithColor(context, [UIColor blueColor].CGColor);
    CGContextMoveToPoint(context, 100100);
    CGContextAddLineToPoint(context, 150150);
    CGContextAddLineToPoint(context, 100200);
    CGContextAddLineToPoint(context, 50150);
    CGContextAddLineToPoint(context, 100100);
    CGContextStrokePath(context);
    //--------------------------

}


// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    
    //4)  그리기
    //--------------------------
    CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextSetLineWidth(context, 5.0);
    //  쉽게 색상 구하는 코드
    CGContextSetStrokeColorWithColor(context, [UIColor blueColor].CGColor);
    CGRect rectangle = CGRectMake(505020080);
    CGContextAddEllipseInRect(context, rectangle);
    CGContextStrokePath(context);
    //--------------------------
}

// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    //3) 사각형 그리기
    //--------------------------
    CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextSetLineWidth(context, 5.0);
    //  쉽게 색상 구하는 코드
    CGContextSetStrokeColorWithColor(context, [UIColor blueColor].CGColor);
    CGRect rectangle = CGRectMake(505020080);
    CGContextAddRect(context, rectangle);
    CGContextStrokePath(context);
    //--------------------------
    
}




댓글 없음:

댓글 쓰기

참고: 블로그의 회원만 댓글을 작성할 수 있습니다.

KBS 다큐 인사이트 - 인재전쟁 1부 공대에 미친 중국 - 영상입니다.

  지난주에 파이썬 수업을 하면서 미국 캘리포니아에 유학중인 여학생이 한번 입과를 했습니다. 중국에 대해서 물어보았는데 생각보다 부자들이 많다는 이야기를 합니다. ㅎㅎ 바이오와 화학을 전공하고 있고 IT를 접목하는 모습을 보니 정말 뛰어난 인재라고 ...