translucency.box

Translucent colors through Cairo

../../_images/translucency.png

It is highly recommended to compile Box with Cairo support. You’ll then be able to use translucent colors, color gradients and many others useful features. To run this example you will need the following file(s): ./translucency.box. If the example requires more than one file, then you should put them into the same directory. You can then launch Box with box -l g ./translucency.box.

// Under a shell type: box -l g translucent.box
// ---
// Here we show translucent effects on Cairo Windows.

include "g"

w = Window[][
  BBox[(-20, -18), (20, 22)]
  c1 = Color[color.red,  .a=0.5], c2 = Color[color.yellow, .a=0.5]
  c3 = Color[color.blue, .a=0.5], c4 = Color[color.green, .a=0.5]
  radius = 20.0

  Circle[(-5, -2), 4, c4]                            // One circle (behind)
  i = 0, delta = 4*const.pi/5, angle0 = const.pi/2   // The star
  Line[radius*Vec[i*delta + angle0], For[++i < 5]
       Close[], Border[2, c1, Join["round"]]]
  Circle[(2, -5), 8, c2]                             // Other two circles
  Circle[(-1, 1), 6, c3]
]

w.Save["translucency.png"
       Window["rgb24", .Res[Dpi[100]]]]              // Save to PNG

Table Of Contents



This Page



Get The figure description language: Box at SourceForge.net. Fast, secure and Free Open Source software downloads