[View] [Edit] [Lock] [References] [Attachments] [History] [Home] [Changes] [Search] [Help]
api[apple,CGGeometry]
"CGGeometry APIImplementation executable in both iOS and OSX execution environments."
NativeObject
subclass: #CGGeometryObject
category: #CGGeometry!
#( #CGPoint #CGSize #CGRect
#CGColor #CGContext
) do: [:each| CGGeometryObject subclass: each ]!
! CGColor class methodsFor: #constants !
getConstantColor: colorName
" Private - Return the constant color with colorName. "
^self @ (# #CGColorGetConstantColor: colorName)! !
! CGColor class methodsFor: #constants !
white
^self getConstantColor: #kCGColorWhite! !
! CGColor class methodsFor: #constants !
black
^self getConstantColor: #kCGColorBlack! !
! CGColor class methodsFor: #constants !
clear
^self getConstantColor: #kCGColorClear! !
! CGColor class methodsFor: #constants !
transparent
^self clear! !
CGPoint buildNumberAccessors: #( x y )!
CGSize buildNumberAccessors: #( width height )!
CGRect buildTypedAccessors: #(
#( origin #CGPoint )
#( size #CGSize )
)!
! CGGeometryObject class methodsFor: #converting !
instance: anAlien
" Return an instance of the receiver converted from anAlien. "
(self isObject: anAlien) ifFalse: [ ^self @ anAlien ].
(anAlien isKindOf: self) ifTrue: [ ^anAlien ].
^self @ anAlien! !
! CGPoint methodsFor: #accessing !
handle: anAlien
" Set the native handle to a potentialy non-StObject. "
(self isObject: anAlien) ifTrue: [
(anAlien isMemberOf: Point) ifTrue: [
^super handle: (Point newCGPoint: anAlien x y: anAlien y)
].
anAlien isNumber ifTrue: [ ^self handle: anAlien @ anAlien ].
].
^super handle: anAlien! !
! CGSize methodsFor: #accessing !
handle: anAlien
" Set the native handle to a potentialy non-StObject. "
(self isObject: anAlien) ifTrue: [
(anAlien isMemberOf: Point) ifTrue: [
^super handle: (Point newCGSize: anAlien x height: anAlien y)
].
anAlien isNumber ifTrue: [ ^self handle: anAlien @ anAlien ].
].
^super handle: anAlien! !
! CGRect methodsFor: #accessing !
handle: anAlien
" Set the native handle to a potentialy non-StObject. "
(self isObject: anAlien) ifFalse: [ ^super handle: anAlien ].
anAlien isRectangle ifTrue: [ ^super handle: anAlien asCGRect ].
^super handle: anAlien! !
! CGPoint methodsFor: #converting !
asPoint
^self x @ self y! !
! CGSize methodsFor: #converting !
asPoint
^self width @ self height! !
! CGRect methodsFor: #converting !
asRectangle
^self origin asPoint extent: self size asPoint! !
! CGRect methodsFor: #accessing !
extent
^self size asPoint! !
! CGRect methodsFor: #accessing !
center
^self extent / (2@2)
+ self origin asPoint! !
! CGPoint class methodsFor: #instantiating !
x: x y: y
^self @ (x @ y)! !
! CGSize class methodsFor: #instantiating !
x: x y: y
^self @ (x @ y)! !
! CGSize class methodsFor: #instantiating !
width: x height: y
^self @ (x @ y)! !
! Point class methodsFor: 'CGGeometry-private' !
newCGPoint: x y: y
^{'new CGPoint(x,y);'}! !
! Point class methodsFor: 'CGGeometry-private' !
newCGSize: width height: height
^{'new CGSize(width,height);'}! !
! Rectangle class methodsFor: 'CGGeometry-private' !
newCGRect: x y: y width: width height: height
^{'new CGRect(x,y,width,height);'}! !
! Rectangle class methodsFor: 'CGGeometry-private' !
fromCGRect: aCGRect
^aCGRect#origin#x @ aCGRect#origin#y
extent: aCGRect#size#width @ aCGRect#size#height! !
! Rectangle methodsFor: 'CGGeometry-private' !
asCGRect
" ObjC - Return a native CGRect from the receiver. "
^{'new CGRect(self.left(),self.top(),self.width(),self.height());'}! !
"TODO: Needs work to complete CGContext "!
! CGContext methodsFor: #shadow !
setShadow: cgSizeOffset blur: aFloat
" Enables shadowing in a graphics context. "
^# #CGContextSetShadow: self handle
offset: (CGSize instance: cgSizeOffset) handle
blur: aFloat! !
! CGContext methodsFor: #fill !
setFillColor: aCGColor
" Sets the current fill color in a graphics context, using a Quartz color. "
^# #CGContextSetFillColorWithColor: self handle color: aCGColor handle! !
! CGContext methodsFor: #stroke !
setStrokeColor: aCGColor
" Sets the current stroke color in a graphics context, using a Quartz color. "
^# #CGContextSetStrokeColorWithColor: self handle color: aCGColor handle! !
! CGContext methodsFor: #paths !
moveToPoint: x y: y
" Begins a new subpath at x@y. "
^# #CGContextMoveToPoint: self handle x: x y: y! !
! CGContext methodsFor: #paths !
moveToPoint: aPoint
" Begins a new subpath at aPoint. "
^self moveToPoint: aPoint x y: aPoint y! !
! CGContext methodsFor: #paths !
moveTo: aPoint
" Begins a new subpath at aPoint. "
^self moveToPoint: aPoint x y: aPoint y! !
! CGContext methodsFor: #paths !
addLineToPoint: x y: y
" Appends a straight line segment from the current point to x@y. "
^# #CGContextAddLineToPoint: self handle x: x y: y! !
! CGContext methodsFor: #paths !
lineToPoint: aPoint
" Appends a straight line segment from the current point to aPoint. "
^self addLineToPoint: aPoint x y: aPoint y! !
! CGContext methodsFor: #paths !
lineTo: aPoint
" Appends a straight line segment from the current point to aPoint. "
^self addLineToPoint: aPoint x y: aPoint y! !
! CGContext methodsFor: #paths !
fillPath
" Paints the area within the current path, using the nonzero winding number rule. "
^# #CGContextFillPath: self handle! !
! CGContext methodsFor: #paths !
strokePath
" Paints a line along the current path. "
^# #CGContextStrokePath: self handle! !