Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(6)  |  Call(4)  |  Derive(0)  |  Import(2)
This function convert a web exadecimal color in a kml color
color = rrggbb or rrggbbaa

        def web2kmlcolor(color, opacity='3c'):
    """This function convert a web exadecimal color in a kml color
    color = rrggbb or rrggbbaa
    """
    if not color:
        return ''

    if color.startswith('#'):
        color = color[1:]

    r = color[0:2]
    g = color[2:4]
    b = color[4:6]
    a = opacity
    if len(color) == 8:
        # alpha layer could be bassed by color varible
        a = color[6:8]

    return a + b + g + r
        


src/c/o/collective.geo.kml-3.2/src/collective/geo/kml/browser/kmldocument.py   collective.geo.kml(Download)
 
from collective.geo.kml.interfaces import IFeature, IContainer, IPlacemark
from collective.geo.kml.utils import web2kmlcolor
 
# support to collective.contentleadimage
    def linecolor(self):
        if self.styles:
            return web2kmlcolor(self.styles['linecolor'])
        return u''
 
    def polygoncolor(self):
        if self.styles:
            return web2kmlcolor(self.styles['polygoncolor'])
        return u''
 
    def linecolor(self):
        return web2kmlcolor(self.styles.linecolor)
 
    @property
    def linewidth(self):
        return self.styles.linewidth
 
    @property
    def polygoncolor(self):
        return web2kmlcolor(self.styles.polygoncolor)

src/c/o/collective.geo.kml-3.2/src/collective/geo/kml/tests/test_colorconversion.py   collective.geo.kml(Download)
    def test_colorconvert(self):
        from collective.geo.kml.utils import web2kmlcolor
        # convert standard web color
        self.assertEquals(web2kmlcolor('#ff00cc'), '3ccc00ff')
        # convert exadecimal color with alpha property