Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@jspahrsummers
Last active April 29, 2021 01:55
Show Gist options
  • Star 11 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jspahrsummers/4305792 to your computer and use it in GitHub Desktop.
Save jspahrsummers/4305792 to your computer and use it in GitHub Desktop.
CGRectDivideWithPadding illustrations

Simple visual illustrations of how CGRectDivideWithPadding works.

Slicing from CGRectMinXEdge
  +-------+---------+------------>
e |       |         |
d | slice | padding | remainder…
g |       |         |
e |       |         |
  +-------+---------+------------>
Slicing from CGRectMaxXEdge
<-----------+---------+-------+
            |         |       | e
 remainder… | padding | slice | d
            |         |       | g
            |         |       | e
<-----------+---------+-------+
Slicing from CGRectMinYEdge (assuming a top-left origin)
    edge
+-----------+
|           |
|   slice   |
|           |
+-----------+
|           |
|  padding  |
|           |
+-----------+
|           |
| remainder |
|           |
⇣           ⇣
Slicing from CGRectMaxYEdge (assuming a top-left origin)
⇡           ⇡
|           |
| remainder |
|           |
+-----------+
|           |
|  padding  |
|           |
+-----------+
|           |
|   slice   |
|           |
+-----------+
    edge
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment