Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
iOS Core Animation Transform
Search
Qing-Cheng Li
February 12, 2015
Programming
0
160
iOS Core Animation Transform
Introduction to iOS Core Animation Transform
Qing-Cheng Li
February 12, 2015
Tweet
Share
More Decks by Qing-Cheng Li
See All by Qing-Cheng Li
Using Buck to save iOS project build time
qcl
0
1k
Mobile App Continuous Delivery
qcl
0
190
XingZhe - iOS BDD UI Automation Test Framework
qcl
0
500
High Performance iOS Apps Testing and Release
qcl
0
93
Mobile App Continuous Delivery
qcl
0
96
How QCLean Works: Introduction to Browser Extensions
qcl
0
630
黑暗時代網頁程式設計 - HTML
qcl
0
99
Big Data Processing lol
qcl
1
110
油電雙掌
qcl
0
810
Other Decks in Programming
See All in Programming
採用事例の少ないSvelteを選んだ理由と それを正解にするためにやっていること
oekazuma
2
1.1k
情報漏洩させないための設計
kubotak
5
1.2k
ゆるやかにgolangci-lintのルールを強くする / Kyoto.go #56
utgwkk
2
710
Go の GC の不得意な部分を克服したい
taiyow
3
950
Cloudflare MCP ServerでClaude Desktop からWeb APIを構築
kutakutat
1
620
PSR-15 はあなたのための ものではない? - phpcon2024
myamagishi
0
340
開発者とQAの越境で自動テストが増える開発プロセスを実現する
92thunder
1
220
htmxって知っていますか?次世代のHTML
hiro_ghap1
0
390
Kaigi on Railsに初参加したら、その日にLT登壇が決定した件について
tama50505
0
130
Асинхронность неизбежна: как мы проектировали сервис уведомлений
lamodatech
0
1.2k
見えないメモリを観測する: PHP 8.4 `pg_result_memory_size()` とSQL結果のメモリ管理
kentaroutakeda
0
860
テストケースの名前はどうつけるべきか?
orgachem
PRO
1
180
Featured
See All Featured
Speed Design
sergeychernyshev
25
720
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
127
18k
Put a Button on it: Removing Barriers to Going Fast.
kastner
59
3.6k
Side Projects
sachag
452
42k
The Invisible Side of Design
smashingmag
299
50k
Building Better People: How to give real-time feedback that sticks.
wjessup
366
19k
The Language of Interfaces
destraynor
155
24k
Designing for Performance
lara
604
68k
Building an army of robots
kneath
302
44k
Making Projects Easy
brettharned
116
6k
Done Done
chrislema
182
16k
Into the Great Unknown - MozCon
thekraken
34
1.6k
Transcript
Transforms @qcl 2015.02.12
None
Transform • Affine Transforms ◦ CGAffineTransform ◦ view.layer.affineTransform • 3D
Transforms ◦ CATransform3D ◦ view.layer.transfrom ◦ view.layer.sublayerTransform
Affine Transforms • Math behind the matrix ◦ https://developer.apple. com/library/mac/documentation/GraphicsImaging/Co
nceptual/drawingwithquartz2d/dq_affine/dq_affine. html#//apple_ref/doc/uid/TP30001066-CH204-
Affine Transforms • Rotation ◦ CGAffineTransformMakeRotation(CGFloat angle) • Scale ◦
CGAffineTransformMakeScale(CGFloat sx, CGFloat sy) • Translation ◦ CGAffineTransformMakeTranslation(CGFloat tx, CGFloat ty)
Combining Transforms • CGAffineTransformIdentity ◦ A 3x3 Identity matrix •
Rotation ◦ CGAffineTransformRotate(CGAffineTransform t, CGFloat angle) • Scale ◦ CGAffineTransformScale(CGAffineTransform t, CGFloat sx, CGFloat sy) • Translation ◦ CGAffineTransformTranslate(CGAffineTransform t, CGFloat tx, CGFloat ty) • The order you apply transforms is important! ◦ 矩陣乘法沒有交換律
Customized Affine Transform • You can set the fileds of
a CGAffineTransform directly. ◦ a ◦ b ◦ c ◦ d ◦ t x ◦ t y
3D Transforms
3D Transforms • Left hand coordinate system
3D Transforms • Rotation ◦ CATransform3DMakeRotatation(CGFloat angle, CGFloat x, CGFloat
y, CGFloat z) • Scale ◦ CATransform3DMakeScale(CGFloat sx, CGFloat sy, CGFloat sz) • Translation ◦ CATransform3DMakeTranslation(CGFloat tx, CGFloat ty, CGFloat tz)
3D Transforms Combination • CATransform3DIdentity ◦ A 4x4 identity matrix
• Rotation ◦ CATransform3DRotate(CATransform3D t, CGFloat angle, CGFloat x, CGFloat y, CGFloat z) • Scale ◦ CATransform3DScale(CATransform3D t, CGFloat sx, CGFloat sy, CGFloat sz) • Translation ◦ CATransform3DTranslate(CATransform3D t, CGFloat tx, CGFloat ty, CGFloat tz)
Perspective Projection • Prespective transform sometimes called Z transform
Perspective Projection • m34 of CATransform3D • -1 / d
• More: ◦ http://en.wikipedia. org/wiki/3D_projection#Perspective_projection
Vanishing Point • anchorPoint
sublayerTransform • Apply to sublayer but not affect itself. •
The vanishing point is the anchorPoint of itself, not sublayer’s anchorPoint
Backfaces • view.layer.doubleSided
Layer Flattening • Expected result is wrong. • The layers
don’t exist in the same 3D space. • The 3D sence in each layer is flattened.