@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.)
hq.recaptime.dev/wiki/Phorge
phorge
phabricator
1<?php
2
3/**
4 * NOTE: This is very new and unstable.
5 */
6final class PhutilSprite extends Phobject {
7
8 private $sourceFiles = array();
9 private $sourceX;
10 private $sourceY;
11 private $sourceW;
12 private $sourceH;
13 private $targetCSS;
14 private $spriteSheet;
15 private $name;
16
17 public function setName($name) {
18 $this->name = $name;
19 return $this;
20 }
21
22 public function getName() {
23 return $this->name;
24 }
25
26 public function setTargetCSS($target_css) {
27 $this->targetCSS = $target_css;
28 return $this;
29 }
30
31 public function getTargetCSS() {
32 return $this->targetCSS;
33 }
34
35 public function setSourcePosition($x, $y) {
36 $this->sourceX = $x;
37 $this->sourceY = $y;
38 return $this;
39 }
40
41 public function setSourceSize($w, $h) {
42 $this->sourceW = $w;
43 $this->sourceH = $h;
44 return $this;
45 }
46
47 public function getSourceH() {
48 return $this->sourceH;
49 }
50
51 public function getSourceW() {
52 return $this->sourceW;
53 }
54
55 public function getSourceY() {
56 return $this->sourceY;
57 }
58
59 public function getSourceX() {
60 return $this->sourceX;
61 }
62
63 public function setSourceFile($source_file, $scale = 1) {
64 $this->sourceFiles[$scale] = $source_file;
65 return $this;
66 }
67
68 public function getSourceFile($scale) {
69 if (empty($this->sourceFiles[$scale])) {
70 throw new Exception(pht("No source file for scale '%s'!", $scale));
71 }
72
73 return $this->sourceFiles[$scale];
74 }
75
76}