You can Google for "NSBezierPath Class Reference" .
It's the document from Apple describing all methods.
Here's a modified example with line width and dash
Code: Select all
Dim LineDashPattern.CGFloat(3)
LineDashPattern(0) = 9
LineDashPattern(1) = 6
LineDashPattern(2) = 3
LineDashPattern(3) = 6
LineWidth.CGFloat = 3
CocoaMessage(0, 0, "NSBezierPath setDefaultLineWidth:@", @LineWidth)
; *** Create image and draw onto it ***
CreateImage(0, 300, 200, 32, #PB_Image_Transparent)
StartDrawing(ImageOutput(0))
Crayons = CocoaMessage(0, CocoaMessage(0, 0, "NSColorList colorListNamed:$", @"Crayons"), "retain")
ColorGreen = CocoaMessage(0, 0, "NSColor greenColor")
ColorBrown = CocoaMessage(0, 0, "NSColor brownColor")
ColorMocha = CocoaMessage(0, Crayons, "colorWithKey:$", @"Mocha")
CocoaMessage(0, ColorMocha, "setStroke"); set stroke color to Mocha
Gradient = CocoaMessage(0, 0, "NSGradient alloc"); create gradient from green to brown
CocoaMessage(@Gradient, Gradient, "initWithStartingColor:", ColorGreen, "endingColor:", ColorBrown)
CocoaMessage(0, Gradient, "autorelease")
GradientAngle.CGFloat = 315
Rect.NSRect
Rect\origin\x = 5
Rect\origin\y = 5
Rect\size\width = 290
Rect\size\height = 190
RadiusX.CGFloat = 20
RadiusY.CGFloat = 20
Path = CocoaMessage(0, 0, "NSBezierPath bezierPathWithRoundedRect:@", @Rect, "xRadius:@", @RadiusX, "yRadius:@", @RadiusY)
Phase.CGFloat = 0
CocoaMessage(0, Path, "setLineDash:", @LineDashPattern(), "count:", 4, "phase:@", @Phase)
CocoaMessage(0, Gradient, "drawInBezierPath:", Path, "angle:@", @GradientAngle)
CocoaMessage(0, Path, "stroke")
StopDrawing()
; *** Show the result ***
If OpenWindow(0, 0, 0, 320, 220, "Drawing", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ImageGadget(0, 10, 10, 300, 200, ImageID(0))
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
EndIf
To draw a circle you need
bezierPathWithOvalInRect: or
appendBezierPathWithOvalInRect: