SnapCode Update April 25: Added SnapImage

This week I added a class to SnapCode to facilitate “sprite” programming with SnapActor. The class is called SnapImage and it has methods to load an image from a file name, and methods to do all kinds of drawing and basic image manipulation: flipImage, rotateImage, sizeImage, setColor (for a pixel), etc.

SnapActor now has a primary attribute that is a SnapImage, so you can easily create actors with custom drawing and you can easily change the look of an actor on the fly by resetting or manipulating the SnapActor.Image.

Additionally, I added a new SnapActor subclass to make it possible to have compound or nested actors. This class is called SnapParent, and it basically has a list attribute called Actors that lets you add/remove child actors, and it has methods to do hit detection on those child actors and/or retrieve subsets of the actors by class. Since this essentially what SnapScene does, I made SnapScene a SnapParent subclass to get more consistency and code re-use.

Here is a full list of the week’s changes:

– SnapImage: Added class to add rendering and drawing functionality to Actors
– SnapImage: Added flipImageX/flipImageY/rotateImage() to get current image in new orientation
– SnapImage: Added getColor(int,int) and setColor(int,int,color)
– SnapImage: Added Opacity attribute
– SnapImage: Added fillRoundRect, strokeLine, strokeRect, strokeRoundRect
– SnapImage: Added drawImage(image, x,y)
– SnapScene: Added start/stop methods
– SnapParent: Created Actor subclass that can have child actors
– SnapScene: Made this a subclass of SnapParent so it gets same Actor/Image management

SnapCode is available here.

Advertisements

2 Responses to “SnapCode Update April 25: Added SnapImage”

  1. Java desktop links of the week, April 28 « Jonathan Giles Says:

    […] Martin has blogged about the latest updates to SnapCode, his IDE and RAD tool for education, entertainment and the […]

  2. JavaFX links of the week, April 28 // JavaFX News, Demos and Insight // FX Experience Says:

    […] Martin has blogged about the latest updates to SnapCode, his IDE and RAD tool for education, entertainment and the […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: