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 sofia.graphics.ImageShape 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.
CopyableGeometry<T> | |
Joint | TODO document |
PropertyTransformer | Write a one-sentence summary of your class here. |
ResolvableGeometry<T> | |
ShapeManipulating | Methods that manipulate shapes by adding or removing them from their parent, such as a ShapeView or a CompositeShape. |
ShapeParent | An interface implemented by classes that can contain a list of shapes, such as a ShapeView. |
ShapeQuerying | Methods that query shapes based on position, intersection, or other properties. |
AbstractJoint<JointType extends Joint, JointDefType extends JointDef> | TODO document |
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 ShapeView (or a ShapeScreen). |
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 | TODO document |
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. |
Predicate<T> | Predicates are used to specify numeric (and other) criteria when filtering shapes. |
RectangleShape | A shape that is drawn as a rectangle. |
RevoluteJoint | TODO document |
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> | TODO: document. |
ShapeSet<ShapeType extends Shape> | Represents a collection of Shape objects held in drawing order, based on z-index. |
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. |