Changeset View
Changeset View
Standalone View
Standalone View
src/applications/celerity/CeleritySpriteGenerator.php
| <?php | <?php | ||||
| final class CeleritySpriteGenerator { | final class CeleritySpriteGenerator { | ||||
| public function buildMenuSheet() { | public function buildMenuSheet() { | ||||
| $sprites = array(); | $sprites = array(); | ||||
| $sources = array( | $colors = array( | ||||
| 'logo' => array( | 'dark', | ||||
| 'red', | |||||
| 'blue', | |||||
| 'indigo', | |||||
| 'blindigo', | |||||
| 'rainbow', | |||||
| ); | |||||
| $sources = array(); | |||||
| foreach ($colors as $color) { | |||||
| $sources[$color.'-logo'] = array( | |||||
| 'x' => 96, | 'x' => 96, | ||||
| 'y' => 40, | 'y' => 40, | ||||
| 'css' => '.phabricator-main-menu-logo', | 'css' => '.'.$color.'-logo', | ||||
| ), | ); | ||||
| 'eye' => array( | $sources[$color.'-eye'] = array( | ||||
| 'x' => 40, | 'x' => 40, | ||||
| 'y' => 40, | 'y' => 40, | ||||
| 'css' => '.phabricator-main-menu-eye', | 'css' => '.'.$color.'-eye', | ||||
| ), | |||||
| ); | ); | ||||
| } | |||||
| $scales = array( | $scales = array( | ||||
| '1x' => 1, | '1x' => 1, | ||||
| '2x' => 2, | '2x' => 2, | ||||
| ); | ); | ||||
| $template = new PhutilSprite(); | $template = new PhutilSprite(); | ||||
| foreach ($sources as $name => $spec) { | foreach ($sources as $name => $spec) { | ||||
| ▲ Show 20 Lines • Show All 111 Lines • ▼ Show 20 Lines | public function buildLoginSheet() { | ||||
| $sheet->setScales($scales); | $sheet->setScales($scales); | ||||
| foreach ($sprites as $sprite) { | foreach ($sprites as $sprite) { | ||||
| $sheet->addSprite($sprite); | $sheet->addSprite($sprite); | ||||
| } | } | ||||
| return $sheet; | return $sheet; | ||||
| } | } | ||||
| public function buildMainHeaderSheet() { | |||||
| $gradients = $this->getDirectoryList('main_header'); | |||||
| $template = new PhutilSprite(); | |||||
| $sprites = array(); | |||||
| foreach ($gradients as $gradient) { | |||||
| $path = $this->getPath('main_header/'.$gradient.'.png'); | |||||
| $sprite = id(clone $template) | |||||
| ->setName('main-header-'.$gradient) | |||||
| ->setSourceFile($path) | |||||
| ->setTargetCSS('.main-header-'.$gradient); | |||||
| $sprite->setSourceSize(6, 44); | |||||
| $sprites[] = $sprite; | |||||
| } | |||||
| $sheet = $this->buildSheet('main-header', | |||||
| false, | |||||
| PhutilSpriteSheet::TYPE_REPEAT_X); | |||||
| foreach ($sprites as $sprite) { | |||||
| $sheet->addSprite($sprite); | |||||
| } | |||||
| return $sheet; | |||||
| } | |||||
| private function getPath($to_path = null) { | private function getPath($to_path = null) { | ||||
| $root = dirname(phutil_get_library_root('phabricator')); | $root = dirname(phutil_get_library_root('phabricator')); | ||||
| return $root.'/resources/sprite/'.$to_path; | return $root.'/resources/sprite/'.$to_path; | ||||
| } | } | ||||
| private function getDirectoryList($dir) { | private function getDirectoryList($dir) { | ||||
| $path = $this->getPath($dir); | $path = $this->getPath($dir); | ||||
| ▲ Show 20 Lines • Show All 76 Lines • Show Last 20 Lines | |||||