Quartz OpenGL ES 注 3 注 4 図 2 注 5 3 3D 4 5 2 OpenGL ES Quartz Quartz Jun. 2011-135



Similar documents
AirPrintPublic

Microsoft Word - colors


170403_1_FABEX_2017会場案内マップ


特別プログラム

8 浜根知恵(p191‐203)204白/p191‐203

★表紙-背幅5.5mm/表紙

SBI損保の自動車保険 重要事項説明書


表紙(背幅8.5mm)/背幅8.5mm

2

_ZEI-1022_fiÁŁÊ−雿-’‘Ä


1 鵜澤幸弘(p7‐26)/性同一障害 p7‐26

広報あつぎ-1月15日号-1面12.indd

A4_元


60周年記念 記念誌/扉・扉裏・中扉・資料扉・名簿扉

本文/YAY180B


S \1.E4


本文(縦)/YAZ149T

ISBN ISBN 5 128p ISBN ISBN 2


民事責任規定・エンフォースメント


ISBN ISBN 0 0 ISBN

2015-s6-4g-pocket-guidebook_H1-4.indd

index View Controller


iOSにおける描画と印刷のガイド (TP )

endo.PDF


2

untitled

国際会館ICC冊子2013.indd

ÿþ

EUにおける投資型クラウドファンディング規制


JavaScriptCore

★分冊3-説明資料PDF用/02-PDF個別

™ƒŒì„³001†`028.pwd

山田直巳109‐121/109‐128

76

' % % &! #



康乘聡子(P105‐121)/康乘聡子 p105‐121

‡Æ‡Ý‡©457_01-12

JavaScript演習

WebGL OpenGL GLSL Kageyama (Kobe Univ.) Visualization / 57

第三学年  総合的な学習の指導案(国際理解・英語活動)

SSKP

untitled

_150609_<984E><95A2><7BC0>_<5FF5><6821>.pdf

CocoaDrawingGuide

橡Taro9-生徒の活動.PDF

Microsoft Word - hozon-fujimura-HP-伊勢工業高校における造船教育の歴史から学ぶ

77

Transcription:

iphone Quartz ios ios YOSHIDA Yuuichi http://sonson.jp 注 1 注 2 図 1 1 ios Objective-C 2 Google 1 Map Kit 3 Cocoa Touch 134 - Software Design

Quartz OpenGL ES 注 3 注 4 図 2 注 5 3 3D 4 5 2 OpenGL ES Quartz Quartz Jun. 2011-135

3 4 1 UIView drawrect - (void)drawrect:(cgrect)rect { // レンダリングコードをここに 書 く 5 Quartz 2 drawrect - (void)drawrect:(cgrect)rect { // レンダリングコードをここに 書 く CGContextSetRGBFillColor(context, 0.0, 1.0, 0.0, 1.0); CGContextFillRect(context, CGRectMake(10, 10, 100, 100)); 3 CGContextMoveToPoint(context, 10, 10); CGContextAddLineToPoint(context, 20, 10); CGContextAddLineToPoint(context, 20, 20); CGContextAddLineToPoint(context, 10, 20); CGContextAddLineToPoint(context, 10, 10); CGContextDrawPath(context, kcgpathstroke); 図 3 Quartz 図 4 Quartz リスト1 リスト2 注 6 図 5 6 Quartz 2D Programming Guide http://developer. a p p l e. c o m / l i b r a r y / m a c / # d o c u m e n t a t i o n / graphicsimaging/conceptual/drawingwithquartz2d/ Introduction/Introduction.html 136 - Software Design

Quartz リスト 3 リスト4 4 - (void)drawroundcornerrect:(cgrect)rect mode:(cgpathdrawingmode)mode radius:(float) radius { 5 - (void)drawrectwithshadow { CGFloat minx = CGRectGetMinX(rect); CGFloat midx = CGRectGetMidX(rect); CGFloat maxx = CGRectGetMaxX(rect); CGFloat miny = CGRectGetMinY(rect); CGFloat midy = CGRectGetMidY(rect); CGFloat maxy = CGRectGetMaxY(rect); CGContextMoveToPoint(context, minx, midy); CGContextAddArcToPoint(context, minx, miny, midx, miny, radius); CGContextAddArcToPoint(context, maxx, miny, maxx, midy, radius); CGContextAddArcToPoint(context, maxx, maxy, midx, maxy, radius); CGContextAddArcToPoint(context, minx, maxy, minx, midy, radius); CGContextDrawPath(context, mode); // 影 を 付 ける 前 の 状 態 を 保 存 する CGContextSaveGState(context); UIColor *blackcolor = [UIColor blackcolor]; CGContextSetShadowWithColor(context, CGSizeMake(0, 1), 2.0, [blackcolor CGColor]); CGContextSetRGBFillColor(context, 0.0, 1.0, 0.0, 1.0); CGContextFillRect(context, CGRectMake(10, 10, 100, 100)); // 影 を 付 ける 前 の 状 態 を 復 帰 する CGContextRestoreGState(context); // 他 のオブジェクトをここで 描 画 する 6 図 6 リスト5 注 7 7 OpenGL glpushmatrix glpopmatrix Jun. 2011-137

6 - (void)testclipping { CGContextSaveGState(context); CGContextAddArc(context, 100, 100, 30, 0, 360, 0); CGContextClip(context); UIColor *greencolor = [UIColor greencolor]; CGContextSetFillColorWithColor(context, [greencolor CGColor]); CGContextFillRect(context, CGRectMake(100, 100, 50, 50)); CGContextRestoreGState(context); 7 CGColorSpaceRef space = CGColorSpaceCreateDeviceRGB(); CGFloat colors[] = { 155.0 / 255.0, 155.0 / 255.0, 155.0 / 255.0, 1.0, 70.0 / 255.0, 70.0 / 255.0, 70.0 / 255.0, 1.0, ; CGGradientRef gradient = CGGradientCreateWithColorComponents( space, colors, NULL, sizeof(colors)/(sizeof(colors[0])*4)); CGColorSpaceRelease(space); 7 図 7 リスト 6 リスト7 リスト8 リスト9 138 - Software Design

Quartz 図 8 注 8 NSString *str = @"Hello, world."; [str drawatpoint:cgpointmake(10, 10) withfont:[uifont boldsystemfontofsize:12]]; リスト10 図 9 8 h t t p : / / d e v e l o p e r. a p p l e. c o m / l i b r a r y / ios/#documentation/uikit/reference/nsstring_ UIKit_Additions/Reference/Reference.html 8 8 - (void)drawgradientcolor { CGColorSpaceRef space = CGColorSpaceCreateDeviceRGB(); CGFloat colors[] = { 155.0 / 255.0, 155.0 / 255.0, 155.0 / 255.0, 1.0, 70.0 / 255.0, 70.0 / 255.0, 70.0 / 255.0, 1.0, ; CGGradientRef gradient = CGGradientCreateWithColorComponents( space, colors, NULL, sizeof(colors)/(sizeof(colors[0])*4)); CGColorSpaceRelease(space); CGContextDrawLinearGradient( context, gradient, CGPointMake(100, 100), CGPointMake(100, 200), kcggradientdrawsbeforestartlocation kcggradientdrawsafterendlocation); CGGradientRelease(gradient); 9 - (void)drawgradientrhombus { CGColorSpaceRef space = CGColorSpaceCreateDeviceRGB(); CGFloat colors[] = { 155.0 / 255.0, 155.0 / 255.0, 155.0 / 255.0, 1.0, 20.0 / 255.0, 20.0 / 255.0, 20.0 / 255.0, 1.0, ; CGGradientRef gradient = CGGradientCreateWithColorComponents( space, colors, NULL, sizeof(colors)/(sizeof(colors[0])*4)); CGColorSpaceRelease(space); CGContextSaveGState(context); CGContextMoveToPoint(context, 160,160); CGContextAddLineToPoint(context, 240, 240); CGContextAddLineToPoint(context, 160, 320); CGContextAddLineToPoint(context, 80, 240); CGContextAddLineToPoint(context, 160, 160); CGContextClip(context); CGContextDrawLinearGradient( context, gradient, CGPointMake(160, 160), CGPointMake(160, 320), kcggradientdrawsbeforestartlocation kcggradientdrawsafterendlocation); CGGradientRelease(gradient); CGContextRestoreGState(context); Jun. 2011-139

10 9 - (void)layoutanddrawtext { // 引 数 CGPoint p = CGPointMake(30, 30); float width = 200; float height = 480; float fontsize = 20; NSString *str = @"Hello, world. Do you like ios programming? " " 初 めまして!iOSプログラミングはお 好 きですか?"; UIColor *yellow = [UIColor yellowcolor]; UIColor *black = [UIColor blackcolor]; UIFont *font = [UIFont boldsystemfontofsize:fontsize]; // 文 字 列 のサイズ CGSize strsize = [str sizewithfont:font constrainedtosize:cgsizemake(width,height) linebreakmode:uilinebreakmodecharacterwrap]; CGRect renderingrect; renderingrect.origin = p; renderingrect.size = strsize; // 背 景 色 のレンダリング [yellow setfill]; CGContextFillRect(context, renderingrect); // 文 字 列 のレンダリング [black setfill]; [str drawinrect:renderingrect withfont:font linebreakmode:uilinebreakmodecharacterwrap]; - (void)set; - (void)setfill; - (void)setstroke; 注 9 注 10 注 11 Quartz 9 http://developer.apple.com/library/ios/#samplecode/ QuartzDemo/Introduction/Intro.html 10 David Gelphman Bunny Laden Morgan Kaufmann 2005 ISBN978-0-1236-9473-7 11 https://github.com/sonsongithub/ ios 22tch ios API ios SDK HACKS ISBN978-4-87311-472-9 140 - Software Design