Custom Drawing & Animation. CS 442: Mobile App Development Michael Saelee

Size: px
Start display at page:

Download "Custom Drawing & Animation. CS 442: Mobile App Development Michael Saelee"

Transcription

1 Custom Drawing & Animation CS 442: Mobile App Development Michael Saelee 1

2 Frameworks - UIKit - Core Graphics / Quartz - Core Animation - OpenGL ES 2

3 UIKit OpenGL ES Core Graphics Core Animation 3

4 UIKit (mostly) ObjC API UI... classes/functions 4

5 UIKit Base view class: UIView Pre-built controls: UIControls 5

6 UIKit typically, use concrete subclasses as is (no need to subclass) e.g., UILabel, UIButton, UITableView, UIImageView 6

7 UIKit can also subclass UIView to draw custom UI elements 7

8 UIKit support for - 2D drawing - transformations - predefined transitions - basic animation 8

9 CG aka Quartz 2D C API for drawing 9

10 CG support for: - layer-based graphics - patterns, gradients, etc. - color spaces - working with bitmaps 10

11 CG mostly, UIKit draws using CG i.e., more than one way of doing anything 11

12 UIKit CG // clear with white rectangle [[UIColor whitecolor] set]; UIRectFill(self.bounds); // load and draw image at (0,0) [[UIImage drawatpoint:cgpointmake(0, 0)]; // get current graphics context to draw into CGContextRef context = UIGraphicsGetCurrentContext(); // clear with white rectangle CGContextSetRGBFillColor(context, 1.0, 1.0, 1.0, 1.0); CGContextFillRect(context, self.bounds); // load image from file NSString* imagefilename = [[[NSBundle mainbundle] resourcepath] stringbyappendingpathcomponent:@"image.png"]; CGDataProviderRef provider = CGDataProviderCreateWithFilename([imageFileName UTF8String]); CGImageRef image = CGImageCreateWithPNGDataProvider(provider, NULL, true, kcgrenderingintentdefault); CGDataProviderRelease(provider); // draw image at (0,0) CGContextDrawImage(context, CGRectMake(0, 0, CGImageGetWidth(image), CGImageGetHeight(image)), image); CGImageRelease(image); 12

13 CA ObjC API for animation and compositing verb [ trans. ] [usu. as n. ] ( compositing) combine (two or more images) to make a single picture, esp. electronically : photographic compositing by computer. 13

14 CA all UIViews are backed by CA layers 14

15 CA can create a hierarchy of CALayers within a single view (in addition to creating a hierarchy of views) 15

16 CA generally, layers are: - more lightweight - more flexible - more complex 16

17 CA CALayer properties can be automatically animated 17

18 CA support for: - simple value interpolation - key frame animation - transition effects - animation groups 18

19 UIKit CA // load image and add to view at position (100,100) UIImageView *imageview = [[UIImageView alloc] initwithimage:[uiimage imagenamed:@"image.png"]]; imageview.center = CGPointMake(100, 100); [self.view addsubview:imageview]; // animate using a block - - bounce between start position and (300,300) [UIView animatewithduration:5.0 delay:0.0 options:uiviewanimationoptionrepeat UIViewAnimationOptionAutoreverse animations:^{ imageview.center = CGPointMake(300, 300); } completion:null]; // create new CA layer and populate with image CALayer *layer = [CALayer layer]; UIImage *image = [UIImage imagenamed:@"image.png"]; layer.contents = image.cgimage; layer.frame = CGRectMake(0, 0, image.size.width, image.size.height); // add layer to view layer [self.view.layer addsublayer:layer]; // create basic animation to interpolate position between (100,100) and (300,300) CABasicAnimation *anim = [CABasicAnimation animationwithkeypath:@"position"]; anim.fromvalue = [NSValue valuewithcgpoint:cgpointmake(100, 100)]; anim.tovalue = [NSValue valuewithcgpoint:cgpointmake(300, 300)]; anim.duration = 5.0; anim.autoreverses = YES; anim.repeatcount = HUGE_VALF; anim.timingfunction = [CAMediaTimingFunction functionwithname:kcamediatimingfunctioneaseineaseout]; [layer addanimation:anim forkey:@"backandforth"]; 19

20 OpenGL industry standard 2D/3D graphics API 20

21 OpenGL technically, OpenGL ES; i.e., for Embedded Systems 21

22 OpenGL OpenGL ES 2.0 not backwards compatible (fixed-function vs. shaders) 22

23 OpenGL hardware acceleration (ipad 2: CPUx2, GPUx9, ipad 3: CPUx1, GPUx2-3) 23

24 OpenGL OpenGL render destination: CAEAGLLayer in UIView 24

25 OpenGL generally, don t mix OpenGL and UIKit/CA/CG functions (e.g., no layer transforms) 25

26 UIKit OpenGL ES Core Graphics Core Animation 26

27 Drawing 27

28 (0,0) x 320 y 480 ULO 28

29 (0,0) x 480 y 320 ULO 29

30 320 x 480 points (not necessarily = pixels!) 30

31 resolution independence scale factor points = pixels (retina display: scale = 2.0) 31

32 principal data types: CGPoint, CGSize, CGRect /* Points. */ typedef struct { float x; float y; } CGPoint; /* Sizes. */ typedef struct { float width; float height; } CGSize; /* Rectangles. */ typedef struct { CGPoint origin; CGSize size; } CGRect; 32

33 /* Make a point from (x, y). */ CGPoint CGPointMake(CGFloat x, CGFloat y); /* Make a size from (width, height). */ CGSize CGSizeMake(CGFloat width, CGFloat height); /* Make a rect from (x, y; width, height). */ CGRect CGRectMake(CGFloat x, CGFloat y, CGFloat width, CGFloat height); 33

34 /* Return the left/mid/right x- value of rect. */ CGFloat CGRectGetMinX(CGRect rect); CGFloat CGRectGetMidX(CGRect rect); CGFloat CGRectGetMaxX(CGRect rect); /* Return the top/mid/bottom y- value of rect. */ CGFloat CGRectGetMinY(CGRect rect); CGFloat CGRectGetMidY(CGRect rect); CGFloat CGRectGetMaxY(CGRect rect); /* Return the width/height of rect. */ CGFloat CGRectGetWidth(CGRect rect); CGFloat CGRectGetHeight(CGRect rect); /* Standardize rect - - i.e., convert it to an equivalent rect which has positive width and height. */ CGRect CGRectStandardize(CGRect rect); /* Return true if rect is empty (that is, if it has zero width or height), false otherwise. A null rect is defined to be empty. */ bool CGRectIsEmpty(CGRect rect); 34

35 locating/placing things: frame & bounds rectangles 35

36 frame = origin & size in superview s coordinate system 36

37 bounds = origin & size in local view s coordinate system 37

38 application window 38

39 view frame: - origin = (6, 5) - size = (15, 10) view application window 39

40 view bounds: - origin = (0, 0) - size = (15, 10) subview frame: - origin = (3, 4) - size = (6, 5) subview view application window 40

41 size of frame, bounds are automatically linked 41

42 reposition view by changing frame origin or center (changing one automatically adjusts the other) 42

43 can change bounds origin to adjust local coordinate system 43

44 view bounds: - origin = (0, 0) - size = (15, 10) subview frame: - origin = (3, 4) - size = (6, 5) 44

45 view bounds: - origin = (-1, 4) - size = (15, 10) subview frame: - origin = (3, 4) - size = (6, 5) 45

46 /* Fill `rect' with solid color */ void UIRectFill(CGRect rect); void UIRectFillUsingBlendMode(CGRect rect, CGBlendMode blendmode); /* Draw 1px frame inside `rect'. */ void UIRectFrame(CGRect rect); void UIRectFrameUsingBlendMode(CGRect rect, CGBlendMode blendmode); Simple Drawing 46

47 @interface UIColor // Convenience methods for creating autoreleased colors + (UIColor *)colorwithred:(cgfloat)red green:(cgfloat)green blue:(cgfloat)blue alpha:(cgfloat)alpha; // Some convenience methods to create colors. These colors are cached. + (UIColor *)blackcolor; // 0.0 white + (UIColor *)redcolor; // 1.0, 0.0, 0.0 RGB + (UIColor *)greencolor; // 0.0, 1.0, 0.0 RGB + (UIColor *)bluecolor; // 0.0, 0.0, 1.0 RGB + (UIColor *)clearcolor; // 0.0 white, 0.0 alpha // Set the color: Sets the fill and stroke colors in the current drawing context. - (void)set; // Set the fill or stroke colors individually. - (void)setfill; - (void)setstroke; // Access the underlying CGColorRef Color? 47

48 UIKit framework always draws to implicit, current Graphics Context 48

49 CG maintains a stack of graphics contexts (empty, by default) 49

50 UIView object pushes graphics context for its layer before calling drawrect: 50

51 @interface UIView(UIViewRendering) /* All custom drawing must happen from this method. Should limit drawing to rect - - on first call rect is usually equal to our bounds. */ - (void)drawrect:(cgrect)rect; /* drawrect: is called lazily. If view must be redrawn, we must notify the system by calling one of these methods below. */ - (void)setneedsdisplay; - 51

52 Q: draw in current view vs. adding subview? - it depends - subviews allow us to add/remove objects - but adds memory + processing overhead 52

53 HelloWorldView -discuss root view frame origin/ size Rectangle1 -using setneedsdisplay to force refresh Rectangle2 -use multiple views to track drawn rectangles -ignore contentstretch for now GameBoard - handling demo 53

54 subview size > superview? 54

55 default: no subview clipping. but no scrolling, either 55

56 Clipping Demo - effect of clipstobounds ScrollView Demo -automatic pan support based on contentsize -also: pinch to zoom demo 56

57 view transformations: translating, scaling, rotating 57

58 common strategy: - draw unit object at (0,0) - translate, scale, rotate to final position/size/orientation 58

59 drawrect: can be very lazy i.e., draw once, transform many times 59

60 implementation: affine transform matrices 60

61 transformed coordinates x 0 y 0 1 = x y 1 transformation matrix 2 4 original coordinates a b 0 c d 0 t x t y x 0 = ax + cy + t x y 0 = bx + dy + t y e.g. x 0 y 0 1 = x y = x + t x y + t y t x t y

62 typedef struct { CGFloat a, b, c, d; CGFloat tx, ty; } CGAffineTransform; /* The identity transform: [ ]. */ extern const CGAffineTransform CGAffineTransformIdentity; /* Return a transform which translates by `(tx, ty)': t' = [ tx ty ] */ CGAffineTransform CGAffineTransformMakeTranslation(CGFloat tx, CGFloat ty); /* Return a transform which scales by `(sx, sy)': t' = [ sx 0 0 sy 0 0 ] */ CGAffineTransform CGAffineTransformMakeScale(CGFloat sx, CGFloat sy); /* Return a transform which rotates by `angle' radians: t' = [ cos(angle) sin(angle) - sin(angle) cos(angle) 0 0 ] */ CGAffineTransform CGAffineTransformMakeRotation(CGFloat angle) /* Concatenate translation, scaling, rotation transforms to existing matrices. */ CGAffineTransform CGAffineTransformTranslate(CGAffineTransform t, CGFloat tx, CGFloat ty); CGAffineTransform CGAffineTransformScale(CGAffineTransform t, CGFloat sx, CGFloat sy); CGAffineTransform CGAffineTransformRotate(CGAffineTransform t, CGFloat angle); 62

63 for given graphics context (e.g., in drawrect:), change current transform matrix (CTM) 63

64 /* Scale the current graphics state's transformation matrix (the CTM) by `(sx, sy)'. */ void CGContextScaleCTM(CGContextRef c, CGFloat sx, CGFloat sy); /* Translate the current graphics state's transformation matrix (the CTM) by `(tx, ty)'. */ void CGContextTranslateCTM(CGContextRef c, CGFloat tx, CGFloat ty); /* Rotate the current graphics state's transformation matrix (the CTM) by `angle' radians. */ void CGContextRotateCTM(CGContextRef c, CGFloat angle); /* Concatenate the current graphics state's transformation matrix (the CTM) with the affine transform `transform'. */ void CGContextConcatCTM(CGContextRef c, CGAffineTransform transform); 64

65 ExpandingFrame -look at RotatingView drawrect -motivate CGContextSave/ RestoreGState -explore frame/bounds relationship demo 65

66 cubic & quadratic Bézier curves Drawing Other Shapes 66

67 @interface UIBezierPath : NSObject<NSCopying, NSCoding> { + (UIBezierPath *)bezierpath; - (void)movetopoint:(cgpoint)point; - (void)addlinetopoint:(cgpoint)point; - (void)addcurvetopoint:(cgpoint)endpoint controlpoint1:(cgpoint)controlpoint1 controlpoint2:(cgpoint)controlpoint2; - (void)addquadcurvetopoint:(cgpoint)endpoint controlpoint:(cgpoint)controlpoint; - (void)addarcwithcenter:(cgpoint)center radius:(cgfloat)radius startangle:(cgfloat)startangle endangle:(cgfloat)endangle clockwise:(bool)clockwise; - (void)closepath; + (UIBezierPath *)bezierpathwithrect:(cgrect)rect; + (UIBezierPath *)bezierpathwithovalinrect:(cgrect)rect; + (UIBezierPath *)bezierpathwithroundedrect:(cgrect)rect CGPathRef 67

68 Bézier curves can be created, stored, and reused, independent of graphics context 68

69 BezierDrawing demo 69

70 rects, curves, etc. = vector graphics infinite scaleability 70

71 raster graphics? e.g., bitmaps, JPG, PNG 71

72 UIKit: load with UIImage 72

73 imagenamed: Returns the image object associated with the specified filename. + (UIImage *)imagenamed:(nsstring *)name Parameters name The name of the file. If this is the first time the image is being loaded, the method looks for an image with the specified name in the application s main bundle. Return Value The image object for the specified file, or nil if the method could not find the specified image. Discussion This method looks in the system caches for an image object with the specified name and returns that object if it exists. If a matching image object is not already in the cache, this method loads the image data from the specified file, caches it, and then returns the resulting object. On a device running ios 4 or later, the behavior is identical if the device s screen has a scale of 1.0. If the screen has a scale of 2.0, this method first searches for an image file with the same filename with suffix appended to it. For example, if the file s name is button, it first searches for button@2x. If it finds a 2x, it loads that image and sets the scale property of the returned UIImage object to 2.0. Otherwise, it loads the unmodified filename and sets the scale property to

74 caveat emptor: imagenamed cache can be quite aggressive! (Google: imagenamed cache ) 74

75 raster graphics problem: scaling pixelation 75

76 UIView contentstretch property defines which parts of an image are stretched 76

77 ContentStretching demo 77

78 image = [UIImage imagenamed:@"image.png"]; ➊ UIKit (subview) UIImageView *imageview = [[UIImageView alloc] initwithimage:image]; [self.view addsubview:imageview]; ➋ CG (drawing) - (void)drawrect:(cgrect)rect { [image drawatpoint:cgpointmake(0, 0)]; } ➌ CA (compositing) CALayer *layer = [CALayer layer]; layer.contents = image.cgimage; [self.view.layer addsublayer:layer]; Image Drawing Options 78

79 ImageDrawing -run all three versions (view, layer, drawrect) --- may want to keep num_image < 100 for the last -run through instruments: memory allocations (num_images=10000 for view, layer version), and time profiler (esp. interesting for drawrect based) demo 79

80 more reading (Xcode library): - View Programming Guide for ios - Quartz 2D Programming Guide 80

81 Animation 81

82 UIKit / CoreAnimation 82

83 typically, use magic UIView / CALayer animation mechanism 83

84 i.e., provide new view properties in animation block along with time frame core animation does the rest 84

85 note: CA updates happen in a separate thread! 85

86 animated parameters are updated according to a specified interpolation curve (aka timing function) 86

87 timing functions 87

88 e.g., sprites 88

89 e.g., basic magic animations 89

90 e.g., how it works (CA equivalent with CAAction) 90

91 e.g., view transitions 91

92 e.g., UIImage based animations (multiple images) 92

93 e.g., CABasicAnimation 93

94 e.g., CAKeyFrameAnimation 94

Custom Drawing & Animation. CS 442: Mobile App Development Michael Saelee

Custom Drawing & Animation. CS 442: Mobile App Development Michael Saelee Custom Drawing & Animation CS 442: Mobile App Development Michael Saelee Frameworks - UIKit - Core Graphics / Quartz - Core Animation - OpenGL ES UIKit OpenGL ES Core Graphics Core Animation

More information

Stanford CS193p. Developing Applications for ios. Fall Stanford CS193p. Fall 2011

Stanford CS193p. Developing Applications for ios. Fall Stanford CS193p. Fall 2011 Developing Applications for ios Views A view (i.e. UIView subclass) represents a rectangular area Defines a coordinate space Draws and handles events in that rectangle Hierarchical A view has only one

More information

Science. Computer Science

Science. Computer Science Introductions CS 442: Mobile App Development Michael Saelee Michael (Sae) Lee - lee@iit.edu - moss.cs.iit.edu - Office: SB 226A Agenda - Syllabus & Administrivia - Course overview Android

More information

Core Graphics and OpenGL ES. Dr. Sarah Abraham

Core Graphics and OpenGL ES. Dr. Sarah Abraham Core Graphics and OpenGL ES Dr. Sarah Abraham University of Texas at Austin CS329e Fall 2018 Core Graphics Apple s vector-drawing framework Previously known as Quartz or Quartz2D Includes handling for:

More information

View Hierarchy - UIWindow

View Hierarchy - UIWindow Views and Drawing Views View Fundamentals Rectangular area on screen Draws content Handles events Subclass of UIResponder (event handling class) Views arranged hierarchically every view has one superview

More information

Today s Topics. Views Drawing Text & Images Animation

Today s Topics. Views Drawing Text & Images Animation Today s Topics Views Drawing Text & Images Animation 4 Views 5 View Fundamentals Rectangular area on screen Draws content Handles events Subclass of UIResponder (event handling class) Views arranged hierarchically

More information

Core Graphics & Animation. ios App Development Fall 2010 Lecture 17

Core Graphics & Animation. ios App Development Fall 2010 Lecture 17 Core Graphics & Animation ios App Development Fall 2010 Lecture 17 Questions? Announcements Assignment #5 out later this week Last of the short assignments Today s Topics Custom UIViews -drawrect: Core

More information

Monday, 1 November The ios System

Monday, 1 November The ios System The ios System System Overview System Overview System Overview System Overview System Overview System Overview Foundation Classes (Useful) Foundation Framework Value and collection classes User defaults

More information

Stanford CS193p. Developing Applications for ios. Spring CS193p. Spring 2016

Stanford CS193p. Developing Applications for ios. Spring CS193p. Spring 2016 Stanford Developing Applications for ios Today Views Custom Drawing Demo FaceView Views A view (i.e. UIView subclass) represents a rectangular area Defines a coordinate space For drawing And for handling

More information

Views. A view (i.e. UIView subclass) represents a rectangular area Defines a coordinate space

Views. A view (i.e. UIView subclass) represents a rectangular area Defines a coordinate space Views A view (i.e. UIView subclass) represents a rectangular area Defines a coordinate space Draws and handles events in that rectangle Hierarchical A view has only one superview - (UIView *)superview

More information

Stanford CS193p. Developing Applications for ios. Winter CS193p. Winter 2017

Stanford CS193p. Developing Applications for ios. Winter CS193p. Winter 2017 Stanford Developing Applications for ios Today Views Custom Drawing Demo FaceView Views A view (i.e. UIView subclass) represents a rectangular area Defines a coordinate space For drawing And for handling

More information

CS193p Spring 2010 Monday, April 12, 2010

CS193p Spring 2010 Monday, April 12, 2010 CS193p Spring 2010 Announcements Axess! Make sure your grading option matches what you were approved for Sonali s Office Hours Changed Friday 11am to 1pm Thursday 10am to noon Gates B26B Any questions

More information

ios Mobile Development

ios Mobile Development ios Mobile Development Today Views How to draw custom stuff on screen. Gestures How to react to user s touch gestures. Demo SuperCard Views A view (i.e. UIView subclass) represents a rectangular area Defines

More information

COMP327 Mobile Computing. Lecture Set 9 - Model, View, Controller

COMP327 Mobile Computing. Lecture Set 9 - Model, View, Controller COMP327 Mobile Computing Lecture Set 9 - Model, View, Controller 1 In this Lecture Set Anatomy of an Application Model View Controller Interface Builder and Nibs View Classes Views Drawing Text and Images

More information

Announcements. Lab 2 is due next Monday (Sept 25 th ) by 11:59 PM. Late policy is 10% of lab total per day late. So -7.5 points per day late for lab 2

Announcements. Lab 2 is due next Monday (Sept 25 th ) by 11:59 PM. Late policy is 10% of lab total per day late. So -7.5 points per day late for lab 2 Announcements Lab 2 is due next Monday (Sept 25 th ) by 11:59 PM Late policy is 10% of lab total per day late So -7.5 points per day late for lab 2 Labs 3 and 4 are posted on the course website Extensible

More information

Stanford CS193p. Developing Applications for iphone 4, ipod Touch, & ipad Fall Stanford CS193p Fall 2010

Stanford CS193p. Developing Applications for iphone 4, ipod Touch, & ipad Fall Stanford CS193p Fall 2010 Developing Applications for iphone 4, ipod Touch, & ipad Today One last Objective-C topic: Protocols Using protocols to define/implement/use a data source and/or delegate Views UIView and UIWindow classes

More information

Announcements. Lab 3. Lab 2 is due on Monday Sept 21 st. Lab 3 is posted Due September 30 th

Announcements. Lab 3. Lab 2 is due on Monday Sept 21 st. Lab 3 is posted Due September 30 th Announcements Lab 2 is due on Monday Sept 21 st Lab 3 is posted Due September 30 th 1 Extensible - CSE 436 Software Networking Engineering Platform Workshop 1 Lab 3 2 Extensible - CSE 436 Software Networking

More information

Stanford CS193p. Developing Applications for ios. Winter CS193p! Winter 2015

Stanford CS193p. Developing Applications for ios. Winter CS193p! Winter 2015 Stanford CS193p Developing Applications for ios Today Objective-C Compatibility Bridging Property List NSUserDefaults Demo: var program in CalculatorBrain Views Custom Drawing Demo FaceView Bridging Objective-C

More information

Views, Drawing, and Events. Lecture 5

Views, Drawing, and Events. Lecture 5 Views, Drawing, and Events Lecture 5 First - Representing Points and Areas NSPoint // Represents a point in a Cartesian coordinate system. typedef struct _NSPoint { CGFloat x; CGFloat y; } NSPoint Pair

More information

Stanford CS193p. Developing Applications for ios. Fall CS193p. Fall

Stanford CS193p. Developing Applications for ios. Fall CS193p. Fall Stanford Developing Applications for ios Today Miscellaneous Error Handling Any Other Interesting Classes Views Custom Drawing Demo: Draw a Playing Card enum Thrown Errors In Swift, methods can throw errors

More information

View Controller Lifecycle

View Controller Lifecycle View Controller Lifecycle View Controllers have a Lifecycle A sequence of messages is sent to them as they progress through it Why does this matter? You very commonly override these methods to do certain

More information

Custom Views and Events. Lecture 7

Custom Views and Events. Lecture 7 Custom Views and Events Lecture 7 First Representing Points and Areas NSPoint typedef struct _NSPoint { CGFloat x; CGFloat y; } NSPoint; Pair of x, y coordinates NSZeroPoint represents the bottom left

More information

The Best of Both Worlds: Using UIKit with OpenGL

The Best of Both Worlds: Using UIKit with OpenGL The Best of Both Worlds: Using UIKit with OpenGL Noel Llopis Snappy Touch Twitter: @snappytouch About Me iphone development full time for a year and a half. Flower Garden on the app store. Interesting

More information

View Concepts. iphone Application Programming Lecture 4: User Interface Design. SDK provide many types of Views to show your content

View Concepts. iphone Application Programming Lecture 4: User Interface Design. SDK provide many types of Views to show your content View Concepts iphone Application Programming Lecture 4: User Interface Design SDK provide many types of Views to show your content At run-time Views are organized as a tree Chat Wacharamanotham Media Computing

More information

Developing Applications for ios

Developing Applications for ios Developing Applications for ios Lecture 4: Views, Autorotation and Gestures Radu Ionescu raducu.ionescu@gmail.com Faculty of Mathematics and Computer Science University of Bucharest Content Views Drawing

More information

Stanford CS193p. Developing Applications for ios. Spring Stanford CS193p. Spring 2012

Stanford CS193p. Developing Applications for ios. Spring Stanford CS193p. Spring 2012 Developing Applications for ios Foundation Framework NSObject Base class for pretty much every object in the ios SDK Implements introspection methods, etc. - (NSString *)description is a useful method

More information

Adopting Advanced Features of the New UI

Adopting Advanced Features of the New UI Frameworks #WWDC14 Adopting Advanced Features of the New UI Session 220 Chris Dreessen AppKit Software Engineer! Corbin Dunn AppKit Software Engineer 2014 Apple Inc. All rights reserved. Redistribution

More information

lecture 10 UI/UX and Programmatic Design cs : spring 2018

lecture 10 UI/UX and Programmatic Design cs : spring 2018 lecture 10 UI/UX and Programmatic Design cs198-001 : spring 2018 1 Announcements custom app progress form due before lab (~1 minute) will be released after lecture only 2 labs left (both very important)

More information

Praktikum Entwicklung von Mediensystemen mit ios

Praktikum Entwicklung von Mediensystemen mit ios Praktikum Entwicklung von Mediensystemen mit ios SS 2012 Prof. Dr. Michael Rohs michael.rohs@ifi.lmu.de MHCI Lab, LMU München Today Animations Prototyping 2 Timeline # Date Topic 19.4. Introduction & Brainstorming

More information

Developing Applications for ios

Developing Applications for ios Developing Applications for ios Lecture 5: Views, Drawing and Gestures Radu Ionescu raducu.ionescu@gmail.com Faculty of Mathematics and Computer Science University of Bucharest Content Views, Drawing and

More information

Graphics and Animation on ios

Graphics and Animation on ios Graphics and Animation on ios Graphics and Animation on ios Vandad Nahavandipoor Beijing Cambridge Farnham Köln Sebastopol Tokyo Graphics and Animation on ios by Vandad Nahavandipoor Copyright 2011 Vandad

More information

User Experience: Windows & Views

User Experience: Windows & Views View Programming Guide for ios User Experience: Windows & Views 2010-07-07 Apple Inc. 2010 Apple Inc. All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or

More information

Praktikum Entwicklung von Mediensystemen mit

Praktikum Entwicklung von Mediensystemen mit Praktikum Entwicklung von Mediensystemen mit Sommersemester 2013 Fabius Steinberger, Dr. Alexander De Luca Honors Degree in Technology Management at the Center for Digital Technology and Management (Barerstr.

More information

Developing Applications for ios

Developing Applications for ios Developing Applications for ios Lecture 7: View Controller Lifecycle and UIKit Radu Ionescu raducu.ionescu@gmail.com Faculty of Mathematics and Computer Science University of Bucharest Content View Controller

More information

Graphics & Animation: 2D Drawing

Graphics & Animation: 2D Drawing Core Graphics Framework Reference Graphics & Animation: 2D Drawing 2009-05-14 Apple Inc. 2009 Apple Inc. All rights reserved. No part of this publication may be reproduced, stored in a retrieval system,

More information

Stanford CS193p. Developing Applications for ios. Winter CS193p. Winter 2017

Stanford CS193p. Developing Applications for ios. Winter CS193p. Winter 2017 Stanford Developing Applications for ios Today Timer Periodically execute a block of code Blinking FaceIt Demo Animation Animating changes to UIViews Smoother Blinking FaceIt Head-shaking FaceIt Animating

More information

Praktikum Entwicklung von Mediensystemen mit ios

Praktikum Entwicklung von Mediensystemen mit ios Praktikum Entwicklung von Mediensystemen mit ios WS 2011 Prof. Dr. Michael Rohs michael.rohs@ifi.lmu.de MHCI Lab, LMU München Today Storyboards Automatic Reference Counting Animations Exercise 3 2 Timeline

More information

What's New in UIKit Dynamics and Visual Effects Session 229

What's New in UIKit Dynamics and Visual Effects Session 229 App Frameworks #WWDC15 What's New in UIKit Dynamics and Visual Effects Session 229 Michael Turner UIKit Engineer David Duncan UIKit Engineer 2015 Apple Inc. All rights reserved. Redistribution or public

More information

Metal. GPU-accelerated advanced 3D graphics rendering and data-parallel computation. source rebelsmarket.com

Metal. GPU-accelerated advanced 3D graphics rendering and data-parallel computation. source rebelsmarket.com Metal GPU-accelerated advanced 3D graphics rendering and data-parallel computation source rebelsmarket.com Maths The heart and foundation of computer graphics source wallpoper.com Metalmatics There are

More information

CUSTOM VIEWS. The View Hierarchy. Chapter 12

CUSTOM VIEWS. The View Hierarchy. Chapter 12 Chapter 12 CUSTOM VIEWS A ll the visible objects in an application are either windows or views. In this chapter, you will create a subclass of NSView. From time to time, you will create a custom view to

More information

As you convert your QuickDraw application to one that uses only Quartz, there are two primary issues you ll face with respect to PICT data:

As you convert your QuickDraw application to one that uses only Quartz, there are two primary issues you ll face with respect to PICT data: C H A P T E R 4 Converting PICT Data The QuickDraw picture (PICT) format is the graphics metafile format in Mac OS 9 and earlier. A picture contains a recorded sequence of QuickDraw imaging operations

More information

ITP 342 Mobile App Dev. Animation

ITP 342 Mobile App Dev. Animation ITP 342 Mobile App Dev Animation Core Animation Introduced in Mac OS X Leopard Uses animatable "layers" built on OpenGL UIKit supports Core Animation out of the box Every UIView has a CALayer behind it

More information

Stanford CS193p. Developing Applications for ios. Winter CS193p. Winter 2017

Stanford CS193p. Developing Applications for ios. Winter CS193p. Winter 2017 Stanford Developing Applications for ios Today Error Handling in Swift try Extensions A simple, powerful, but easily overused code management syntax Protocols Last (but certainly not least important) typing

More information

EXERCISES RELATED TO ios PROGRAMMING

EXERCISES RELATED TO ios PROGRAMMING EXERCISES RELATED TO ios PROGRAMMING Kari Laitinen http://www.naturalprogramming.com 2017-08-30 File created. 2017-09-21 Last modification. 1 Kari Laitinen EXERCISES WITH PROGRAM Animals.swift With these

More information

Apple introduced MapKit with ios, maps were based on Google.

Apple introduced MapKit with ios, maps were based on Google. History: Apple introduced MapKit with ios, maps were based on Google. With ios 6.0, Apple provided its own mapping service, which lacked some quality, especially level-of-detail. With ios 7 Apple opened

More information

Custom Views and Drawing. Lecture 5

Custom Views and Drawing. Lecture 5 Custom Views and Drawing Lecture 5 First - Representing Points and Areas NSPoint typedef struct _NSPoint { CGFloat x; CGFloat y; } NSPoint Pair of x, y coordinates NSZeroPoint represents the origin Create

More information

A Vertical Slider for iphone

A Vertical Slider for iphone A Vertical Slider for iphone The UISlider control offers a way to continuously get values from the user within a range of set values. In the Interface Builder library of controls, there is only a horizontal

More information

Stanford CS193p. Developing Applications for ios. Spring CS193p. Spring 2016

Stanford CS193p. Developing Applications for ios. Spring CS193p. Spring 2016 Stanford Developing Applications for ios Today Memory Management for Reference Types Controlling when things leave the heap Closure Capture Closures capture things into the heap too Extensions A simple,

More information

iphone Application Programming Lecture 5: View Programming

iphone Application Programming Lecture 5: View Programming Lecture 5: View Programming Nur Al-huda Hamdan RWTH Aachen University Winter Semester 2015/2016 http://hci.rwth-aachen.de/iphone Name the UI Elements In the Screen 2 View Programming 3 View Programming

More information

Advanced ios. CSCI 4448/5448: Object-Oriented Analysis & Design Lecture 20 11/01/2012

Advanced ios. CSCI 4448/5448: Object-Oriented Analysis & Design Lecture 20 11/01/2012 Advanced ios CSCI 4448/5448: Object-Oriented Analysis & Design Lecture 20 11/01/2012 1 Goals of the Lecture Present a few additional topics and concepts related to ios programming persistence serialization

More information

CS193P - Lecture 8. iphone Application Development. Scroll Views & Table Views

CS193P - Lecture 8. iphone Application Development. Scroll Views & Table Views CS193P - Lecture 8 iphone Application Development Scroll Views & Table Views Announcements Presence 1 due tomorrow (4/28)! Questions? Presence 2 due next Tuesday (5/5) Announcements Enrolled students who

More information

Scroll View School Hands-On Challenges

Scroll View School Hands-On Challenges Scroll View School Hands-On Challenges Copyright 2014 Razeware LLC. All rights reserved. No part of this book or corresponding materials (such as text, images, or source code) may be reproduced or distributed

More information

ios Memory Deep Dive #WWDC18 Kyle Howarth, Software Engineer James Snee, Software Engineer Kris Markel, Software Engineer

ios Memory Deep Dive #WWDC18 Kyle Howarth, Software Engineer James Snee, Software Engineer Kris Markel, Software Engineer Session #WWDC18 ios Memory Deep Dive 416 Kyle Howarth, Software Engineer James Snee, Software Engineer Kris Markel, Software Engineer 2018 Apple Inc. All rights reserved. Redistribution or public display

More information

Assignment III: Graphing Calculator

Assignment III: Graphing Calculator Assignment III: Graphing Calculator Objective You will enhance your Calculator to create a graph of the program the user has entered which can be zoomed in on and panned around. Your app will now work

More information

epicurious Anatomy of an ios app Robert Tolar Haining June 25, 2010 ConvergeSE

epicurious Anatomy of an ios app Robert Tolar Haining June 25, 2010 ConvergeSE epicurious Anatomy of an ios app Robert Tolar Haining June 25, 2010 ConvergeSE + = Prototype iphone ipad Why iphone apps Simplicity Control Speed Revenue Epicurious Defined as a Recipe Utility Cookbook

More information

Editing Media with AV Foundation

Editing Media with AV Foundation Editing Media with AV Foundation Overview and best practices Eric Lee iphone Engineering 2 What You ll Learn Why and when you should use AV Foundation editing Concepts underlying manipulation of timed-based

More information

AUTO LAYOUT IS A UNICORN

AUTO LAYOUT IS A UNICORN AUTO LAYOUT IS A UNICORN WILD AND FREE. MAGIK AWAITS, COME AND SEE. Hi there folks! -Art credit: Elinor, 5 years old. ABOUT ME SousChef YOUR DIGITAL COOKING ASSISTANT 100K+ Users Mac, iphone, and ipad

More information

Swift API Design Guidelines

Swift API Design Guidelines Developer Tools #WWDC16 Swift API Design Guidelines The Grand Renaming Session 403 Doug Gregor Swift Engineer Michael Ilseman Swift Engineer 2016 Apple Inc. All rights reserved. Redistribution or public

More information

1.1 Why Foxit Mobile PDF SDK is your choice Foxit Mobile PDF SDK Key features Evaluation...

1.1 Why Foxit Mobile PDF SDK is your choice Foxit Mobile PDF SDK Key features Evaluation... TABLE OF CONTENTS 1 Introduction to...2 1.1 Why is your choice... 2 1.2... 3 1.3 Key features... 4 1.4 Evaluation... 4 1.5 License... 5 1.6 About this Guide... 5 2 Getting Started...6 2.1 Requirements...

More information

Stanford CS193p. Developing Applications for iphone 4, ipod Touch, & ipad Fall Stanford CS193p Fall 2010

Stanford CS193p. Developing Applications for iphone 4, ipod Touch, & ipad Fall Stanford CS193p Fall 2010 Developing Applications for iphone 4, ipod Touch, & ipad Today Blocks Language syntax for declaring a function on the fly. Grand Central Dispatch C API for leveraging blocks to make writing multithreaded

More information

Core Animation. Building Animated UI s. Bill Dudney. Gala Factory Software LLC. Bill Dudney Core Animation: Building Animated UI s Slide 1

Core Animation. Building Animated UI s. Bill Dudney. Gala Factory Software LLC. Bill Dudney Core Animation: Building Animated UI s Slide 1 Core Animation Building Animated UI s Bill Dudney Gala Factory Software LLC Bill Dudney Core Animation: Building Animated UI s Slide 1 Objective-C Dynamic Object Oriented C Based Smalltalk Roots Bill Dudney

More information

UICollectionView. NSCoder Milwaukee. 2 April John Psuik. Tuesday, April 2, 13

UICollectionView. NSCoder Milwaukee. 2 April John Psuik. Tuesday, April 2, 13 UICollectionView NSCoder Milwaukee 2 April 2013 John Psuik 1 UICollectionView New to ios 6 Layouts determine placement of items (flowlayout and custom layout) UITableView concepts, but you can do so much

More information

OVERVIEW. Why learn ios programming? Share first-hand experience. Identify platform differences. Identify similarities with.net

OVERVIEW. Why learn ios programming? Share first-hand experience. Identify platform differences. Identify similarities with.net OVERVIEW Why learn ios programming? Share first-hand experience. Identify platform differences. Identify similarities with.net Microsoft MVP for 4 years C#, WinForms, WPF, Silverlight Joined Cynergy about

More information

Today s Topics. Scroll views Table views. UITableViewController Table view cells. Displaying data Controlling appearance & behavior

Today s Topics. Scroll views Table views. UITableViewController Table view cells. Displaying data Controlling appearance & behavior Today s Topics Scroll views Table views Displaying data Controlling appearance & behavior UITableViewController Table view cells Scroll Views UIScrollView For displaying more content than can fit on the

More information

Developing Core Image Filters for ios

Developing Core Image Filters for ios Media #WWDC14 Developing Core Image Filters for ios Session 515 Alexandre Naaman Lead Customizer Tony Chu General Specialist 2014 Apple Inc. All rights reserved. Redistribution or public display not permitted

More information

Scalable Vector Graphics (SVG) vector image World Wide Web Consortium (W3C) defined with XML searched indexed scripted compressed Mozilla Firefox

Scalable Vector Graphics (SVG) vector image World Wide Web Consortium (W3C) defined with XML searched indexed scripted compressed Mozilla Firefox SVG SVG Scalable Vector Graphics (SVG) is an XML-based vector image format for twodimensional graphics with support for interactivity and animation. The SVG specification is an open standard developed

More information

Assignment III: Graphing Calculator

Assignment III: Graphing Calculator Assignment III: Graphing Calculator Objective The goal of this assignment is to reuse your CalculatorBrain and CalculatorViewController objects to build a Graphing Calculator. By doing this, you will gain

More information

Building GUIs with UIKit. Kevin Cathey

Building GUIs with UIKit. Kevin Cathey Building GUIs with UIKit Kevin Cathey Building GUIs with UIKit acm.uiuc.edu/macwarriors/devphone Building GUIs with UIKit What is UIKit? acm.uiuc.edu/macwarriors/devphone Building GUIs with UIKit What

More information

Getting the Most out of Playgrounds in Xcode

Getting the Most out of Playgrounds in Xcode #WWDC18 Getting the Most out of Playgrounds in Xcode Session 402 Tibet Rooney-Rabdau, Xcode Engineer Alex Brown, Core OS Engineer TJ Usiyan, Xcode Engineer 2018 Apple Inc. All rights reserved. Redistribution

More information

Apple Development Technology Workshops

Apple Development Technology Workshops Apple Development Technology Workshops Workshop 10 Table Views Building iphone Apps. Pt 2 Fall 2008 Hafez Rouzati Fall 2008 Zach Pousman Last Week UIViewControllers Organizing Content & Building iphone

More information

SFU CMPT 361 Computer Graphics Fall 2017 Assignment 2. Assignment due Thursday, October 19, 11:59pm

SFU CMPT 361 Computer Graphics Fall 2017 Assignment 2. Assignment due Thursday, October 19, 11:59pm SFU CMPT 361 Computer Graphics Fall 2017 Assignment 2 Assignment due Thursday, October 19, 11:59pm For this assignment, you are to interpret a 3D graphics specification language, along with doing some

More information

Assignment III: Graphing Calculator

Assignment III: Graphing Calculator Assignment III: Graphing Calculator Objective You will enhance your Calculator to create a graph of the program the user has entered which can be zoomed in on and panned around. Your app will now work

More information

CS193p Spring 2010 Wednesday, March 31, 2010

CS193p Spring 2010 Wednesday, March 31, 2010 CS193p Spring 2010 Logistics Lectures Building 260 (History Corner) Room 034 Monday & Wednesday 4:15pm - 5:30pm Office Hours TBD Homework 7 Weekly Assignments Assigned on Wednesdays (often will be multiweek

More information

OpenGL ES for iphone Games. Erik M. Buck

OpenGL ES for iphone Games. Erik M. Buck OpenGL ES for iphone Games Erik M. Buck Topics The components of a game n Technology: Graphics, sound, input, physics (an engine) n Art: The content n Fun: That certain something (a mystery) 2 What is

More information

Lecture 5 Demo Code: FaceIt MVC and Gestures

Lecture 5 Demo Code: FaceIt MVC and Gestures Lecture 5 Demo Code: FaceIt MVC and Gestures Objective Included below is the source code for the demo in lecture. It is provided under the same Creative Commons licensing as the rest of CS193p s course

More information

Assignment III: Graphing Calculator

Assignment III: Graphing Calculator Assignment III: Graphing Calculator Objective The goal of this assignment is to reuse your CalculatorBrain and CalculatorViewController objects to build a Graphing Calculator for iphone and ipad. By doing

More information

Mobile Application Programming. Controls

Mobile Application Programming. Controls Mobile Application Programming Controls Views UIView instances and subclasses Form a tree rooted at the window Have a backing store of pixels that are drawn seldomly, then composited to form the full user

More information

Modern User Interaction on ios

Modern User Interaction on ios App Frameworks #WWDC17 Modern User Interaction on ios Mastering the UIKit UIGesture System Session 219 Dominik Wagner, UIKit Engineer Michael Turner, UIKit Engineer Glen Low, UIKit Engineer 2017 Apple

More information

Objective-C Primer. iphone Programmer s Association. Lorenzo Swank September 10, 2008

Objective-C Primer. iphone Programmer s Association. Lorenzo Swank September 10, 2008 Objective-C Primer iphone Programmer s Association Lorenzo Swank September 10, 2008 Disclaimer Content was blatantly and unapologetically stolen from the WWDC 2007 Fundamentals of Cocoa session, as well

More information

EXAMINATIONS 2016 TRIMESTER 2

EXAMINATIONS 2016 TRIMESTER 2 EXAMINATIONS 2016 TRIMESTER 2 CGRA 151 INTRODUCTION TO COMPUTER GRAPHICS Time Allowed: TWO HOURS CLOSED BOOK Permitted materials: Silent non-programmable calculators or silent programmable calculators

More information

CSC 581: Mobile App Development Spring 2018

CSC 581: Mobile App Development Spring 2018 CSC 581: Mobile App Development Spring 2018 Unit 2: Introduciton to the UIKit UIKit, UIViews UIControl subclasses 1 UIKit the UIKit is a code framework for building mobile apps the foundational class for

More information

View Controller Advancements for ios8

View Controller Advancements for ios8 Frameworks #WWDC14 View Controller Advancements for ios8 Session 214 Bruce D. Nilo Manager, UIKit Fundamentals 2014 Apple Inc. All rights reserved. Redistribution or public display not permitted without

More information

let w = UIWindow(frame: UIScreen.mainScreen().bounds)

let w = UIWindow(frame: UIScreen.mainScreen().bounds) PART I Views The things that appear in your app s interface are, ultimately, views. A view is a unit of your app that knows how to draw itself. A view also knows how to sense that the user has touched

More information

CHAPTER 1 Graphics Systems and Models 3

CHAPTER 1 Graphics Systems and Models 3 ?????? 1 CHAPTER 1 Graphics Systems and Models 3 1.1 Applications of Computer Graphics 4 1.1.1 Display of Information............. 4 1.1.2 Design.................... 5 1.1.3 Simulation and Animation...........

More information

For each question, indicate whether the statement is true or false by circling T or F, respectively.

For each question, indicate whether the statement is true or false by circling T or F, respectively. True/False For each question, indicate whether the statement is true or false by circling T or F, respectively. 1. (T/F) Rasterization occurs before vertex transformation in the graphics pipeline. 2. (T/F)

More information

Stanford CS193p. Developing Applications for ios. Fall CS193p. Fall

Stanford CS193p. Developing Applications for ios. Fall CS193p. Fall Stanford Developing Applications for ios Today Drag and Drop Transferring information around within and between apps. EmojiArt Demo Drag and drop an image to get our EmojiArt masterpieces started. UITableView

More information

From the dock at the left, right, top, or bottom of your monitor screen, open the Finder.

From the dock at the left, right, top, or bottom of your monitor screen, open the Finder. GETTING STARTED Composition & Defamiliarization: Using Adobe Illustrator as a Tool Kristen Foster 2010 Drawing and Composition Module OTIS College of Art and Design Trash preferences + Open Illustrator

More information

What s New in Core Image

What s New in Core Image Media #WWDC15 What s New in Core Image Session 510 David Hayward Engineering Manager Tony Chu Engineer Alexandre Naaman Lead Engineer 2015 Apple Inc. All rights reserved. Redistribution or public display

More information

ITP 342 Mobile App Dev. Animation

ITP 342 Mobile App Dev. Animation ITP 342 Mobile App Dev Animation Core Animation Introduced in Mac OS X Leopard Uses animatable "layers" built on OpenGL UIKit supports Core Animation out of the box Every UIView has a CALayer behind it

More information

ITP 342 Mobile App Dev. Animation

ITP 342 Mobile App Dev. Animation ITP 342 Mobile App Dev Animation Views Views are the fundamental building blocks of your app's user interface, and the UIView class defines the behaviors that are common to all views. Responsibilities

More information

LESSONS LEARNED. SWIFT. Dagna Bieda, 7th April 2016

LESSONS LEARNED. SWIFT. Dagna Bieda, 7th April 2016 LESSONS LEARNED. SWIFT Dagna Bieda, 7th April 2016 SWIFT & XCODE Brief Intro Language that essentially marries the readability of Python with the speed of C++. @jeremyconkin SWIFT mix of good practices

More information

Contents. iphone Training. Industry Trainers. Classroom Training Online Training ON-DEMAND Training. Read what you need

Contents. iphone Training. Industry Trainers. Classroom Training Online Training ON-DEMAND Training. Read what you need iphone Training Contents About iphone Training Our ios training classes can help you get off to a running start in iphone, ipod and ipad app development. Learn from expert Objective-C developers with years

More information

Output models Drawing Rasterization Color models

Output models Drawing Rasterization Color models Output models Drawing Rasterization olor models Fall 2004 6.831 UI Design and Implementation 1 Fall 2004 6.831 UI Design and Implementation 2 omponents Graphical objects arranged in a tree with automatic

More information

(a) rotating 45 0 about the origin and then translating in the direction of vector I by 4 units and (b) translating and then rotation.

(a) rotating 45 0 about the origin and then translating in the direction of vector I by 4 units and (b) translating and then rotation. Code No: R05221201 Set No. 1 1. (a) List and explain the applications of Computer Graphics. (b) With a neat cross- sectional view explain the functioning of CRT devices. 2. (a) Write the modified version

More information

Sign up for crits! Announcments

Sign up for crits! Announcments Sign up for crits! Announcments Reading for Next Week FvD 16.1-16.3 local lighting models GL 5 lighting GL 9 (skim) texture mapping Modern Game Techniques CS248 Lecture Nov 13 Andrew Adams Overview The

More information

Leveraging Touch Input on ios

Leveraging Touch Input on ios App Frameworks #WWDC16 Leveraging Touch Input on ios And getting the most out of Apple Pencil Session 220 Dominik Wagner UIKit Engineer 2016 Apple Inc. All rights reserved. Redistribution or public display

More information

Scene Graphs. CS4620/5620: Lecture 7. Announcements. HW 1 out. PA 1 will be out on Wed

Scene Graphs. CS4620/5620: Lecture 7. Announcements. HW 1 out. PA 1 will be out on Wed CS4620/5620: Lecture 7 Scene Graphs 1 Announcements HW 1 out PA 1 will be out on Wed Next week practicum will have an office hour type session on Open GL 2 Example Can represent drawing with flat list

More information

Building Visually Rich User Experiences

Building Visually Rich User Experiences Session App Frameworks #WWDC17 Building Visually Rich User Experiences 235 Noah Witherspoon, Software Engineer Warren Moore, Software Engineer 2017 Apple Inc. All rights reserved. Redistribution or public

More information

Solution Notes. COMP 151: Terms Test

Solution Notes. COMP 151: Terms Test Family Name:.............................. Other Names:............................. ID Number:............................... Signature.................................. Solution Notes COMP 151: Terms

More information

RENDERING TECHNIQUES

RENDERING TECHNIQUES RENDERING TECHNIQUES Colors in Flash In Flash, colors are specified as numbers. A color number can be anything from 0 to 16,777,215 for 24- bit color which is 256 * 256 * 256. Flash uses RGB color, meaning

More information