1
# $Id: xw30.py 11680 2011-03-27 17:57:51Z airwin $
3
# Copyright (C) 2008 Hazen Babcock
4
# Copyright (C) 2008 Andrew Ross
6
# Alpha color values demonstration.
8
# This file is part of PLplot.
10
# PLplot is free software; you can redistribute it and/or modify
11
# it under the terms of the GNU Library General Public License as published
12
# by the Free Software Foundation; either version 2 of the License, or
13
# (at your option) any later version.
15
# PLplot is distributed in the hope that it will be useful,
16
# but WITHOUT ANY WARRANTY; without even the implied warranty of
17
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
# GNU Library General Public License for more details.
20
# You should have received a copy of the GNU Library General Public License
21
# along with PLplot; if not, write to the Free Software
22
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24
from plplot_py_demos import *
26
red = array([ 0, 255, 0, 0])
27
green = array([ 0, 0, 255, 0])
28
blue = array([ 0, 0, 0, 255])
29
alpha = array([1.0, 1.0, 1.0, 1.0])
31
pos = array([0.0, 1.0])
32
rcoord = array([1.0, 1.0])
33
gcoord = array([0.0, 0.0])
34
bcoord = array([0.0, 0.0])
35
acoord = array([0.0, 1.0])
40
px = array([0.1, 0.5, 0.5, 0.1])
41
py = array([0.1, 0.1, 0.5, 0.5])
45
plscmap0a (red, green, blue, alpha)
50
# This is a series of red, green and blue rectangles overlaid
51
# on each other with gradually increasing transparency.
56
plvpor (0.0, 1.0, 0.0, 1.0)
57
plwind (0.0, 1.0, 0.0, 1.0)
59
plbox ("", 1.0, 0, "", 1.0, 0)
65
# Get a color, change its transparency and
66
# set it as the current color.
67
rgba = plgcol0a (icol)
68
plscol0a (icol, rgba[0], rgba[1], rgba[2], 1.0 - float(i)/9.0)
74
# Shift the rectangles coordinates
81
# This is a bunch of boxes colored red, green or blue with a single
82
# large (red) box of linearly varying transparency overlaid. The
83
# overlaid box is completely transparent at the bottom and completely
89
plvpor(0.1, 0.9, 0.1, 0.9)
90
plwind(0.0, 1.0, 0.0, 1.0)
92
# Draw the boxes. There are 25 of them drawn on a 5 x 5 grid.
95
px[0] = 0.05 + 0.2 * i
100
# We don't want the boxes to be transparent, so since we changed
101
# the colors transparencies in the first example we have to change
102
# the transparencies back to completely opaque.
104
rgba = plgcol0a (icol)
105
plscol0a (icol, rgba[0], rgba[1], rgba[2], 1.0)
108
# Set box y position and draw the box.
109
py[0] = 0.05 + 0.2 * j
115
# Create the color map with 128 colors and use plscmap1la to initialize
116
# the color values with a linearly varying red transparency (or alpha)
118
plscmap1la(1, pos, rcoord, gcoord, bcoord, acoord, rev)
120
# Use that cmap1 to create a transparent red gradient for the whole
132
plgradient(px, py, 90.)