getBackgroundCoordinates

@param mixed $gravity
@access private
@return array
321545
private function getBackgroundCoordinates($gravity)
    {
        $w = imagesx($this->resource);
        $h = imagesy($this->resource);


        $x1 = $y1 = 0;
        $x2 = $w - 1;
        $y2 = $h - 1;

        switch ($gravity) {
            case 1:
                $x1 = $w - 1;
                $y1 = $h - 1;
                $y2 = 0;
                break;
            case 5:
                $x1 = $w - 1;
                $y2 = $w - 1;
                $x2 = 0;
                $y2 = 0;
                break;
            case 9:
                break;
            default:
                $x2 = 0;
                $y2 = 0;
                break;
        }
        return compact('x1', 'y1', 'x2', 'y2');
    }
1174556
protected function gdImageBackground($image, $bgcolor){

		if( $bgcolor == 'transparent' ){
			imagesavealpha($image,true);
			$bgcolor1 = imagecolorallocatealpha($image, 255, 255, 255, 127);

		}else{
			list($r, $g, $b) = sscanf($bgcolor, "#%02x%02x%02x");
			$bgcolor1 = imagecolorallocate($image, $r, $g, $b);
		}

		imagefill($image, 0, 0, $bgcolor1);
	}
1357103
private function getBackgroundShortDescription(BackgroundNode $background)
    {
        return trim(sprintf('%s: %s', trim($background->getKeyword()), trim($background->getTitle())));
    }
1031639
public function getRevEventGeo()
    {
        if (isset($this->_receive['Latitude'])) {
            return array(
                'x'         => $this->_receive['Latitude'],
                'y'         => $this->_receive['Longitude'],
                'precision' => $this->_receive['Precision'],
            );
        }
        return false;
    }
222484
public static function getBackgroundUrl( $style )
    {
        $patten = '/background(-image)?\s*:\s*url\s*\((?<source>[^\)]*)/';
        preg_match( $patten, $style, $backgroundImage );

        return trim( ArrayHelper::getValue( $backgroundImage, 'source', null ) );
    }
301345
protected static function rgbToSrgb($rgb)
    {
        return [
            'R' => self::rgbToSrgbStep($rgb['R']),
            'G' => self::rgbToSrgbStep($rgb['G']),
            'B' => self::rgbToSrgbStep($rgb['B']),
        ];
    }
830947
public function backColor($r, $g, $b) {
        $this->renderer->setBackgroundColor(new Rgb($r, $g, $b));

        return $this;
    }
1076200
function getBackgroundPoint(vm, size, alignment, chart) {
	// Background Position
	var x = vm.x;
	var y = vm.y;

	var caretSize = vm.caretSize;
	var caretPadding = vm.caretPadding;
	var cornerRadius = vm.cornerRadius;
	var xAlign = alignment.xAlign;
	var yAlign = alignment.yAlign;
	var paddingAndSize = caretSize + caretPadding;
	var radiusAndPadding = cornerRadius + caretPadding;

	if (xAlign === 'right') {
		x -= size.width;
	} else if (xAlign === 'center') {
		x -= (size.width / 2);
		if (x + size.width > chart.width) {
			x = chart.width - size.width;
		}
		if (x < 0) {
			x = 0;
		}
	}

	if (yAlign === 'top') {
		y += paddingAndSize;
	} else if (yAlign === 'bottom') {
		y -= size.height + paddingAndSize;
	} else {
		y -= (size.height / 2);
	}

	if (yAlign === 'center') {
		if (xAlign === 'left') {
			x += paddingAndSize;
		} else if (xAlign === 'right') {
			x -= paddingAndSize;
		}
	} else if (xAlign === 'left') {
		x -= radiusAndPadding;
	} else if (xAlign === 'right') {
		x += radiusAndPadding;
	}

	return {
		x: x,
		y: y
	};
}
649563
public function getForeignColumnObjects()
    {
        $columns = [];
        $foreignTable = $this->getForeignTable();
        foreach ($this->foreignColumns as $columnName) {
            $column = $foreignTable->getColumn($columnName);
            if (null !== $column) {
                $columns[] = $column;
            }
        }

        return $columns;
    }
934536
public function getContextualChildren($position)
    {
        $widgetMapChildren = [];
        $viewWidgetMaps = $this->getContextualView()->getWidgetMapsForViewAndTemplates();

        foreach ($viewWidgetMaps as $viewWidgetMap) {
            if ($viewWidgetMap->getParent() == $this && $viewWidgetMap->getPosition() == $position) {
                $widgetMapChildren[] = $viewWidgetMap;
            }
        }

        return $widgetMapChildren;
    }
870844
public function themePaths(string $resource): array
    {
        $paths = [];

        if (file_exists($this->sourceDirectory.'/'.$resource)) {
            $paths[] = $resource;
        }

        if (null === $this->theme) {
            return $paths;
        }

        $themeResource = $this->findThemeResource($this->theme, $resource);
        if (null !== $themeResource) {
            $paths[] = $themeResource;
        }

        if (isset($this->theme['parent'])) {
            $themeResource = $this->findThemeResource($this->theme['parent'], $resource);
            if (null !== $themeResource) {
                $paths[] = $themeResource;
            }
        }

        return array_reverse($paths);
    }
1101349
def foreground(background, *options):
    
    def absdiff(a, b):
        return brightnessdiff(a, b)
        # return 3 * brightnessdiff(a, b) + colordiff(a, b)
    diffs = [(absdiff(background, color), color) for color in options]
    diffs.sort(reverse=True)
    return diffs[0][1]
558983
protected final function getWhere($data) {
        $con = [];
        foreach ($this->primaryKeys as $f) {
            if (array_key_exists($f, $data)) {
                if (isset($data[ $f ])) {
                    $con [ $f ] = $data [ $f ];
                } else {
                    $con [ $f . ' $' ] = null;
                }
            }
        }

        return $con;
    }
104797
function _getGPOStables()
	{
		///////////////////////////////////
		// GPOS - Glyph Positioning
		///////////////////////////////////
		if (isset($this->tables["GPOS"])) {
			$this->mpdf->WriteHTML('<h1>GPOS Tables</h1>');
			$ffeats = [];
			$gpos_offset = $this->seek_table("GPOS");
			$this->skip(4);
			$ScriptList_offset = $gpos_offset + $this->read_ushort();
			$FeatureList_offset = $gpos_offset + $this->read_ushort();
			$LookupList_offset = $gpos_offset + $this->read_ushort();

			// ScriptList
			$this->seek($ScriptList_offset);
			$ScriptCount = $this->read_ushort();
			for ($i = 0; $i < $ScriptCount; $i++) {
				$ScriptTag = $this->read_tag(); // = "beng", "deva" etc.
				$ScriptTableOffset = $this->read_ushort();
				$ffeats[$ScriptTag] = $ScriptList_offset + $ScriptTableOffset;
			}

			// Script Table
			foreach ($ffeats as $t => $o) {
				$ls = [];
				$this->seek($o);
				$DefLangSys_offset = $this->read_ushort();
				if ($DefLangSys_offset > 0) {
					$ls['DFLT'] = $DefLangSys_offset + $o;
				}
				$LangSysCount = $this->read_ushort();
				for ($i = 0; $i < $LangSysCount; $i++) {
					$LangTag = $this->read_tag(); // =
					$LangTableOffset = $this->read_ushort();
					$ls[$LangTag] = $o + $LangTableOffset;
				}
				$ffeats[$t] = $ls;
			}

			// Get FeatureIndexList
			// LangSys Table - from first listed langsys
			foreach ($ffeats as $st => $scripts) {
				foreach ($scripts as $t => $o) {
					$FeatureIndex = [];
					$langsystable_offset = $o;
					$this->seek($langsystable_offset);
					$LookUpOrder = $this->read_ushort(); //==NULL
					$ReqFeatureIndex = $this->read_ushort();
					if ($ReqFeatureIndex != 0xFFFF) {
						$FeatureIndex[] = $ReqFeatureIndex;
					}
					$FeatureCount = $this->read_ushort();
					for ($i = 0; $i < $FeatureCount; $i++) {
						$FeatureIndex[] = $this->read_ushort(); // = index of feature
					}
					$ffeats[$st][$t] = $FeatureIndex;
				}
			}
//print_r($ffeats); exit;
			// Feauture List => LookupListIndex es
			$this->seek($FeatureList_offset);
			$FeatureCount = $this->read_ushort();
			$Feature = [];
			for ($i = 0; $i < $FeatureCount; $i++) {
				$Feature[$i] = ['tag' => $this->read_tag()];
				$Feature[$i]['offset'] = $FeatureList_offset + $this->read_ushort();
			}
			for ($i = 0; $i < $FeatureCount; $i++) {
				$this->seek($Feature[$i]['offset']);
				$this->read_ushort(); // null
				$Feature[$i]['LookupCount'] = $Lookupcount = $this->read_ushort();
				$Feature[$i]['LookupListIndex'] = [];
				for ($c = 0; $c < $Lookupcount; $c++) {
					$Feature[$i]['LookupListIndex'][] = $this->read_ushort();
				}
			}

			foreach ($ffeats as $st => $scripts) {
				foreach ($scripts as $t => $o) {
					$FeatureIndex = $ffeats[$st][$t];
					foreach ($FeatureIndex as $k => $fi) {
						$ffeats[$st][$t][$k] = $Feature[$fi];
					}
				}
			}
//print_r($ffeats); exit;
			//=====================================================================================
			$gpos = [];
			$GPOSScriptLang = [];
			foreach ($ffeats as $st => $scripts) {
				foreach ($scripts as $t => $langsys) {
					$lg = [];
					foreach ($langsys as $ft) {
						$lg[$ft['LookupListIndex'][0]] = $ft;
					}
					// list of Lookups in order they need to be run i.e. order listed in Lookup table
					ksort($lg);
					foreach ($lg as $ft) {
						$gpos[$st][$t][$ft['tag']] = $ft['LookupListIndex'];
					}
					if (!isset($GPOSScriptLang[$st])) {
						$GPOSScriptLang[$st] = '';
					}
					$GPOSScriptLang[$st] .= $t . ' ';
				}
			}
			if ($this->mode == 'summary') {
				$this->mpdf->WriteHTML('<h3>GPOS Scripts &amp; Languages</h3>');
				$html = '';
				if (count($gpos)) {
					foreach ($gpos as $st => $g) {
						$html .= '<h5>' . $st . '</h5>';
						foreach ($g as $l => $t) {
							$html .= '<div><a href="font_dump_OTL.php?script=' . $st . '&lang=' . $l . '">' . $l . '</a></b>: ';
							foreach ($t as $tag => $o) {
								$html .= $tag . ' ';
							}
							$html .= '</div>';
						}
					}
				} else {
					$html .= '<div>No entries in GPOS table.</div>';
				}
				$this->mpdf->WriteHTML($html);
				$this->mpdf->WriteHTML('</div>');

				return 0;
			}

			//=====================================================================================
			// Get metadata and offsets for whole Lookup List table
			$this->seek($LookupList_offset);
			$LookupCount = $this->read_ushort();
			$Lookup = [];
			$Offsets = [];
			$SubtableCount = [];
			for ($i = 0; $i < $LookupCount; $i++) {
				$Offsets[$i] = $LookupList_offset + $this->read_ushort();
			}
			for ($i = 0; $i < $LookupCount; $i++) {
				$this->seek($Offsets[$i]);
				$Lookup[$i]['Type'] = $this->read_ushort();
				$Lookup[$i]['Flag'] = $flag = $this->read_ushort();
				$Lookup[$i]['SubtableCount'] = $SubtableCount[$i] = $this->read_ushort();
				for ($c = 0; $c < $SubtableCount[$i]; $c++) {
					$Lookup[$i]['Subtables'][$c] = $Offsets[$i] + $this->read_ushort();
				}
				// MarkFilteringSet = Index (base 0) into GDEF mark glyph sets structure
				if (($flag & 0x0010) == 0x0010) {
					$Lookup[$i]['MarkFilteringSet'] = $this->read_ushort();
				}
				// else { $Lookup[$i]['MarkFilteringSet'] = ''; }
				// Lookup Type 9: Extension
				if ($Lookup[$i]['Type'] == 9) {
					// Overwrites new offset (32-bit) for each subtable, and a new lookup Type
					for ($c = 0; $c < $SubtableCount[$i]; $c++) {
						$this->seek($Lookup[$i]['Subtables'][$c]);
						$ExtensionPosFormat = $this->read_ushort();
						$type = $this->read_ushort();
						$Lookup[$i]['Subtables'][$c] = $Lookup[$i]['Subtables'][$c] + $this->read_ulong();
					}
					$Lookup[$i]['Type'] = $type;
				}
			}

			//=====================================================================================

			$st = $this->mpdf->OTLscript;
			$t = $this->mpdf->OTLlang;
			$langsys = $gpos[$st][$t];

			$lul = []; // array of LookupListIndexes
			$tags = []; // corresponding array of feature tags e.g. 'ccmp'
			if (count($langsys)) {
				foreach ($langsys as $tag => $ft) {
					foreach ($ft as $ll) {
						$lul[$ll] = $tag;
					}
				}
			}
			ksort($lul); // Order the Lookups in the order they are in the GUSB table, regardless of Feature order
			$this->_getGPOSarray($Lookup, $lul, $st);

//print_r($lul); exit;

			return [$GPOSScriptLang, $gpos, $Lookup];
		} // end if GPOS
	}
663765
def getGroundCheckEnabled(self):
    """"""
    command = '$GE'
    settings = self.sendCommand(command)
    flags = int(settings[2], 16)
    return not (flags & 0x0008)
593596
public function getBackgroundColorEscapeSequence ( $colorName = '' ) {
        if ( $this->_isDefinedColor($colorName) === true ) {
            $colors = self::getDefinedColors();
            list($textColor, $backgroundColor) = $colors[$colorName];
            return $backgroundColor;
        }
        return '';
    }
1329602
function(){
        var _arr=[],_row=20,_col=3;
        for(var i=0;i<_row;i++)
            for(var j=0;j<_col;j++)
                _arr.push('.#<uispace> .z-i-'+i+j+'{background-position:-'+(16*j)+'px -'+(40+i*16)+'px;}');
        return _arr.join('');
    }