Skip to content

Commit 2f1737c

Browse files
committed
Extracted constant to base class
Also, used said constants
1 parent 66c0d10 commit 2f1737c

3 files changed

Lines changed: 20 additions & 30 deletions

File tree

filters/filter.crop.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,6 @@ class FilterCrop extends JIT\ImageFilter
55

66
public $mode = 3;
77

8-
const TOP_LEFT = 1;
9-
const TOP_MIDDLE = 2;
10-
const TOP_RIGHT = 3;
11-
const MIDDLE_LEFT = 4;
12-
const CENTER = 5;
13-
const MIDDLE_RIGHT = 6;
14-
const BOTTOM_LEFT = 7;
15-
const BOTTOM_MIDDLE = 8;
16-
const BOTTOM_RIGHT = 9;
17-
188
public static function about()
199
{
2010
return array(

filters/filter.resizeandcrop.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,6 @@ class FilterResizeAndCrop extends JIT\ImageFilter
55

66
public $mode = 2;
77

8-
const TOP_LEFT = 1;
9-
const TOP_MIDDLE = 2;
10-
const TOP_RIGHT = 3;
11-
const MIDDLE_LEFT = 4;
12-
const CENTER = 5;
13-
const MIDDLE_RIGHT = 6;
14-
const BOTTOM_LEFT = 7;
15-
const BOTTOM_MIDDLE = 8;
16-
const BOTTOM_RIGHT = 9;
17-
188
public static function about()
199
{
2010
return array(

lib/class.imagefilter.php

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,17 @@ abstract class ImageFilter implements ImageFilterInterface
88
const CHANNEL_RED = 0;
99
const CHANNEL_GREEN = 1;
1010
const CHANNEL_BLUE = 2;
11-
11+
12+
const TOP_LEFT = 1;
13+
const TOP_MIDDLE = 2;
14+
const TOP_RIGHT = 3;
15+
const MIDDLE_LEFT = 4;
16+
const CENTER = 5;
17+
const MIDDLE_RIGHT = 6;
18+
const BOTTOM_LEFT = 7;
19+
const BOTTOM_MIDDLE = 8;
20+
const BOTTOM_RIGHT = 9;
21+
1222
abstract public static function about();
1323

1424
abstract public function parseParameters($parameter_string);
@@ -120,41 +130,41 @@ protected static function __calculateDestSrcXY($width, $height, $src_w, $src_h,
120130

121131
switch ($position) {
122132

123-
case 1:
133+
case self::TOP_LEFT:
124134
break;
125135

126-
case 2:
136+
case self::TOP_MIDDLE:
127137
$src_x = 1;
128138
break;
129139

130-
case 3:
140+
case self::TOP_RIGHT:
131141
$src_x = 2;
132142
break;
133143

134-
case 4:
144+
case self::MIDDLE_LEFT:
135145
$src_y = 1;
136146
break;
137147

138-
case 5:
148+
case self::CENTER:
139149
$src_x = 1;
140150
$src_y = 1;
141151
break;
142152

143-
case 6:
153+
case self::MIDDLE_RIGHT:
144154
$src_x = 2;
145155
$src_y = 1;
146156
break;
147157

148-
case 7:
158+
case self::BOTTOM_LEFT:
149159
$src_y = 2;
150160
break;
151161

152-
case 8:
162+
case self::BOTTOM_MIDDLE:
153163
$src_x = 1;
154164
$src_y = 2;
155165
break;
156166

157-
case 9:
167+
case self::BOTTOM_RIGHT:
158168
$src_x = 2;
159169
$src_y = 2;
160170
break;

0 commit comments

Comments
 (0)