Dims Wemo bulb to specified percentage

@param $percent integer

@return mixed
342077
public function dim($percent)
    {
        if($percent < 0){
            $percent = 0;
        } else if($percent > 100){
            $percent = 100;
        }

        $level = round((255*$percent)/100);

        return $this->bridge->setDeviceStatus($this->deviceId, null, $level);
    }
216958
public function shade($percent = 50)
    {
        $clone = clone $this;
        $black = $clone->toRgb()->red(0)->green(0)->blue(0);
        return $this->mix($black, $percent);
    }
1020215
public function getFillingPercentage()
    {
        $mems = $this->_memcache->getStats();
        if ($mems === false) {
            return 0;
        }

        $memSize = null;
        $memUsed = null;
        foreach ($mems as $key => $mem) {
            if ($mem === false) {
                $this->_log('can\'t get stat from ' . $key);
                continue;
            }

            $eachSize = $mem['limit_maxbytes'];
            $eachUsed = $mem['bytes'];
            if ($eachUsed > $eachSize) {
                $eachUsed = $eachSize;
            }

            $memSize += $eachSize;
            $memUsed += $eachUsed;
        }

        if ($memSize === null || $memUsed === null) {
            Zend_Cache::throwException('Can\'t get filling percentage');
        }

        return ((int) (100. * ($memUsed / $memSize)));
    }
1318619
public static function percentage($number1 = false, $number2 = false, $decimals = 2) {

        if($number1 && $number2) {

            return self::round(($number1 / $number2) * 100, $decimals);
        }

        return false;
    }
207970
public function lighten($percent)
    {
        $color = $this->toHsl();
        $lightness = $this->clamp(($color->lightness() + $percent) / 100);
        return $color->lightness($lightness * 100)->back($this);
    }
223430
protected function getClassFromPercent($percent)
    {
        $mapping = array(95, 70, 50, 30, 15, 5, 0);
        foreach ($mapping as $key => $value) {
            if ($percent >= $value) {
                return $key;
            }
        }
        return 0;
    }
295829
function quality($percent)
    {
        $this->info();
        $this->_info['quality'] = intval($percent);
        if ($percent!=100){
            $this->_transforms_str.='quality('.$this->_info['quality'].')';
        }
        return $this;
    }
669797
public function resizePercent($percent = 0)
    {
        if (!is_numeric($percent)) {
            throw new \InvalidArgumentException('$percent must be numeric');
        }

        $this->percent = intval($percent);

        $this->calcImageSizePercent($this->currentDimensions['width'], $this->currentDimensions['height']);

        if (function_exists('imagecreatetruecolor')) {
            $this->workingImage = imagecreatetruecolor($this->newDimensions['newWidth'], $this->newDimensions['newHeight']);
        } else {
            $this->workingImage = imagecreate($this->newDimensions['newWidth'], $this->newDimensions['newHeight']);
        }

        $this->preserveAlpha();

        imagecopyresampled($this->workingImage, $this->oldImage, 0, 0, 0, 0, $this->newDimensions['newWidth'], $this->newDimensions['newHeight'], $this->currentDimensions['width'], $this->currentDimensions['height']);

        $this->oldImage = $this->workingImage;
        $this->currentDimensions['width'] = $this->newDimensions['newWidth'];
        $this->currentDimensions['height'] = $this->newDimensions['newHeight'];

        return $this;
    }
744668
public function format($value)
    {
        if ($value instanceOf Percentage) {
            $value = $value->toPercent();
        }

        return $value->int().'%';
    }
1315028
public function desaturate($percent)
    {
        $color = $this->toHsl();
        $saturation = $this->clamp(($color->saturation() - $percent) / 100);
        return $color->saturation($saturation * 100)->back($this);
    }
1213306
public function tint($percent = 50)
    {
        $clone = clone $this;
        $white = $clone->toRgb()->red(255)->green(255)->blue(255);
        return $this->mix($white, $percent);
    }
1055238
public static function getPercentage($base, $divider, $scale = 2, $string = false)
    {
        if (0 === $divider) {
            return '-';
        }

        $value = round(($base / $divider) * 100, $scale);
        if (false === $string) {
            return $value;
        }

        return sprintf('%s%%', number_format($value, $scale));
    }
405515
private function getTotalFromPercent(\SimpleXMLElement $percent)
    {
        $percent = (string)$percent;
        $percent = substr($percent, 0, -1);
        return round($percent);
    }
764553
private function _percentageAdjustValues($dataValues,$sumValues) {
		foreach($dataValues as $k => $dataValue) {
			$dataValues[$k] = $dataValue / $sumValues[$k] * 100;
		}

		return $dataValues;
	}
318850
function (percent) {
            var min = this.options.min,
                max = this.options.max,
                min_decimals = min.toString().split(".")[1],
                max_decimals = max.toString().split(".")[1],
                min_length, max_length,
                avg_decimals = 0,
                abs = 0;

            if (percent === 0) {
                return this.options.min;
            }
            if (percent === 100) {
                return this.options.max;
            }


            if (min_decimals) {
                min_length = min_decimals.length;
                avg_decimals = min_length;
            }
            if (max_decimals) {
                max_length = max_decimals.length;
                avg_decimals = max_length;
            }
            if (min_length && max_length) {
                avg_decimals = (min_length >= max_length) ? min_length : max_length;
            }

            if (min < 0) {
                abs = Math.abs(min);
                min = +(min + abs).toFixed(avg_decimals);
                max = +(max + abs).toFixed(avg_decimals);
            }

            var number = ((max - min) / 100 * percent) + min,
                string = this.options.step.toString().split(".")[1],
                result;

            if (string) {
                number = +number.toFixed(string.length);
            } else {
                number = number / this.options.step;
                number = number * this.options.step;

                number = +number.toFixed(0);
            }

            if (abs) {
                number -= abs;
            }

            if (string) {
                result = +number.toFixed(string.length);
            } else {
                result = this.toFixed(number);
            }

            if (result < this.options.min) {
                result = this.options.min;
            } else if (result > this.options.max) {
                result = this.options.max;
            }

            return result;
        }
444524
def pos_by_percent(self, x_percent, y_percent):
        
        x = round(x_percent * self.width)
        y = round(y_percent * self.height)
        return int(x), int(y)
1079958
public function drawProgress($X, $Y, $Percent, array $Format = [])
    {
        if ($Percent > 100) {
            $Percent = 100;
        }
        if ($Percent < 0) {
            $Percent = 0;
        }

        $Width = isset($Format["Width"]) ? $Format["Width"] : 200;
        $Height = isset($Format["Height"]) ? $Format["Height"] : 20;
        $Orientation = isset($Format["Orientation"]) ? $Format["Orientation"] : ORIENTATION_HORIZONTAL;
        $ShowLabel = isset($Format["ShowLabel"]) ? $Format["ShowLabel"] : false;
        $LabelPos = isset($Format["LabelPos"]) ? $Format["LabelPos"] : LABEL_POS_INSIDE;
        $Margin = isset($Format["Margin"]) ? $Format["Margin"] : 10;
        $R = isset($Format["R"]) ? $Format["R"] : 130;
        $G = isset($Format["G"]) ? $Format["G"] : 130;
        $B = isset($Format["B"]) ? $Format["B"] : 130;
        $RFade = isset($Format["RFade"]) ? $Format["RFade"] : -1;
        $GFade = isset($Format["GFade"]) ? $Format["GFade"] : -1;
        $BFade = isset($Format["BFade"]) ? $Format["BFade"] : -1;
        $BorderR = isset($Format["BorderR"]) ? $Format["BorderR"] : $R;
        $BorderG = isset($Format["BorderG"]) ? $Format["BorderG"] : $G;
        $BorderB = isset($Format["BorderB"]) ? $Format["BorderB"] : $B;
        $BoxBorderR = isset($Format["BoxBorderR"]) ? $Format["BoxBorderR"] : 0;
        $BoxBorderG = isset($Format["BoxBorderG"]) ? $Format["BoxBorderG"] : 0;
        $BoxBorderB = isset($Format["BoxBorderB"]) ? $Format["BoxBorderB"] : 0;
        $BoxBackR = isset($Format["BoxBackR"]) ? $Format["BoxBackR"] : 255;
        $BoxBackG = isset($Format["BoxBackG"]) ? $Format["BoxBackG"] : 255;
        $BoxBackB = isset($Format["BoxBackB"]) ? $Format["BoxBackB"] : 255;
        $Surrounding = isset($Format["Surrounding"]) ? $Format["Surrounding"] : null;
        $BoxSurrounding = isset($Format["BoxSurrounding"]) ? $Format["BoxSurrounding"] : null;
        $NoAngle = isset($Format["NoAngle"]) ? $Format["NoAngle"] : false;

        if ($RFade != -1 && $GFade != -1 && $BFade != -1) {
            $RFade = (($RFade - $R) / 100) * $Percent + $R;
            $GFade = (($GFade - $G) / 100) * $Percent + $G;
            $BFade = (($BFade - $B) / 100) * $Percent + $B;
        }

        if ($Surrounding != null) {
            $BorderR = $R + $Surrounding;
            $BorderG = $G + $Surrounding;
            $BorderB = $B + $Surrounding;
        }
        if ($BoxSurrounding != null) {
            $BoxBorderR = $BoxBackR + $Surrounding;
            $BoxBorderG = $BoxBackG + $Surrounding;
            $BoxBorderB = $BoxBackB + $Surrounding;
        }

        if ($Orientation == ORIENTATION_VERTICAL) {
            $InnerHeight = (($Height - 2) / 100) * $Percent;
            $this->drawFilledRectangle(
                $X,
                $Y,
                $X + $Width,
                $Y - $Height,
                [
                    "R" => $BoxBackR,
                    "G" => $BoxBackG,
                    "B" => $BoxBackB,
                    "BorderR" => $BoxBorderR,
                    "BorderG" => $BoxBorderG,
                    "BorderB" => $BoxBorderB,
                    "NoAngle" => $NoAngle
                ]
            );

            $RestoreShadow = $this->Shadow;
            $this->Shadow = false;
            if ($RFade != -1 && $GFade != -1 && $BFade != -1) {
                $GradientOptions = [
                    "StartR" => $RFade,
                    "StartG" => $GFade,
                    "StartB" => $BFade,
                    "EndR" => $R,
                    "EndG" => $G,
                    "EndB" => $B
                ];
                $this->drawGradientArea(
                    $X + 1,
                    $Y - 1,
                    $X + $Width - 1,
                    $Y - $InnerHeight,
                    DIRECTION_VERTICAL,
                    $GradientOptions
                );

                if ($Surrounding) {
                    $this->drawRectangle(
                        $X + 1,
                        $Y - 1,
                        $X + $Width - 1,
                        $Y - $InnerHeight,
                        ["R" => 255, "G" => 255, "B" => 255, "Alpha" => $Surrounding]
                    );
                }
            } else {
                $this->drawFilledRectangle(
                    $X + 1,
                    $Y - 1,
                    $X + $Width - 1,
                    $Y - $InnerHeight,
                    [
                        "R" => $R,
                        "G" => $G,
                        "B" => $B,
                        "BorderR" => $BorderR,
                        "BorderG" => $BorderG,
                        "BorderB" => $BorderB
                    ]
                );
            }
            $this->Shadow = $RestoreShadow;

            if ($ShowLabel && $LabelPos == LABEL_POS_BOTTOM) {
                $this->drawText(
                    $X + ($Width / 2),
                    $Y + $Margin,
                    $Percent . "%",
                    ["Align" => TEXT_ALIGN_TOPMIDDLE]
                );
            }
            if ($ShowLabel && $LabelPos == LABEL_POS_TOP) {
                $this->drawText(
                    $X + ($Width / 2),
                    $Y - $Height - $Margin,
                    $Percent . "%",
                    ["Align" => TEXT_ALIGN_BOTTOMMIDDLE]
                );
            }
            if ($ShowLabel && $LabelPos == LABEL_POS_INSIDE) {
                $this->drawText(
                    $X + ($Width / 2),
                    $Y - $InnerHeight - $Margin,
                    $Percent . "%",
                    ["Align" => TEXT_ALIGN_MIDDLELEFT, "Angle" => 90]
                );
            }
            if ($ShowLabel && $LabelPos == LABEL_POS_CENTER) {
                $this->drawText(
                    $X + ($Width / 2),
                    $Y - ($Height / 2),
                    $Percent . "%",
                    ["Align" => TEXT_ALIGN_MIDDLEMIDDLE, "Angle" => 90]
                );
            }
        } else {
            if ($Percent == 100) {
                $InnerWidth = $Width - 1;
            } else {
                $InnerWidth = (($Width - 2) / 100) * $Percent;
            }
            $this->drawFilledRectangle(
                $X,
                $Y,
                $X + $Width,
                $Y + $Height,
                [
                    "R" => $BoxBackR,
                    "G" => $BoxBackG,
                    "B" => $BoxBackB,
                    "BorderR" => $BoxBorderR,
                    "BorderG" => $BoxBorderG,
                    "BorderB" => $BoxBorderB,
                    "NoAngle" => $NoAngle
                ]
            );

            $RestoreShadow = $this->Shadow;
            $this->Shadow = false;
            if ($RFade != -1 && $GFade != -1 && $BFade != -1) {
                $GradientOptions = [
                    "StartR" => $R,
                    "StartG" => $G,
                    "StartB" => $B,
                    "EndR" => $RFade,
                    "EndG" => $GFade,
                    "EndB" => $BFade
                ];
                $this->drawGradientArea(
                    $X + 1,
                    $Y + 1,
                    $X + $InnerWidth,
                    $Y + $Height - 1,
                    DIRECTION_HORIZONTAL,
                    $GradientOptions
                );

                if ($Surrounding) {
                    $this->drawRectangle(
                        $X + 1,
                        $Y + 1,
                        $X + $InnerWidth,
                        $Y + $Height - 1,
                        ["R" => 255, "G" => 255, "B" => 255, "Alpha" => $Surrounding]
                    );
                }
            } else {
                $this->drawFilledRectangle(
                    $X + 1,
                    $Y + 1,
                    $X + $InnerWidth,
                    $Y + $Height - 1,
                    [
                        "R" => $R,
                        "G" => $G,
                        "B" => $B,
                        "BorderR" => $BorderR, "BorderG" => $BorderG, "BorderB" => $BorderB
                    ]
                );
            }
            $this->Shadow = $RestoreShadow;

            if ($ShowLabel && $LabelPos == LABEL_POS_LEFT) {
                $this->drawText(
                    $X - $Margin,
                    $Y + ($Height / 2),
                    $Percent . "%",
                    ["Align" => TEXT_ALIGN_MIDDLERIGHT]
                );
            }
            if ($ShowLabel && $LabelPos == LABEL_POS_RIGHT) {
                $this->drawText(
                    $X + $Width + $Margin,
                    $Y + ($Height / 2),
                    $Percent . "%",
                    ["Align" => TEXT_ALIGN_MIDDLELEFT]
                );
            }
            if ($ShowLabel && $LabelPos == LABEL_POS_CENTER) {
                $this->drawText(
                    $X + ($Width / 2),
                    $Y + ($Height / 2),
                    $Percent . "%",
                    ["Align" => TEXT_ALIGN_MIDDLEMIDDLE]
                );
            }
            if ($ShowLabel && $LabelPos == LABEL_POS_INSIDE) {
                $this->drawText(
                    $X + $InnerWidth + $Margin,
                    $Y + ($Height / 2),
                    $Percent . "%",
                    ["Align" => TEXT_ALIGN_MIDDLELEFT]
                );
            }
        }
    }