Hi Eugene,
thanks for your reply. No, it’s not directly what I’m looking for. I’d love to create native drop shadows behind Graphics.DrawString like here: https://docs.microsoft.com/en-us/windows/desktop/Direct2D/drop-shadow or here https://www.codeproject.com/Articles/21071/Glow-and-Shadow-Effects-using-Windows-GDI. I’m not fit into Windows, that’s why I asked. Under macOS, this code snippet is enough to create drop shadows:
[code]Declare Sub CGContextSetShadow Lib “CoreGraphics” (context As Integer, offset As CGSize_FTC, blur As CGFloat)
Declare Sub CGContextSetShadowWithColor Lib “CoreGraphics” (context As Integer, offset As CGSize_FTC, 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 CGSize_FTC
s.Width = 8
s.Height = -8
Dim cspace, colorref As Ptr
Dim components As MemoryBlock
Dim shadowColor As Color = &cF4A80800
#If Target32Bit
components = New MemoryBlock(4 * 4) ’ 4 components per color * sizeof(Single)
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 ’ must be single /100
#ElseIf Target64Bit
components = New MemoryBlock(4 * 8) ’ 4 components per color * sizeof(Single)
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 ’ must be single /100
#Endif
cspace = CGColorSpaceCreateWithName(“kCGColorSpaceGenericRGB”)
colorref = CGColorCreate(cspace, components)
CGContextSetShadowWithColor(context, s, 10, colorref)
g.TextSize = 48
g.Bold = True
g.ForeColor = &cFB271100
g.TextFont = “Courier New”
g.DrawString(“Hello World!”, 10, 60)[/code]
CGPoint, CGSize and CGSize are Structures.
CGPoint
x As CGFloat
y As CGFloat
CGSize
width As CGFloat
height As CGFloat
CGRect
origin As CGPoint
rSize As CGSize