Giving a custom style a colored gradient background
I'm not sure how exactly to integrate this with a stylesheet background, but here is a way to achieve gradients using Graphics
:
Overlay@{
Graphics[
Raster@{List@@@Table[Blend["AvocadoColors",i],{i,0,1,.005}]},
AspectRatio->1/2,
ImageSize->Full],
Graphics[
Text@Style["Gradient!",FontSize->[email protected]],
AspectRatio->1/2,
ImageSize->Full]}
EDIT
I stumbled on a different way to do this that would be easier for simple layouts (tidied up with kguler's suggestion):
Graphics[{
Polygon[
{{0, 0}, {1, 0}, {1, 1}, {0, 1}},
VertexColors -> {Yellow, Yellow, Green, Green}],
Text[
Style["Gradient!", FontSize -> [email protected]],
Scaled[{.5, .5}]]}, ImageSize -> Full, AspectRatio -> 1/2]
In versions 11.1+, you can use LinearGradientImage
and add the text as Epilog
:
Show[LinearGradientImage["BlueGreenYellow", 6 {100, 50}],
Epilog -> {Text[Style["Gradient!", FontFamily -> "Old English Text MT",
FontSize -> [email protected]], Scaled[{.5, .5}]]}]
Replace "BlueGreenYellow"
with {Black, Red, Orange, White}
to get
Update: In versions 12.2.0+, gradient filling is available as a graphics directive:
Graphics[{LinearGradientFilling["BlueGreenYellow"], Rectangle[],
Text[Style["Gradient!", FontSize -> [email protected]], Scaled[{.5, .5}]]},
AspectRatio -> 1/2]