Provides low-level graphical components like colors, shape primitives for creating and adding shapes directly to the screen using a canvas-based model, and animation.
This package provides an object-oriented model for drawing shapes on the
screen. The ShapeView
provides a canvas where objects
that extend Shape
can be added and removed, and the
visuals on the screen are automatically updated whenever shapes are
manipulated.
Sofia provides a number of shape classes that you can begin using right away:
LineShape
RectangleShape
OvalShape
TextShape
You can use these shape classes directly or extend them to add your own
capabilities. For example, in a game you might extend
RectangleShape
to create a few classes that represent
different playable and non-playable entities in the game.
All shapes have an animate(long)
method that
allow you to construct animations that will run in the background. This
method takes the duration of the animation in milliseconds as an argument
(so an animation that runs for 1 second would pass in 1000). It returns an
Shape.Animator
object (or an Animator
nested inside the Shape
subclass being animated) with several
methods that can be chained together to indicate which properties should be
animated.
These animations are interpolating animations, meaning that they operate by considering two values – the value of a shape property at the beginning of an animation and the desired value of the same property at the end of the animation – and interpolates the intermediate values of that property to make the shape appear to animate. Consider the following example:
shape.setColor(Color.black); shape.animate(1000).color(Color.red).play();
In this case a shape starts out black and animates to red over a duration of 1 second. This would cause the shape to "fade in", starting dark and getting brighter until the duration has passed.
Motion can also be achieved in these animations:
shape.setColor(Color.black); shape.animate(1000).position(10, 40).play();
To be written.
Joint | An interface that represents joints between shapes. |
PropertyTransformer | Write a one-sentence summary of your class here. |
AbstractJoint<JointType extends Joint, JointDefType extends JointDef> | The abstract base class for all Sofia classes representing JBox2D joints. |
Anchor |
An |
Color | Represents a color, which is composed of red, green, blue, and alpha components, which are integers between 0 and 255. |
CoordinateSystem |
Allows the user to modify the coordinate system of a |
DirectionalPad | An on-screen directional pad (d-pad) suitable for games, based on the cross-shaped d-pad used on classic console game systems. |
DistanceJoint | A joint that forces the distance between two shapes to always remain constant, or within a certain amount of each other (like a spring-damper). |
ElasticInInterpolator | |
ElasticInOutInterpolator | |
ElasticOutInterpolator | |
FillableShape | An abstract class that represents shapes that can be filled when they are drawn, and for which the fill color can be set independently of the shape's other color (for the stroke). |
FillableShape.Animator<AnimatorType extends Animator<AnimatorType>> | Provides animation support for shapes. |
Geometry | This class contains various geometry-related static helper methods. |
Image | Represents a single bitmapped image, such as one loaded from a file. |
LineShape | A shape that is drawn as a line between two points. |
MotionStep | |
OvalShape | A shape that is drawn as an oval. |
PointAndAnchor | A PointAndAnchor encapsulates a PointF denoting a location
on a shape canvas and an Anchor that indicates how a shape should be
anchored to that point. |
Polygon | This class represents a polygon as a list of vertices. |
PolygonShape | A shape that is drawn using an arbitrary polygon. |
Predicate<T> | Predicates are used to specify numeric (and other) criteria when filtering shapes. |
RectangleShape | A shape that is drawn as a rectangle. |
RevoluteJoint | A joint that forces two shapes to share a common anchor point, allowing only the relative rotation between them to change. |
Shape | The base class for all types of shapes that can be drawn on a
ShapeView . |
Shape.Animator<AnimatorType extends Animator<AnimatorType>> | Provides animation support for shapes. |
Shape.Filter<FilterType extends Animator<FilterType>> | |
ShapeField | A shape field is a shape set that also provides (optional) real-time physics simulation. |
ShapeFilter<ShapeType extends Shape> | A chainable filter that lets you search for shapes in a field based on a set of criteria. |
ShapeSet<ShapeType extends Shape> |
Represents a collection of |
ShapeView | Represents a view containing drawn Shape objects. |
SizeF | A class used elsewhere in Sofia that holds two float coordinates representing the width and height of an object. |
StrokedShape | An abstract class that represents shapes that include a stroke or outline when they are drawn. |
StrokedShape.Animator<AnimatorType extends Animator<AnimatorType>> | Provides animation support for shapes. |
TextShape | A shape that renders a text string on the canvas. |
TextShape.Animator<AnimatorType extends Animator<AnimatorType>> | Provides animation support for shapes. |
Timings | This class provides static helper methods that provide friendlier names for timing functions (interpolators) used in animations. |
ViewEdges | Represents one or more of the four edges of a view, used with collision detection. |
ZIndexComparator | A comparator for shapes that orders them by increasing z-index, or for identical z-indices, orders them by increasing insertion time (i.e., newer shapes are after older shapes). |
RepeatMode | Defines how an animation repeats itself. |
ShapeMotion | Determines the physical nature of a shape and how it is simulated and how it responds to forces. |