コード例 #1
0
def blue(values, feature, parent):
    """
        Returns the blue component of a color
        
        <p><h4>Syntax</h4>
        blue(<i>color</i>)</p>

        <p><h4>Arguments</h4>
        <i>  color</i> &rarr; a color<br></p>
        
        <p><h4>Example</h4>
        <!-- Show example of function.-->
             blue('0,0,255') &rarr; 255</p>
    """
    try:
        return QgsSymbolLayerV2Utils.decodeColor(values[0]).blue()
    except:
        return None
コード例 #2
0
def blue(values, feature, parent):
    """
        Returns the blue component of a color
        
        <p><h4>Syntax</h4>
        blue(<i>color</i>)</p>

        <p><h4>Arguments</h4>
        <i>  color</i> &rarr; a color<br></p>
        
        <p><h4>Example</h4>
        <!-- Show example of function.-->
             blue('0,0,255') &rarr; 255</p>
    """
    try:
        return QgsSymbolLayerV2Utils.decodeColor(values[0]).blue()
    except:
        return None
コード例 #3
0
def alpha(values, feature, parent):
    """
        Returns the alpha component of a color
        
        <p><h4>Syntax</h4>
        alpha(<i>color</i>)</p>

        <p><h4>Arguments</h4>
        <i>  color</i> &rarr; a color<br></p>
        
        <p><h4>Example</h4>
        <!-- Show example of function.-->
             alpha('255,255,255,125') &rarr; 125</p>
    """
    try:
        return QgsSymbolLayerV2Utils.decodeColor(values[0]).alpha()
    except:
        return None
コード例 #4
0
def alpha(values, feature, parent):
    """
        Returns the alpha component of a color
        
        <p><h4>Syntax</h4>
        alpha(<i>color</i>)</p>

        <p><h4>Arguments</h4>
        <i>  color</i> &rarr; a color<br></p>
        
        <p><h4>Example</h4>
        <!-- Show example of function.-->
             alpha('255,255,255,125') &rarr; 125</p>
    """
    try:
        return QgsSymbolLayerV2Utils.decodeColor(values[0]).alpha()
    except:
        return None
コード例 #5
0
def hsv_value(values, feature, parent):
    """
        Returns the hsv value component of a color, an integer between 0-100
        
        <p><h4>Syntax</h4>
        hsv_value(<i>color</i>)</p>

        <p><h4>Arguments</h4>
        <i>  color</i> &rarr; a color<br></p>
        
        <p><h4>Example</h4>
        <!-- Show example of function.-->
             hsv_value('125,255,125') &rarr; 100</p>
    """
    try:
        # Value ranges from 0 - 100
        return int(QgsSymbolLayerV2Utils.decodeColor(values[0]).valueF() * 100)
    except:
        return None
コード例 #6
0
def lightness(values, feature, parent):
    """
        Returns the lightness of a color, an integer between 0-100
        
        <p><h4>Syntax</h4>
        lightness(<i>color</i>)</p>

        <p><h4>Arguments</h4>
        <i>  color</i> &rarr; a color<br></p>
        
        <p><h4>Example</h4>
        <!-- Show example of function.-->
             lightness('125,255,125') &rarr; 74</p>
    """
    try:
        # Lightness ranges from 0 - 100
        return int(QgsSymbolLayerV2Utils.decodeColor(values[0]).lightnessF() * 100)
    except:
        return None
コード例 #7
0
def saturation(values, feature, parent):
    """
        Returns the saturation of a color, an integer between 0-100
        
        <p><h4>Syntax</h4>
        saturation(<i>color</i>)</p>

        <p><h4>Arguments</h4>
        <i>  color</i> &rarr; a color<br></p>
        
        <p><h4>Example</h4>
        <!-- Show example of function.-->
             saturation('125,255,125') &rarr; 50</p>
    """
    try:
        # Saturation ranges from 0 - 100
        return int(QgsSymbolLayerV2Utils.decodeColor(values[0]).saturationF() * 100)
    except:
        return None
コード例 #8
0
def hue(values, feature, parent):
    """
        Returns the hue component of a color, an integer between 0-360
        
        <p><h4>Syntax</h4>
        hue(<i>color</i>)</p>

        <p><h4>Arguments</h4>
        <i>  color</i> &rarr; a color<br></p>
        
        <p><h4>Example</h4>
        <!-- Show example of function.-->
             hue('255,0,0') &rarr; 0</p>
    """
    try:
        # Hue ranges from 0 - 360
        return int(QgsSymbolLayerV2Utils.decodeColor(values[0]).hueF() * 360)
    except:
        return None
コード例 #9
0
def lightness(values, feature, parent):
    """
        Returns the lightness of a color, an integer between 0-100
        
        <p><h4>Syntax</h4>
        lightness(<i>color</i>)</p>

        <p><h4>Arguments</h4>
        <i>  color</i> &rarr; a color<br></p>
        
        <p><h4>Example</h4>
        <!-- Show example of function.-->
             lightness('125,255,125') &rarr; 74</p>
    """
    try:
        # Lightness ranges from 0 - 100
        return int(
            QgsSymbolLayerV2Utils.decodeColor(values[0]).lightnessF() * 100)
    except:
        return None
コード例 #10
0
def saturation(values, feature, parent):
    """
        Returns the saturation of a color, an integer between 0-100
        
        <p><h4>Syntax</h4>
        saturation(<i>color</i>)</p>

        <p><h4>Arguments</h4>
        <i>  color</i> &rarr; a color<br></p>
        
        <p><h4>Example</h4>
        <!-- Show example of function.-->
             saturation('125,255,125') &rarr; 50</p>
    """
    try:
        # Saturation ranges from 0 - 100
        return int(
            QgsSymbolLayerV2Utils.decodeColor(values[0]).saturationF() * 100)
    except:
        return None
コード例 #11
0
def set_alpha(values, feature, parent):
    """
        Sets the alpha component of a color
        
        <p><h4>Syntax</h4>
        set_alpha(<i>color</i>, <i>alpha</i>)</p>

        <p><h4>Arguments</h4>
        <i>  color</i> &rarr; a color<br>
        <i>  alpha</i> &rarr; an alpha value between 0 and 255<br></p>
        
        <p><h4>Example</h4>
        <!-- Show example of function.-->
             set_alpha('255,255,255,255', 125) &rarr; '255,255,255,125'</p>
    """
    try:
        color = QgsSymbolLayerV2Utils.decodeColor(values[0])
        color.setAlpha(values[1])
        return QgsSymbolLayerV2Utils.encodeColor(color)
    except:
        return None
コード例 #12
0
def set_hsv_value(values, feature, parent):
    """
        Sets the value of a color
        
        <p><h4>Syntax</h4>
        set_hsv_value(<i>color</i>, <i>value</i>)</p>

        <p><h4>Arguments</h4>
        <i>  color</i> &rarr; a color<br>
        <i>  value</i> &rarr; a integer between 0 and 100<br></p>
        
        <p><h4>Example</h4>
        <!-- Show example of function.-->
             set_hsv_value('0,255,0,255', 50) &rarr; '0,128,0,255'</p>
    """
    try:
        color = QgsSymbolLayerV2Utils.decodeColor(values[0])
        color.setHsvF(color.hueF(), color.saturationF(), values[1] / 100.0, color.alphaF())
        return QgsSymbolLayerV2Utils.encodeColor(color)
    except:
        return None
コード例 #13
0
def set_hue(values, feature, parent):
    """
        Sets the hue component of a color
        
        <p><h4>Syntax</h4>
        set_hue(<i>color</i>, <i>hue</i>)</p>

        <p><h4>Arguments</h4>
        <i>  color</i> &rarr; a color<br>
        <i>  hue</i> &rarr; a integer between 0 and 360<br></p>
        
        <p><h4>Example</h4>
        <!-- Show example of function.-->
             set_hue('0,255,0,255', 0) &rarr; '255,0,0,255'</p>
    """
    try:
        color = QgsSymbolLayerV2Utils.decodeColor(values[0])
        color.setHslF(values[1] / 360.0, color.saturationF(), color.lightnessF(), color.alphaF())
        return QgsSymbolLayerV2Utils.encodeColor(color)
    except:
        return None
コード例 #14
0
def set_alpha(values, feature, parent):
    """
        Sets the alpha component of a color
        
        <p><h4>Syntax</h4>
        set_alpha(<i>color</i>, <i>alpha</i>)</p>

        <p><h4>Arguments</h4>
        <i>  color</i> &rarr; a color<br>
        <i>  alpha</i> &rarr; an alpha value between 0 and 255<br></p>
        
        <p><h4>Example</h4>
        <!-- Show example of function.-->
             set_alpha('255,255,255,255', 125) &rarr; '255,255,255,125'</p>
    """
    try:
        color = QgsSymbolLayerV2Utils.decodeColor(values[0])
        color.setAlpha(values[1])
        return QgsSymbolLayerV2Utils.encodeColor(color)
    except:
        return None
コード例 #15
0
def set_hsv_value(values, feature, parent):
    """
        Sets the value of a color
        
        <p><h4>Syntax</h4>
        set_hsv_value(<i>color</i>, <i>value</i>)</p>

        <p><h4>Arguments</h4>
        <i>  color</i> &rarr; a color<br>
        <i>  value</i> &rarr; a integer between 0 and 100<br></p>
        
        <p><h4>Example</h4>
        <!-- Show example of function.-->
             set_hsv_value('0,255,0,255', 50) &rarr; '0,128,0,255'</p>
    """
    try:
        color = QgsSymbolLayerV2Utils.decodeColor(values[0])
        color.setHsvF(color.hueF(), color.saturationF(), values[1] / 100.0,
                      color.alphaF())
        return QgsSymbolLayerV2Utils.encodeColor(color)
    except:
        return None
コード例 #16
0
def set_hue(values, feature, parent):
    """
        Sets the hue component of a color
        
        <p><h4>Syntax</h4>
        set_hue(<i>color</i>, <i>hue</i>)</p>

        <p><h4>Arguments</h4>
        <i>  color</i> &rarr; a color<br>
        <i>  hue</i> &rarr; a integer between 0 and 360<br></p>
        
        <p><h4>Example</h4>
        <!-- Show example of function.-->
             set_hue('0,255,0,255', 0) &rarr; '255,0,0,255'</p>
    """
    try:
        color = QgsSymbolLayerV2Utils.decodeColor(values[0])
        color.setHslF(values[1] / 360.0, color.saturationF(),
                      color.lightnessF(), color.alphaF())
        return QgsSymbolLayerV2Utils.encodeColor(color)
    except:
        return None