Help with CGContext
Posted: Fri Jul 08, 2011 6:10 pm
Can someone please point out where I've gone wrong here?
I'll be grateful for any assistance.
Thank you.
Code: Select all
EnableExplicit
#MainWindow=1
Structure CGPoint
x.f
y.f
EndStructure
Structure CGSize
width.f
height.f
EndStructure
Structure CGRect
origin.CGPoint
size.CGSize
EndStructure
Define clipRect.CGRect, cg.l, *wPort, OSStat.L
ImportC ""
GetWindowPort(*WindowRef)
QDBeginCGContext(*WindowPtr, *CGContextRef)
QDEndCGContext(*WindowPtr, *CGContextRef)
CGContextSetRGBFillColor(*CGContextRef, r.f, g.f, b.f, a.f)
CGContextFillRect(*CGContextRef, *fillArea.CGRect)
CGContextFlush(*CGContextRef)
CGMakeRect(x.f, y.f, width.f, height.f)
EndImport
OpenWindow(#MainWIndow, 0, 0, 500, 500, "Carbon CGTest")
;clipRect=CGMakeRect(0, 0, 600, 600)
; --> CGRectMake not found/doesn't work!?
; --> manually populating the CGRect structure
With clipRect
\origin\x=10
\origin\y=10
\size\height=300
\size\width=300
EndWith
*wPort = GetWindowPort(WindowID(#MainWindow))
OSStat = QDBeginCGContext(*wPort, @cg)
CGContextSetRGBFillColor(cg, 0.8, 0.5, 0.2, 1.0)
CGContextFillRect(cg, clipRect)
CGContextFlush(cg)
QDEndCGContext(*wPort, @cg)
Repeat
Event = WindowEvent()
Until event = #PB_Event_CloseWindow
EndThank you.