Repository: bokeh/bokeh

Issue:
Add alpha control for ImageURL objects
It's apparently possible to adjust the transparency of an HTML Canvas element (http://stackoverflow.com/questions/2359537/how-to-change-the-opacity-alpha-transparency-of-an-element-in-a-canvas-elemen), but there doesn't seem to be a way to adjust the transparency of ImageURL objects in Bokeh at present.  

It would be extremely useful if we could do so, both for compositing multiple images and for adjusting the effective brightness of an image used as a background element in a plot.  There might be other Bokeh objects that could make use of such a parameter as well, but ImageURL is the one we need most urgently.



Discussion:

Resolving patch:
diff --git a/bokeh/models/glyphs.py b/bokeh/models/glyphs.py
--- a/bokeh/models/glyphs.py
+++ b/bokeh/models/glyphs.py
@@ -8,7 +8,7 @@
 from ..plot_object import PlotObject
 from ..mixins import FillProps, LineProps, TextProps
 from ..enums import Direction, Anchor
-from ..properties import AngleSpec, Bool, DistanceSpec, Enum, Include, Instance, NumberSpec, StringSpec
+from ..properties import AngleSpec, Bool, DistanceSpec, Enum, Float, Include, Instance, NumberSpec, StringSpec
 
 from .mappers import LinearColorMapper
 
@@ -464,6 +464,10 @@ class ImageURL(Glyph):
     horizontal.
     """)
 
+    global_alpha = Float(1.0, help="""
+    The opacity that each image is rendered with.
+    """)
+
     dilate = Bool(False, help="""
     Whether to always round fractional pixel locations in such a way
     as to make the images bigger.
diff --git a/examples/glyphs/image_url.py b/examples/glyphs/image_url.py
--- a/examples/glyphs/image_url.py
+++ b/examples/glyphs/image_url.py
@@ -26,7 +26,7 @@
 
 plot = Plot(title="ImageURL", x_range=xdr, y_range=ydr)
 
-image1 = ImageURL(url="url", x="x1", y="y1", w="w1", h="h1", anchor="center")
+image1 = ImageURL(url="url", x="x1", y="y1", w="w1", h="h1", anchor="center", global_alpha=0.2)
 plot.add_glyph(source, image1)
 
 image2 = ImageURL(url="url", x="x2", y="y2", w=20, h=20, anchor="top_left")
@@ -53,4 +53,3 @@
         f.write(file_html(doc, INLINE, "Image URL Example"))
     print("Wrote %s" % filename)
     view(filename)
-
diff --git a/examples/plotting/file/image_url.py b/examples/plotting/file/image_url.py
--- a/examples/plotting/file/image_url.py
+++ b/examples/plotting/file/image_url.py
@@ -7,6 +7,6 @@
 url = ["http://bokeh.pydata.org/en/latest/_static/bokeh-transparent.png"]*10
 x = list(range(0, 100, 10))
 y = list(range(0, 100, 10))
-p.image_url(x=x, y=y, url=url)
+p.image_url(x=x, y=y, url=url, global_alpha=0.2)
 
 show(p)


Test patch:
diff --git a/bokeh/models/tests/test_glyphs.py b/bokeh/models/tests/test_glyphs.py
--- a/bokeh/models/tests/test_glyphs.py
+++ b/bokeh/models/tests/test_glyphs.py
@@ -254,6 +254,7 @@ def test_ImageURL():
     assert glyph.angle == 0
     assert glyph.dilate == False
     assert glyph.anchor == Anchor.top_left
+    assert glyph.global_alpha == 1.0
     yield (check_props, glyph, [
         "url",
         "x",
@@ -266,6 +267,7 @@ def test_ImageURL():
         "angle_units",
         "dilate",
         "anchor",
+        "global_alpha",
     ])
 
 def test_Line():