Sub Paint(g As Graphics, areas() As REALbasic.Rect)
DropShadow(g, &cF4A80800, 8, -8, 10)
g.FillRect(50, 50, 100, 100)
End Sub
Structure NSSize
Width As CGFloat
Height As CGFloat
End Structure
[code]Private Sub DropShadow(g As Graphics, shadowColor As Color, x As Double, y As Double, blur As Double)
Declare Sub CGContextSetShadow Lib “CoreGraphics” (context As Integer, offset As NSSize, blur As CGFloat)
Declare Sub CGContextSetShadowWithColor Lib “CoreGraphics” (context As Integer, offset As NSSize, blur As CGFloat, CGColorRef As Ptr)
Declare Function CGColorSpaceCreateWithName Lib “CoreGraphics” (name As CFStringRef) As Ptr
Declare Function CGColorCreate Lib “CoreGraphics” (space As Ptr, components As Ptr) As Ptr
Dim context As Integer = g.Handle(g.HandleTypeCGContextRef)
Dim s As NSSize
s.Width = x
s.Height = y
Dim cspace, colorref As Ptr
Dim components As New MemoryBlock(4 * If(Target64Bit, 8, 4))
#If Target32Bit
components.SingleValue(0 * 4) = shadowColor.Red / 255
components.SingleValue(1 * 4) = shadowColor.Green / 255
components.SingleValue(2 * 4) = shadowColor.Blue / 255
components.SingleValue(3 * 4) = 100 / 100
#ElseIf Target64Bit
components.DoubleValue(0 * 8) = shadowColor.Red / 255
components.DoubleValue(1 * 8) = shadowColor.Green / 255
components.DoubleValue(2 * 8) = shadowColor.Blue / 255
components.DoubleValue(3 * 8) = 100 / 100
#Endif
cspace = CGColorSpaceCreateWithName(“kCGColorSpaceGenericRGB”)
colorref = CGColorCreate(cspace, components)
CGContextSetShadowWithColor(context, s, blur, colorref)
End Sub[/code]
I by myself looking for native declarations to do the same on Windows and Linux.