Making gradients able to use theme colors
Regina Henschel
rb.henschel at t-online.de
Sun Aug 6 10:39:43 UTC 2023
Hi Tomaž,
you have started to replace css.rendering.RGBColor by
css.util.XComplexColor in struct ColorStop in API. I don't see how I can
then generate a gradient as it is done in the macro example below. How
does the macro then need to be changed?
Kind regards,
Regina
function getLongColorFromDecColor(aDecColor as
com.sun.star.rendering.RGBColor) as long
dim nRed as integer: nRed = CInt(aDecColor.Red * 255.0)
dim nGreen as integer: nGreen = CInt(aDecColor.Green * 255.0)
dim nBlue as integer: nBlue = CInt(aDecColor.Blue * 255.0)
getLongColorFromDecColor = RGB(nRed,nGreen,nBlue)
end function
function createDecColor(nRed as integer, nGreen as integer, nBlue as
integer) _
as com.sun.star.rendering.RGBColor
dim aNewColor as new com.sun.star.rendering.RGBColor
aNewColor.Red = nRed / 255.0
aNewColor.Green = nGreen / 255.0
aNewColor.Blue = nBlue / 255.0
createDecColor = aNewColor
end function
sub createExampleGradient _
(oGradient as com.sun.star.awt.Gradient2)
rem Creates a Gradient with three colors
'Define the colors
dim aDecStartColor as new com.sun.star.rendering.RGBColor
aDecStartColor = createDecColor(0, 192, 0)
dim aDecBetweenColor as new com.sun.star.rendering.RGBColor
aDecBetweenColor = createDecColor(255, 255, 0)
dim aDecEndColor as new com.sun.star.rendering.RGBColor
aDecEndColor = createDecColor(255, 0, 0)
'Create ColorStops array
dim aColorStops(2) as new com.sun.star.awt.ColorStop
dim aStop as new com.sun.star.awt.ColorStop
aStop.StopColor = aDecStartColor
aStop.StopOffset = 0
aColorStops(0) = aStop
aStop.StopColor = aDecBetweenColor
aStop.StopOffset = 0.6
aColorStops(1) = aStop
aStop.StopColor = aDecEndColor
aStop.StopOffset = 1
aColorStops(2) = aStop
'For start and end we need the 'long' data type in addition
dim nStartColor as long
nStartColor = getLongColorFromDecColor(aDecStartColor)
dim nEndColor as long
nEndColor = getLongColorFromDecColor(aDecEndColor)
'Create gradient
With oGradient
.ColorStops = aColorStops
.Style = com.sun.star.awt.GradientStyle.LINEAR
.StartColor = nStartColor: 'long
.EndColor = nEndColor: 'long
.Angle = 0: '1/10 degree
.Border = 0: 'percent
.XOffset = 0: 'percent
.YOffset = 0: 'percent
.StartIntensity = 100: 'percent
.EndIntensity = 100: 'percent
.StepCount = 0: '0=automatic, otherwise in range 3..255
End With
end sub
More information about the LibreOffice
mailing list