Changeset View
Changeset View
Standalone View
Standalone View
src/applications/celerity/CeleritySpriteGenerator.php
| <?php | <?php | ||||
| final class CeleritySpriteGenerator extends Phobject { | final class CeleritySpriteGenerator extends Phobject { | ||||
| public function buildMenuSheet() { | |||||
| $sprites = array(); | |||||
| $colors = array( | |||||
| 'dark', | |||||
| 'light', | |||||
| ); | |||||
| $sources = array(); | |||||
| foreach ($colors as $color) { | |||||
| $sources[$color.'-logo'] = array( | |||||
| 'x' => 96, | |||||
| 'y' => 40, | |||||
| 'css' => '.'.$color.'-logo', | |||||
| ); | |||||
| $sources[$color.'-eye'] = array( | |||||
| 'x' => 40, | |||||
| 'y' => 40, | |||||
| 'css' => '.'.$color.'-eye', | |||||
| ); | |||||
| } | |||||
| $scales = array( | |||||
| '1x' => 1, | |||||
| '2x' => 2, | |||||
| ); | |||||
| $template = new PhutilSprite(); | |||||
| foreach ($sources as $name => $spec) { | |||||
| $sprite = id(clone $template) | |||||
| ->setName($name) | |||||
| ->setSourceSize($spec['x'], $spec['y']) | |||||
| ->setTargetCSS($spec['css']); | |||||
| foreach ($scales as $scale_name => $scale) { | |||||
| $path = 'menu_'.$scale_name.'/'.$name.'.png'; | |||||
| $path = $this->getPath($path); | |||||
| $sprite->setSourceFile($path, $scale); | |||||
| } | |||||
| $sprites[] = $sprite; | |||||
| } | |||||
| $sheet = $this->buildSheet('menu', true); | |||||
| $sheet->setScales($scales); | |||||
| foreach ($sprites as $sprite) { | |||||
| $sheet->addSprite($sprite); | |||||
| } | |||||
| return $sheet; | |||||
| } | |||||
| public function buildTokenSheet() { | public function buildTokenSheet() { | ||||
| $icons = $this->getDirectoryList('tokens_1x'); | $icons = $this->getDirectoryList('tokens_1x'); | ||||
| $scales = array( | $scales = array( | ||||
| '1x' => 1, | '1x' => 1, | ||||
| '2x' => 2, | '2x' => 2, | ||||
| ); | ); | ||||
| $template = id(new PhutilSprite()) | $template = id(new PhutilSprite()) | ||||
| ->setSourceSize(18, 18); | ->setSourceSize(18, 18); | ||||
| ▲ Show 20 Lines • Show All 141 Lines • Show Last 20 Lines | |||||