Class VectorGraphicsPainter
- java.lang.Object
-
- ej.microvg.VectorGraphicsPainter
-
public class VectorGraphicsPainter extends Object
Provides static methods to draw paths, texts and images.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classVectorGraphicsPainter.DirectionEnum for specifying the direction in which a rotation can occur.static classVectorGraphicsPainter.FillTypeEnum for the ways a path may be filled.
-
Constructor Summary
Constructors Constructor Description VectorGraphicsPainter()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voiddrawAnimatedImage(GraphicsContext g, VectorImage image, float x, float y, long elapsedTime)Draws an animated vector image at a specific time.static voiddrawAnimatedImage(GraphicsContext g, VectorImage image, Matrix matrix, long elapsedTime)Draws an animated vector image at a specific time.static voiddrawAnimatedImage(GraphicsContext g, VectorImage image, Matrix matrix, long elapsedTime, int alpha)Draws an animated vector image at a specific time.static voiddrawFilteredAnimatedImage(GraphicsContext g, VectorImage image, Matrix matrix, long elapsedTime, float[] colorMatrix)Draws an animated vector image at a specific time with a color filter.static voiddrawFilteredImage(GraphicsContext g, VectorImage image, Matrix matrix, float[] colorMatrix)Draws a vector image with a color filter.static voiddrawGradientString(GraphicsContext g, String string, VectorFont font, float size, Matrix matrix, LinearGradient gradient, int alpha, BlendMode blendMode, float letterSpacing)Draws a text with a gradient.static voiddrawGradientStringOnCircle(GraphicsContext g, String string, VectorFont font, float size, Matrix matrix, LinearGradient gradient, float radius, VectorGraphicsPainter.Direction direction, int alpha, BlendMode blendMode, float letterSpacing)Draws a text with a gradient along a circle.static voiddrawImage(GraphicsContext g, VectorImage image, float x, float y)Draws a vector image.static voiddrawImage(GraphicsContext g, VectorImage image, Matrix matrix)Draws a vector image.static voiddrawImage(GraphicsContext g, VectorImage image, Matrix matrix, int alpha)Draws a vector image.static voiddrawString(GraphicsContext g, String string, VectorFont font, float size, float x, float y)Draws a text.static voiddrawString(GraphicsContext g, String string, VectorFont font, float size, Matrix matrix, int alpha, BlendMode blendMode, float letterSpacing)Draws a text.static voiddrawStringOnCircle(GraphicsContext g, String string, VectorFont font, float size, Matrix matrix, float radius, VectorGraphicsPainter.Direction direction)Draws a text along a circle.static voiddrawStringOnCircle(GraphicsContext g, String string, VectorFont font, float size, Matrix matrix, float radius, VectorGraphicsPainter.Direction direction, int alpha, BlendMode blendMode, float letterSpacing)Draws a text along a circle.static voidfillGradientPath(GraphicsContext g, Path path, Matrix matrix, LinearGradient gradient)Draws a path filled with a linear gradient and winding fill type and source over blending.static voidfillGradientPath(GraphicsContext g, Path path, Matrix matrix, LinearGradient gradient, VectorGraphicsPainter.FillType fillType, int alpha, BlendMode blendMode)Draws a path filled with a linear gradient.static voidfillPath(GraphicsContext g, Path path, float x, float y)Draws a path filled with the color of the graphics context and winding fill type and source over blending.static voidfillPath(GraphicsContext g, Path path, Matrix matrix)Draws a path filled with the color of the graphics context and winding fill type and source over blending.static voidfillPath(GraphicsContext g, Path path, Matrix matrix, VectorGraphicsPainter.FillType fillType, int alpha, BlendMode blendMode)Draws a path filled with the color of the graphics context.
-
-
-
Method Detail
-
fillPath
public static void fillPath(GraphicsContext g, Path path, float x, float y)
Draws a path filled with the color of the graphics context and winding fill type and source over blending.Equivalent to:
Matrix matrix = new Matrix(); matrix.setTranslate(x, y); fillPath(g, path, matrix, FillType.WINDING, GraphicsContext.OPAQUE, BlendMode.SRC_OVER);
- Parameters:
g- the graphics context to draw onpath- the path to drawx- the x coordinate of the pathy- the y coordinate of the path
-
fillPath
public static void fillPath(GraphicsContext g, Path path, Matrix matrix)
Draws a path filled with the color of the graphics context and winding fill type and source over blending.Equivalent to:
fillPath(g, path, matrix, FillType.WINDING, GraphicsContext.OPAQUE, BlendMode.SRC_OVER);
- Parameters:
g- the graphics context to draw onpath- the path to drawmatrix- the matrix to apply
-
fillPath
public static void fillPath(GraphicsContext g, Path path, Matrix matrix, VectorGraphicsPainter.FillType fillType, int alpha, BlendMode blendMode)
Draws a path filled with the color of the graphics context.- Parameters:
g- the graphics context to draw onpath- the path to drawmatrix- the matrix to applyfillType- the fill typealpha- the global opacity rendering value, between 0 (transparent) and 255 (opaque)blendMode- the blend mode- See Also:
GraphicsContext.getAlpha(int)
-
fillGradientPath
public static void fillGradientPath(GraphicsContext g, Path path, Matrix matrix, LinearGradient gradient)
Draws a path filled with a linear gradient and winding fill type and source over blending.The color of the graphics context is not used by this drawing.
Equivalent to:
fillGradientPath(g, path, matrix, gradient, FillType.WINDING, GraphicsContext.OPAQUE, BlendMode.SRC_OVER);
- Parameters:
g- the graphics context to draw onpath- the path to drawmatrix- the matrix to applygradient- the gradient to fill with
-
fillGradientPath
public static void fillGradientPath(GraphicsContext g, Path path, Matrix matrix, LinearGradient gradient, VectorGraphicsPainter.FillType fillType, int alpha, BlendMode blendMode)
Draws a path filled with a linear gradient.The color of the graphics context is not used by this drawing.
- Parameters:
g- the graphics context to draw onpath- the path to drawmatrix- the matrix to applygradient- the gradient to fill withfillType- the fill typealpha- the global opacity rendering value, between 0 (transparent) and 255 (opaque)blendMode- the blend mode- See Also:
GraphicsContext.getAlpha(int)
-
drawImage
public static void drawImage(GraphicsContext g, VectorImage image, float x, float y)
Draws a vector image.Equivalent to:
Matrix matrix = new Matrix(); matrix.setTranslate(x, y); drawImage(g, image, matrix, GraphicsContext.OPAQUE);
- Parameters:
g- the graphics context to draw onimage- the image to drawx- the x coordinate of the imagey- the y coordinate of the image- Throws:
VectorGraphicsException- if the image could not be drawn for any reason (seeVectorGraphicsException.getErrorCode())
-
drawImage
public static void drawImage(GraphicsContext g, VectorImage image, Matrix matrix)
Draws a vector image.Equivalent to:
drawImage(g, image, matrix, GraphicsContext.OPAQUE);
- Parameters:
g- the graphics context to draw onimage- the image to drawmatrix- the matrix to apply- Throws:
VectorGraphicsException- if the image could not be drawn for any reason (seeVectorGraphicsException.getErrorCode())
-
drawImage
public static void drawImage(GraphicsContext g, VectorImage image, Matrix matrix, int alpha)
Draws a vector image.- Parameters:
g- the graphics context to draw onimage- the image to drawmatrix- the matrix to applyalpha- the global opacity rendering value, between 0 (transparent) and 255 (opaque)- Throws:
VectorGraphicsException- if the image could not be drawn for any reason (seeVectorGraphicsException.getErrorCode())- See Also:
GraphicsContext.getAlpha(int)
-
drawAnimatedImage
public static void drawAnimatedImage(GraphicsContext g, VectorImage image, float x, float y, long elapsedTime)
Draws an animated vector image at a specific time.The given elapsed time is cropped between 0 and the image duration.
Equivalent to:
Matrix matrix = new Matrix(); matrix.setTranslate(x, y); drawAnimatedImage(g, image, matrix, elapsedTime, GraphicsContext.OPAQUE);
- Parameters:
g- the graphics context to draw onimage- the image to drawx- the x coordinate of the imagey- the y coordinate of the imageelapsedTime- the elapsed time since the beginning of the animation, in milliseconds- Throws:
VectorGraphicsException- if the image could not be drawn for any reason (seeVectorGraphicsException.getErrorCode())
-
drawAnimatedImage
public static void drawAnimatedImage(GraphicsContext g, VectorImage image, Matrix matrix, long elapsedTime)
Draws an animated vector image at a specific time.The given elapsed time is cropped between 0 and the image duration.
Equivalent to:
drawAnimatedImage(g, image, matrix, elapsedTime, GraphicsContext.OPAQUE);
- Parameters:
g- the graphics context to draw onimage- the image to drawmatrix- the matrix to applyelapsedTime- the elapsed time since the beginning of the animation, in milliseconds- Throws:
VectorGraphicsException- if the image could not be drawn for any reason (seeVectorGraphicsException.getErrorCode())
-
drawAnimatedImage
public static void drawAnimatedImage(GraphicsContext g, VectorImage image, Matrix matrix, long elapsedTime, int alpha)
Draws an animated vector image at a specific time.The given elapsed time is cropped between 0 and the image duration.
- Parameters:
g- the graphics context to draw onimage- the image to drawmatrix- the matrix to applyelapsedTime- the elapsed time since the beginning of the animation, in millisecondsalpha- the global opacity rendering value, between 0 (transparent) and 255 (opaque)- Throws:
VectorGraphicsException- if the image could not be drawn for any reason (seeVectorGraphicsException.getErrorCode())- See Also:
GraphicsContext.getAlpha(int)
-
drawFilteredImage
public static void drawFilteredImage(GraphicsContext g, VectorImage image, Matrix matrix, float[] colorMatrix)
Draws a vector image with a color filter.- Parameters:
g- the graphics context to draw onimage- the image to drawmatrix- the matrix to applycolorMatrix- the color matrix used to transform colors- Throws:
VectorGraphicsException- if the image could not be drawn for any reason (seeVectorGraphicsException.getErrorCode())ArrayIndexOutOfBoundsException- if the given color matrix is shorter than 20 entries- See Also:
VectorImage.filterImage(float[])
-
drawFilteredAnimatedImage
public static void drawFilteredAnimatedImage(GraphicsContext g, VectorImage image, Matrix matrix, long elapsedTime, float[] colorMatrix)
Draws an animated vector image at a specific time with a color filter.- Parameters:
g- the graphics context to draw onimage- the image to drawmatrix- the matrix to applyelapsedTime- the elapsed time since the beginning of the animation, in millisecondscolorMatrix- the color matrix used to transform colors- Throws:
VectorGraphicsException- if the image could not be drawn for any reason (seeVectorGraphicsException.getErrorCode())ArrayIndexOutOfBoundsException- if the given color matrix is shorter than 20 entries- See Also:
VectorImage.filterImage(float[])
-
drawString
public static void drawString(GraphicsContext g, String string, VectorFont font, float size, float x, float y)
Draws a text.This method uses the color of the graphics context as font color.
The anchor point is the top left corner of the text render box (related to font height; different from the text bounding box, which is related to font size; see class comment
VectorFont). The position of this anchor point within the graphics context is defined by the(x,y)coordinates.For example, to draw a text where
yBaselinedefines the y coordinate of the text baseline, useyBaseline - font.getBaselinePosition()as argument of this method (seeVectorFont.getBaselinePosition(float)).The font size must be positive. If it is less than or equal to 0, nothing is drawn.
Equivalent to:
Matrix matrix = new Matrix(); matrix.setTranslate(x, y); drawString(g, string font, size, matrix, GraphicsContext.OPAQUE, BlendMode.SRC_OVER, 0);
- Parameters:
g- the graphics context to draw onstring- the text to drawfont- the font to usesize- the font size, in pixelsx- the x coordinate of the stringy- the y coordinate of the string- Throws:
VectorGraphicsException- if the text could not be drawn for any reason (seeVectorGraphicsException.getErrorCode())
-
drawString
public static void drawString(GraphicsContext g, String string, VectorFont font, float size, Matrix matrix, int alpha, BlendMode blendMode, float letterSpacing)
Draws a text.This method uses the color of the graphics context as font color.
The anchor point is the top left corner of the text render box (related to font height; different from the text bounding box, which is related to font size; see class comment
VectorFont). The matrix defines the transformations to apply to the text (translation, scale, rotation). For example, passing the identity matrix to this method will draw an horizontal text whose top-left corner is aligned with the origin of the graphics context.The font size must be positive. If it is less than or equal to 0, nothing is drawn.
This method allows to specify the global opacity value to apply during the rendering. The alpha must be a value between 0 and 255. If the specified alpha is outside this range, nothing is drawn.
The blend mode specifies the algorithm to use when blending the pixels of the source and destination.
The letter spacing argument specifies the extra space to add between the characters. A positive value will move the characters apart, a negative value will move them together. The default value is 0.
- Parameters:
g- the graphics context to draw onstring- the text to drawfont- the font to usesize- the font size, in pixelsmatrix- the transformation matrix to applyalpha- the global opacity rendering valueblendMode- the blend mode to useletterSpacing- the extra letter spacing to use, in pixels- Throws:
VectorGraphicsException- if the text could not be drawn for any reason (seeVectorGraphicsException.getErrorCode())- See Also:
GraphicsContext.getAlpha(int),BlendMode
-
drawStringOnCircle
public static void drawStringOnCircle(GraphicsContext g, String string, VectorFont font, float size, Matrix matrix, float radius, VectorGraphicsPainter.Direction direction)
Draws a text along a circle. The circle represents the text baseline.This method uses the color of the graphics context as font color.
The anchor point is the center of the circle. The matrix defines the transformations to apply to the text (translation, scale, rotation). For example, passing the identity matrix to this method will align the center of the circle with the origin of the graphics context.
The position where the text starts along the circle is the 3 o'clock position (positive X axis). This starting position can be modified by specifying a rotation into the transformation matrix.
The text winds along the circle in the specified direction (clockwise or counter-clockwise). The radius of the circle must be positive. If it is less than or equal to 0, nothing is drawn.
The font size must be positive. If it is less than or equal to 0, nothing is drawn.
Equivalent to:
drawStringOnCircle(g, string font, size, matrix, radius, direction, GraphicsContext.OPAQUE, BlendMode.SRC_OVER, 0);
- Parameters:
g- the graphics context to draw onstring- the string to drawfont- the font to usesize- the font size, in pixelsmatrix- the matrix to applyradius- the radius of the circle, in pixelsdirection- the winding direction of the text along the circle.- Throws:
VectorGraphicsException- if the text could not be drawn for any reason (seeVectorGraphicsException.getErrorCode())- See Also:
VectorGraphicsPainter.Direction
-
drawStringOnCircle
public static void drawStringOnCircle(GraphicsContext g, String string, VectorFont font, float size, Matrix matrix, float radius, VectorGraphicsPainter.Direction direction, int alpha, BlendMode blendMode, float letterSpacing)
Draws a text along a circle. The circle represents the text baseline.This method uses the color of the graphics context as font color.
The anchor point is the center of the circle. The matrix defines the transformations to apply to the text (translation, scale, rotation). For example, passing the identity matrix to this method will align the center of the circle with the origin of the graphics context.
The position where the text starts along the circle is the 3 o'clock position (positive X axis). This starting position can be modified by specifying a rotation into the transformation matrix.
The text winds along the circle in the specified direction (clockwise or counter-clockwise). The radius of the circle must be positive. If it is less than or equal to 0, nothing is drawn.
The font size must be positive. If it is less than or equal to 0, nothing is drawn.
This method allows to specify the global opacity value to apply during the rendering. The alpha must be a value between 0 and 255. If the specified alpha is outside this range, nothing is drawn.
The blend mode specifies the algorithm to use when blending the pixels of the source and destination.
The letter spacing argument specifies the extra space to add between the characters. A positive value will move the characters apart, a negative value will move them together. The default value is 0.
- Parameters:
g- the graphics context to draw onstring- the string to drawfont- the font to usesize- the font size, in pixelsmatrix- the matrix to applyradius- the radius of the circle, in pixelsdirection- the winding direction of the text along the circlealpha- the global opacity rendering valueblendMode- the blend modeletterSpacing- the extra letter spacing to use, in pixels- Throws:
VectorGraphicsException- if the text could not be drawn for any reason (seeVectorGraphicsException.getErrorCode())- See Also:
GraphicsContext.getAlpha(int),BlendMode,VectorGraphicsPainter.Direction
-
drawGradientString
public static void drawGradientString(GraphicsContext g, String string, VectorFont font, float size, Matrix matrix, LinearGradient gradient, int alpha, BlendMode blendMode, float letterSpacing)
Draws a text with a gradient.This method uses the given gradient for the font coloring. The color of the graphics context is not used by this drawing.
The anchor point is the top left corner of the text render box (related to font height; different from the text bounding box, which is related to font size; see class comment
VectorFont). The matrix defines the transformations to apply to the text (translation, scale, rotation). For example, passing the identity matrix to this method will draw an horizontal text whose top-left corner is aligned with the origin of the graphics context.The font size must be positive. If it is less than or equal to 0, nothing is drawn.
This method allows to specify the global opacity value to apply during the rendering. The alpha must be a value between 0 and 255. If the specified alpha is outside this range, nothing is drawn.
The blend mode specifies the algorithm to use when blending the pixels of the source and destination.
The letter spacing argument specifies the extra space to add between the characters. A positive value will move the characters apart, a negative value will move them together. The default value is 0.
- Parameters:
g- the graphics context to draw onstring- the text to drawfont- the font to usesize- the font size, in pixelsmatrix- the transformation matrix to applygradient- the gradient to color the text withalpha- the global opacity rendering valueblendMode- the blend modeletterSpacing- the extra letter spacing to use, in pixels- Throws:
VectorGraphicsException- if the text could not be drawn for any reason (seeVectorGraphicsException.getErrorCode())- See Also:
GraphicsContext.getAlpha(int),BlendMode
-
drawGradientStringOnCircle
public static void drawGradientStringOnCircle(GraphicsContext g, String string, VectorFont font, float size, Matrix matrix, LinearGradient gradient, float radius, VectorGraphicsPainter.Direction direction, int alpha, BlendMode blendMode, float letterSpacing)
Draws a text with a gradient along a circle. The circle represents the text baseline.This method uses the given gradient for the font coloring. The color of the graphics context is not used by this drawing.
The anchor point is the center of the circle. The matrix defines the transformations to apply to the text (translation, scale, rotation). For example, passing the identity matrix to this method will align the center of the circle with the origin of the graphics context.
The position where the text starts along the circle is the 3 o'clock position (positive X axis). This starting position can be modified by specifying a rotation into the transformation matrix.
The text winds along the circle in the specified direction (clockwise or counter-clockwise). The radius of the circle must be positive. If it is less than or equal to 0, nothing is drawn.
The font size must be positive. If it is less than or equal to 0, nothing is drawn.
This method allows to specify the global opacity value to apply during the rendering. The alpha must be a value between 0 and 255. If the specified alpha is outside this range, nothing is drawn.
The blend mode specifies the algorithm to use when blending the pixels of the source and destination.
The letter spacing argument specifies the extra space to add between the characters. A positive value will move the characters apart, a negative value will move them together. The default value is 0.
- Parameters:
g- the graphics context to draw onstring- the string to drawfont- the font to usesize- the font size, in pixelsmatrix- the matrix to applygradient- the gradient to color the string withalpha- the global opacity rendering valueblendMode- the blend modeletterSpacing- the extra letter spacing to use, in pixelsradius- the radius of the circle, in pixelsdirection- the winding direction of the text along the circle- Throws:
VectorGraphicsException- if the text could not be drawn for any reason (seeVectorGraphicsException.getErrorCode())- See Also:
GraphicsContext.getAlpha(int),BlendMode,VectorGraphicsPainter.Direction
-
-