 			return {}
 		}
 	}
+
+
+
+	public enum Gravity {
+		case BottomCenter
+		case BottomLeft
+		case BottomRight
+		case Center
+		case CenterLeft
+		case CenterRight
+		case TopCenter
+		case TopLeft
+		case TopRight
+
+
+		public init(horizontal: Horizontal, vertical: Vertical) {
+			switch vertical {
+			case .Bottom:
+				switch horizontal {
+					case .Left:   self = .BottomLeft
+					case .Center: self = .BottomCenter
+					case .Right:  self = .BottomRight
+				}
+
+			case .Center:
+				switch horizontal {
+					case .Left:   self = .CenterLeft
+					case .Center: self = .Center
+					case .Right:  self = .CenterRight
+				}
+
+			case .Top:
+				switch horizontal {
+				case .Left:   self = .TopLeft
+				case .Center: self = .TopCenter
+				case .Right:  self = .TopRight
+				}
+			}
+		}
+
+
+		public var horizontal: Horizontal {
+			switch self {
+			case .BottomLeft, .CenterLeft, .TopLeft:
+				return .Left
+
+			case .BottomCenter, .Center, .TopCenter:
+				return .Center
+
+			case .BottomRight, .CenterRight, .TopRight:
+				return .Right
+			}
+		}
+
+
+		public var vertical: Vertical {
+			switch self {
+			case .BottomCenter, .BottomLeft, .BottomRight:
+				return .Bottom
+
+			case .Center, .CenterLeft, .CenterRight:
+				return .Center
+
+			case .TopCenter, .TopLeft, .TopRight:
+				return .Top
+			}
+		}
+
+
+
+		public enum Horizontal {
+			case Center
+			case Left
+			case Right
+		}
+
+
+		public enum Vertical {
+			case Bottom
+			case Center
+			case Top
+		}
+	}
+
+
+	public enum Scaling {
+		case FitIgnoringAspectRatio
+		case FitInside
+		case FitHorizontally
+		case FitHorizontallyIgnoringAspectRatio
+		case FitOutside
+		case FitVertically
+		case FitVerticallyIgnoringAspectRatio
+		case None
+	}
 }
 
 

			imageSize = image.size

			if !imageSize.isEmpty && !availableFrame.isEmpty {
				drawFrame.top = availableFrame.top
				drawFrame.left = availableFrame.left
				drawFrame.size = imageSize

				switch contentMode {
				case .ScaleToFill:
					drawFrame = availableFrame

				case .ScaleAspectFill, .ScaleAspectFit:
					let horizontalScale = availableFrame.width / imageSize.width
					let verticalScale = availableFrame.height / imageSize.height
					let scale = (contentMode == .ScaleAspectFill ? max : min)(horizontalScale, verticalScale)

					drawFrame.width = imageSize.width * scale
					drawFrame.height = imageSize.height * scale

					fallthrough

				case .Center, .Redraw:
					drawFrame.left += (availableFrame.width - drawFrame.width) / 2
					drawFrame.top += (availableFrame.height - drawFrame.height) / 2

				case .Top:
					drawFrame.left += (availableFrame.width - drawFrame.width) / 2

				case .Bottom:
					drawFrame.left += (availableFrame.width - drawFrame.width) / 2
					drawFrame.bottom = availableFrame.bottom

				case .Left:
					drawFrame.top += (availableFrame.height - drawFrame.height) / 2

				case .Right:
					drawFrame.top += (availableFrame.height - drawFrame.height) / 2
					drawFrame.right = availableFrame.right

				case .TopLeft:
					break

				case .TopRight:
					drawFrame.right = availableFrame.right

				case .BottomLeft:
					drawFrame.bottom = availableFrame.bottom

				case .BottomRight:
					drawFrame.bottom = availableFrame.bottom
					drawFrame.right = availableFrame.right
				}

				drawFrame = roundScaled(drawFrame)



	public var preferredSize: CGSize?


	@IBInspectable
	public var scaling: Scaling = .FitInside {
		didSet {
			guard scaling != oldValue else {
				return
			}

			if image != nil {
				setNeedsDisplay()
			}
		}
	}


	public override func sizeThatFitsSize(maximumSize: CGSize) -> CGSize {
