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




댓글 없음:

댓글 쓰기

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

Xcode 26의 새로운 기능들

 애플의 AI준비에 대한 골든타임이 지나가고 있다는 말이 많이 들립니다. ㅎㅎ  애플의 그동안의 패쇄적인 환경을 생각하면 온디바이스AI나 LLM환경에서 다소 아쉬운 부분이 많이 있습니다. 다른 빅테크들과 전혀 다른 방향의 목소리를 내고 있어서 좀 우려...