Skip to content

Commit 94bcf03

Browse files
author
Mike Barkmin
committed
Add getter for pixels to sprite and stage
1 parent 98dc2ee commit 94bcf03

File tree

3 files changed

+38
-2
lines changed

3 files changed

+38
-2
lines changed

resources/build.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,12 @@ source.repository=https://github.com/mikebarkmin/processing-library-scratch.git
131131
# This is used to compare different versions of the same Library, and check if
132132
# an update is available.
133133

134-
library.version=6
134+
library.version=7
135135

136136

137137
# The version as the user will see it.
138138

139-
library.prettyVersion=1.5.0
139+
library.prettyVersion=1.6.0
140140

141141

142142
# The min and max revision of Processing compatible with your Library.

src/eu/barkmin/processing/scratch/ScratchSprite.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,16 @@ public int getHeight() {
457457
return this.costumes.get(this.currentCostume).getImage().height;
458458
}
459459

460+
/**
461+
* Return the pixels of the current costume or an empty array, when no costume is available.
462+
* @return the pixels of the sprite
463+
*/
464+
public int[] getPixels() {
465+
if (costumes.size() == 0) return new int[0];
466+
467+
return this.costumes.get(this.currentCostume).getImage().pixels;
468+
}
469+
460470
/**
461471
* Return the default timer
462472
* @return the default timer

src/eu/barkmin/processing/scratch/ScratchStage.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,32 @@ public void changeTransparency(float step) {
250250
this.backdrops.get(this.currentBackdrop).changeTransparency(step);
251251
}
252252

253+
/**
254+
* Return the width of the current costume or the pen size, when no costume is available.
255+
* @return the width of the sprite
256+
*/
257+
public int getWidth() {
258+
return ScratchStage.parent.width;
259+
}
260+
261+
/**
262+
* Return the height of the current costume or the pen size, when no costume is available.
263+
* @return the height of the sprite
264+
*/
265+
public int getHeight() {
266+
return ScratchStage.parent.height;
267+
}
268+
269+
/**
270+
* Return the pixels of the current costume or an empty array, when no costume is available.
271+
* @return the pixels of the sprite
272+
*/
273+
public int[] getPixels() {
274+
if (backdrops.size() == 0) return new int[0];
275+
276+
return this.backdrops.get(this.currentBackdrop).getImage().pixels;
277+
}
278+
253279
/**
254280
* Returns the timer
255281
* @return the timer

0 commit comments

Comments
 (0)