aboutsummaryrefslogtreecommitdiff
path: root/demos/colorCircular.tcl
blob: 63041c23d3e378e62c33c27e2b080244b43a9eef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# these simple samples have been developped by C. Mertz mertz@cena.fr in perl
# tcl version by Jean-Paul Imbert imbert@cena.fr

if {![info exists zincDemo]} {
    error "This script should be run from the zinc-widget demo."
}

set w .colorCircular
catch {destroy $w}
toplevel $w
wm title $w "Zinc Color Circular Demonstration"
wm iconname $w "Color Circular"

frame $w.buttons
pack $w.buttons -side bottom -fill x -pady 2m
button $w.buttons.dismiss -text Dismiss -command "destroy $w"
button $w.buttons.code -text "See Code" -command "showCode $w"
pack $w.buttons.dismiss $w.buttons.code -side left -expand 1

set defaultfont [font create -family Helvetica -size 10 -weight bold]

zinc $w.zinc -width 700 -height 600 -borderwidth 3 -relief sunken -render 1
pack $w.zinc

$w.zinc add rectangle 1 {10 10 80 80} -fillcolor {=radial 50 50|red|blue} -filled 1
$w.zinc add text 1 -font $defaultfont -text {Radial variation from non-transparent red to non-transparent blue in a square.
The gradient starts in the lower right corner.} -anchor nw -position {120 20}

$w.zinc add arc 1 {10 110 90 190} -fillcolor {=radial 0 25|red;40|blue;40} -filled 1

$w.zinc add text 1 -font $defaultfont -text {Radial variation from 40% transparent red to 40% transparent blue in a disc.
The gradient starts mid way between the center and the bottom.} \
    -anchor nw -position {120 120}

$w.zinc add arc 1 {10 210 90 290} -fillcolor {=radial 0 0|red;40|green;40 50|blue;40} -filled 1

$w.zinc add text 1 -font $defaultfont -text {A variation from 40% transparent red to 40% transparent blue
through 40% green in the middle of the disc. The gradient is centered.} \
    -anchor nw -position {120 220}

$w.zinc add text 1 -font $defaultfont -text {Two overlapping items filled by a transparent radial gradient on a white background.
On the right three gradient filled ovals, note the warped gradients following the ovals.} -anchor w -position {20 320}

$w.zinc add rectangle 1 {10 340 690 590} -fillcolor white -filled  1 

$w.zinc add rectangle 1 {20 365 220 565} -fillcolor {=radial 0 0|red;40|green;40 50|blue;40} -filled 1

$w.zinc add arc 1 {150 365 350 565} -fillcolor {=radial 0 0|yellow;40|black;40 50|cyan;40} -filled 1

$w.zinc add arc 1 {280 365 480 565} -fillcolor {=radial 0 0|black;100|black;100 20|mistyrose;40} -filled 1 -linewidth 0

set warc [$w.zinc add arc 1 {-50 -50 50 50} \
	      -fillcolor {=radial -10 16|black;80|blue;20 90 100} -filled 1]
$w.zinc scale $warc 1.5 1
$w.zinc translate $warc 500 432

set warc [$w.zinc add arc 1 {-50 -50 50 50} \
	      -fillcolor {=radial 0 20|black;70|green;20} -filled 1]
$w.zinc scale $warc 1 1.5
$w.zinc translate $warc 630 432