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 다큐 인사이트 - 인재전쟁 2부 의대에 미친 한국

  대부분의 내용들은 우리가 이미 알고 있는 내용들입니다. ㅎㅎ 공대가 인기가 있었던 것은 80년대와 90년대 였던 것 같습니다. IMF위기를 겪고 나서 지금처럼 의대로 방향이 바뀌었네요. 한국은 AI분야에서 보면 참으로 척박한 땅입니다. 거의 기술의...