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);
    //--------------------------
    
}




댓글 없음:

댓글 쓰기

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

5월 14일 새벽에 chatGPT 4o가 발표되었습니다. 옵티마이즈, 옴니라는 의미인데 실시간 통역, 다자간 회의, 멀티모달 기능의 강화등이 보이네요.

  초격차로 OpenAI진영이 다시 앞서가는 모양을 보여주고 있습니다. 저도 새벽에 일어나자 마자 올라온 영상들과 글을 정리하고 있습니다. ㅎㅎ 영화 HER의 사진이 새벽에 많이 올라왔었는데 저도 안본 영화입니다. 주말에 한번 봐야 할 것 같습니다....