I would really like to use the OSX Dropshadow availability within the canvas gadgets and have no real idea how to code this in PB.
Can someone provide me with the cocoa calls to undertake this facility?
Thanks in advance.
Drop Shadow in Canvas Gadget
Re: Drop Shadow in Canvas Gadget
Code: Select all
ImportC ""
CGColorCreateGenericRGB(red.CGFloat, green.CGFloat, blue.CGFloat, alpha.CGFloat)
CGColorRelease(color)
CGContextSetShadowWithColor(context, x_offset.CGFloat, y_offset.CGFloat, blur.CGFloat, color)
EndImport
If OpenWindow(0, 0, 0, 400, 200, "VectorDrawing", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
CanvasGadget(0, 0, 0, 400, 200)
CGContext = StartVectorDrawing(CanvasVectorOutput(0))
If CGContext
VectorSourceColor(RGBA(255, 0, 0, 255))
; Enable dark blue shadow
ShadowColor = CGColorCreateGenericRGB(0, 0, 0.4, 0.8)
CGContextSetShadowWithColor(CGContext, 4, -4, 4, ShadowColor)
CGColorRelease(ShadowColor)
MovePathCursor(100, 100)
AddPathCircle(100, 100, 75, 0, 235, #PB_Path_Connected)
ClosePath()
StrokePath(10)
; Disable shadow
CGContextSetShadowWithColor(CGContext, 0, 0, 0, #Null)
MovePathCursor(300, 100)
AddPathCircle(300, 100, 75, 0, 235, #PB_Path_Connected)
ClosePath()
StrokePath(10)
StopVectorDrawing()
EndIf
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
EndIf
Windows (x64)
Raspberry Pi OS (Arm64)
Raspberry Pi OS (Arm64)
Re: Drop Shadow in Canvas Gadget
Wilbert
Yet again, you have provided the perfect example and answer to my question. Thank you.
I am new to PB and really exploring the software. I am a Xojo user and about to decide to drop Xojo altogether in favour of PB.
I have created a significant number of objects that I use in my Xojo apps and am in the process of converting them all to PB code so that I can replicate the solutions. The more that I delve into PB the easier it is to do this and you have been a significant help in this endeavour.
Thanks again.
Simon.
Yet again, you have provided the perfect example and answer to my question. Thank you.
I am new to PB and really exploring the software. I am a Xojo user and about to decide to drop Xojo altogether in favour of PB.
I have created a significant number of objects that I use in my Xojo apps and am in the process of converting them all to PB code so that I can replicate the solutions. The more that I delve into PB the easier it is to do this and you have been a significant help in this endeavour.
Thanks again.
Simon.
Re: Drop Shadow in Canvas Gadget
Cool
Works with fonts...
Works with fonts...
Code: Select all
ImportC ""
CGColorCreateGenericRGB(red.CGFloat, green.CGFloat, blue.CGFloat, alpha.CGFloat)
CGColorRelease(color)
CGContextSetShadowWithColor(context, x_offset.CGFloat, y_offset.CGFloat, blur.CGFloat, color)
EndImport
LoadFont(0, "Arial", 20, #PB_Font_Bold)
If OpenWindow(0, 0, 0, 400, 200, "VectorDrawing", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
CanvasGadget(0, 0, 0, 400, 200)
CGContext = StartVectorDrawing(CanvasVectorOutput(0))
If CGContext
VectorSourceColor(RGBA(255, 0, 0, 255))
; Enable dark blue shadow
ShadowColor = CGColorCreateGenericRGB(0, 0, 0.4, 0.8)
CGContextSetShadowWithColor(CGContext, 4, -4, 4, ShadowColor)
CGColorRelease(ShadowColor)
MovePathCursor(40, 55)
VectorFont(FontID(0), 85)
DrawVectorText("Purebasic")
; Disable shadow
CGContextSetShadowWithColor(CGContext, 0, 0, 0, #Null)
StopVectorDrawing()
EndIf
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
EndIf
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive