Package com.vuzix.ultralite
Interface UltraliteSDK.Canvas
- Enclosing interface:
- UltraliteSDK
public static interface UltraliteSDK.Canvas
Canvas is used to perform direct drawing operations to the Ultralite display. Before a canvas
can be used, the Ultralite layout should be set to CANVAS. Otherwise Canvas methods won't do
anything. Glasses control is also required for all Canvas methods.
All canvas operations need to be committed before they will be reflected on the canvas. This allows you to stage an entire screen with changes and display them all at once. This is done by calling commit(). Please note that uncommitted changes may be shown early in some situations, so this should be called immediately after the last canvas element is sent to ensure predictable results.
All canvas operations need to be committed before they will be reflected on the canvas. This allows you to stage an entire screen with changes and display them all at once. This is done by calling commit(). Please note that uncommitted changes may be shown early in some situations, so this should be called immediately after the last canvas element is sent to ensure predictable results.
- Since:
- 1.0.0
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic interface
Gets notified when a commit is complete. -
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Clears the entire canvas.void
Clears the entire background layer.void
clearBackground
(UltraliteColor color) Clears the entire background layer to the specified color.void
clearBackgroundRect
(int x, int y, int width, int height) Clears a specific area of the background layer.void
clearBackgroundRect
(int x, int y, int width, int height, UltraliteColor color) Clears a specific area of the background layer to the specified color.void
commit()
Commits canvas changes made since the last commit.void
commit
(UltraliteSDK.Canvas.CommitCallback callback) Commits canvas changes made since the last commit.int
createAnimation
(LVGLImage[] images, Anchor anchor, int duration) Creates an animation out of an array of images.int
createAnimation
(LVGLImage[] images, Anchor anchor, int offsetX, int offsetY, int duration) Creates an animation out of an array of images.int
createImage
(LVGLImage image, Anchor anchor) Creates an identifiable image that can be manipulated.int
createImage
(LVGLImage image, Anchor anchor, boolean visible) Creates an identifiable image that can be manipulated.int
createImage
(LVGLImage image, Anchor anchor, int offsetX, int offsetY, boolean visible) Creates an identifiable image that can be manipulated.int
createText
(String text, Anchor anchor) Creates an identifiable block of text that can be manipulated.int
createText
(String text, TextAlignment alignment, UltraliteColor color, Anchor anchor, boolean visible) Creates an identifiable block of text that can be manipulated.int
createText
(String text, TextAlignment alignment, UltraliteColor color, Anchor anchor, int offsetX, int offsetY, int width, int height, TextWrapMode wrap, boolean visible) Creates an identifiable block of text that can be manipulated.boolean
drawBackground
(android.graphics.Bitmap bitmap, int x, int y) Draws the provided bitmap in the background layer at the specified coordinates.boolean
drawBackground
(android.graphics.Bitmap bitmap, android.graphics.Point[] coordinates) Draws the provided bitmap in the background layer at the specified coordinate pairs.boolean
drawBackground
(LVGLImage image, int x, int y) Draws the provided image in the background layer at the specified coordinates.boolean
drawBackground
(LVGLImage image, android.graphics.Point[] coordinates) Draws the provided image in the background layer at the specified coordinate pairs.boolean
moveAnimation
(int id, int x, int y) Moves an animation to a new absolute location on screen.boolean
moveAnimation
(int id, int x, int y, int durationMs) Moves an animation to a new absolute location on screen.boolean
moveImage
(int id, int x, int y) Moves an image to a new absolute location on screen.boolean
moveImage
(int id, int x, int y, int durationMs) Moves an image to a new absolute location on screen.boolean
moveText
(int id, int offsetX, int offsetY, int durationMs) Moves text to a new location.boolean
Moves text to a new location.boolean
removeAnimation
(int id) Removes a previously created animation.boolean
removeImage
(int id) Removes a previously created image.boolean
removeText
(int id) Removes a previously created text block.boolean
setAnimationVisible
(int id, boolean visible) Changes visibility of an animation.boolean
setImageVisible
(int id, boolean visible) Changes visibility of an image.boolean
setTextVisible
(int id, boolean visible) Changes visibility of text.boolean
updateImage
(int id, LVGLImage image) Replaces the image displayed with a particular id.boolean
updateText
(int id, String text) Replaces the text displayed with a particular id.
-
Field Details
-
WIDTH
static final int WIDTHavailable width of the canvas to which we can draw- Since:
- 1.2.0
- See Also:
-
HEIGHT
static final int HEIGHTavailable height of the canvas to which we can draw- Since:
- 1.2.0
- See Also:
-
-
Method Details
-
drawBackground
boolean drawBackground(@NonNull android.graphics.Bitmap bitmap, int x, int y) Draws the provided bitmap in the background layer at the specified coordinates. The bitmap can be no wider than 640 and no taller than 480, otherwise nothing will be drawn.- Parameters:
bitmap
- a bitmapx
- the x location to drawy
- the y location to draw- Returns:
- true if the bitmap was drawn on the background, false otherwise
- Since:
- 1.0.0
-
drawBackground
boolean drawBackground(@NonNull android.graphics.Bitmap bitmap, @NonNull android.graphics.Point[] coordinates) Draws the provided bitmap in the background layer at the specified coordinate pairs. The bitmap can be no wider than 640 and no taller than 480, otherwise nothing will be drawn.- Parameters:
bitmap
- a bitmapcoordinates
- an array of Point coordinate at which to draw the same image- Returns:
- true if the bitmap was drawn on the background, false otherwise
- Since:
- 1.0.0
-
drawBackground
Draws the provided image in the background layer at the specified coordinates. The image can be no wider than 640 and no taller than 480, otherwise nothing will be drawn.- Parameters:
image
- an LVGLImage in color format LVGLImage.CF_INDEXED_2_BITx
- the x location to drawy
- the y location to draw- Returns:
- true if the bitmap was drawn on the background, false otherwise
- Since:
- 1.4.0
-
drawBackground
Draws the provided image in the background layer at the specified coordinate pairs. The image can be no wider than 640 and no taller than 480, otherwise nothing will be drawn.- Parameters:
image
- an LVGLImage in color format LVGLImage.CF_INDEXED_2_BITcoordinates
- an array of Point coordinate at which to draw the same image- Returns:
- true if the bitmap was drawn on the background, false otherwise
- Since:
- 1.4.0
-
clearBackground
void clearBackground()Clears the entire background layer.- Since:
- 1.0.0
-
clearBackground
Clears the entire background layer to the specified color.- Parameters:
color
- the color to paint on the background- Since:
- 1.0.0
-
clearBackgroundRect
void clearBackgroundRect(int x, int y, int width, int height) Clears a specific area of the background layer.- Parameters:
x
- starting x location to cleary
- starting y location to clearwidth
- amount of horizontal space to clear (must be greater than zero)height
- amount of vertical space to clear (must be greater than zero)- Since:
- 1.0.0
-
clearBackgroundRect
Clears a specific area of the background layer to the specified color.- Parameters:
x
- starting x location to cleary
- starting y location to clearwidth
- amount of horizontal space to clear (must be greater than zero)height
- amount of vertical space to clear (must be greater than zero)color
- the color to paint on the background- Since:
- 1.0.0
-
createImage
Creates an identifiable image that can be manipulated. The image will initially be visible.
Note that only 3 images can be allocated. If you create more than this, you will start overwriting previously created images.
Also note that there is a limit of 9900 bytes for the image data. Images larger than this will not be created.- Parameters:
image
- the initial imageanchor
- where to anchor the image- Returns:
- an int that can be used to update the image or -1 if the image can't be created
- Since:
- 1.0.0
-
createImage
Creates an identifiable image that can be manipulated.
Note that only 3 images can be allocated. If you create more than this, you will start overwriting previously created images.
Also note that there is a limit of 9900 bytes for the image data. Images larger than this will not be created.- Parameters:
image
- the initial imageanchor
- where to anchor the imagevisible
- initial visibility of the image- Returns:
- an int that can be used to update the image or -1 if the image can't be created
- Since:
- 1.0.0
-
createImage
int createImage(@NonNull LVGLImage image, @NonNull Anchor anchor, int offsetX, int offsetY, boolean visible) Creates an identifiable image that can be manipulated.
Note that only 3 images can be allocated. If you create more than this, you will start overwriting previously created images.
Also note that there is a limit of 9900 bytes for the image data. Images larger than this will not be created.- Parameters:
image
- the initial imageanchor
- where to anchor the imageoffsetX
- the horizontal offsetoffsetY
- the vertical offsetvisible
- initial visibility of the image- Returns:
- an int that can be used to update the image or -1 if the image can't be created
- Since:
- 1.0.0
-
updateImage
Replaces the image displayed with a particular id. Location and visibility are not changed. If the provided id is invalid, this method does nothing.
Note that there is a limit of 9900 bytes for the image data. Images larger than this will not be updated.- Parameters:
id
- the image id returned by createImageimage
- the new image- Returns:
- true if the image was updated, false otherwise
- Since:
- 1.0.0
-
moveImage
boolean moveImage(int id, int x, int y) Moves an image to a new absolute location on screen. If the provided id is invalid, this method does nothing.- Parameters:
id
- the image id returned by createImagex
- new absolute x positiony
- new absolute y position- Returns:
- true if the image was moved, false otherwise
- Since:
- 1.0.0
-
moveImage
boolean moveImage(int id, int x, int y, int durationMs) Moves an image to a new absolute location on screen. If the provided id is invalid, this method does nothing.- Parameters:
id
- the image id returned by createImagex
- new absolute x positiony
- new absolute y positiondurationMs
- duration in milliseconds over which to animate the move (0 = immediate)- Returns:
- true if the image was moved, false otherwise
- Since:
- 1.3.0
-
setImageVisible
boolean setImageVisible(int id, boolean visible) Changes visibility of an image. If the provided id is invalid, this method does nothing.- Parameters:
id
- the image id returned by createImagevisible
- new visibility- Returns:
- true if the image visibility was changed, false otherwise
- Since:
- 1.0.0
-
removeImage
boolean removeImage(int id) Removes a previously created image. If the provided id is invalid, this method does nothing.- Parameters:
id
- the image id returned by createImage- Returns:
- true if the image was removed, false otherwise
- Since:
- 1.0.0
-
createAnimation
Creates an animation out of an array of images. This will count against your 3 image limit. This means if your array length is larger than 3, only the last 3 images will be used. Also, previously created images could be overwritten.
Note that only 1 animation can be allocated. If you create more than this, you will start overwriting previously created animations.- Parameters:
images
- an array of imagesanchor
- where to anchor the animationduration
- the duration, in milliseconds, of the entire animation (must be greater than zero)- Returns:
- an int that can be used to update the animation or -1 if the animation can't be created
- Since:
- 1.0.0
-
createAnimation
int createAnimation(@NonNull LVGLImage[] images, @NonNull Anchor anchor, int offsetX, int offsetY, int duration) Creates an animation out of an array of images. This will count against your 3 image limit. This means if your array length is larger than 3, only the last 3 images will be used. Also, previously created images could be overwritten.
Note that only 1 animation can be allocated. If you create more than this, you will start overwriting previously created animations.- Parameters:
images
- an array of imagesanchor
- where to anchor the animationoffsetX
- the horizontal offsetoffsetY
- the vertical offsetduration
- the duration, in milliseconds, of the entire animation (must be greater than zero)- Returns:
- an int that can be used to update the animation or -1 if the animation can't be created
- Since:
- 1.0.0
-
moveAnimation
boolean moveAnimation(int id, int x, int y) Moves an animation to a new absolute location on screen. If the provided id is invalid, this method does nothing.- Parameters:
id
- the animation id returned by createAnimationx
- new absolute x positiony
- new absolute y position- Returns:
- true if the animation was moved, false otherwise
- Since:
- 1.0.0
-
moveAnimation
boolean moveAnimation(int id, int x, int y, int durationMs) Moves an animation to a new absolute location on screen. If the provided id is invalid, this method does nothing.- Parameters:
id
- the animation id returned by createAnimationx
- new absolute x positiony
- new absolute y positiondurationMs
- duration in milliseconds over which to animate the move (0 = immediate)- Returns:
- true if the animation was moved, false otherwise
- Since:
- 1.3.0
-
setAnimationVisible
boolean setAnimationVisible(int id, boolean visible) Changes visibility of an animation. If the provided id is invalid, this method does nothing.- Parameters:
id
- the animation id returned by createAnimationvisible
- new visibility- Returns:
- true if the animation visibility was changed, false otherwise
- Since:
- 1.0.0
-
removeAnimation
boolean removeAnimation(int id) Removes a previously created animation. If the provided id is invalid, this method does nothing.- Parameters:
id
- the animation id returned by createAnimation- Returns:
- true if the animation was removed, false otherwise
- Since:
- 1.0.0
-
createText
Creates an identifiable block of text that can be manipulated. The alignment will be AUTO and the color will be WHITE. The text will initially be visible.
Note that only 7 text blocks can be allocated. If you create more than this, you will start overwriting previously created text blocks.- Parameters:
text
- the initial textanchor
- where to anchor the text- Returns:
- an int that can be used to update the text or -1 if the text can't be created
- Since:
- 1.0.0
-
createText
int createText(@NonNull String text, @NonNull TextAlignment alignment, @NonNull UltraliteColor color, @NonNull Anchor anchor, boolean visible) Creates an identifiable block of text that can be manipulated.
Note that only 7 text blocks can be allocated. If you create more than this, you will start overwriting previously created text blocks.- Parameters:
text
- the initial textalignment
- the text alignmentcolor
- the text coloranchor
- where to Anchor the textvisible
- initial visibility of the text- Returns:
- an int that can be used to update the text or -1 if the text can't be created
- Since:
- 1.0.0
-
createText
int createText(@NonNull String text, @NonNull TextAlignment alignment, @NonNull UltraliteColor color, @NonNull Anchor anchor, int offsetX, int offsetY, int width, int height, @Nullable TextWrapMode wrap, boolean visible) Creates an identifiable block of text that can be manipulated.
Note that only 7 text blocks can be allocated. If you create more than this, you will start overwriting previously created text blocks.- Parameters:
text
- the initial textalignment
- the text alignmentcolor
- the text coloranchor
- where to Anchor the textoffsetX
- the horizontal offsetoffsetY
- the vertical offsetwidth
- the width of the text block, use -1 for autoheight
- the height of the text block, use -1 for autowrap
- the desired wrapping mode, null specifies no wrap modevisible
- initial visibility of the text- Returns:
- an int that can be used to update the text or -1 if the text can't be created
- Since:
- 1.0.0
-
updateText
Replaces the text displayed with a particular id. Location and visibility are not changed. If the provided id is invalid, this method does nothing.- Parameters:
id
- the text id returned by createTexttext
- the new text- Returns:
- true if the text was updated, false otherwise
- Since:
- 1.0.0
-
moveText
Moves text to a new location. If the provided id is invalid, this method does nothing.- Parameters:
id
- the text id returned by createTextanchor
- new anchoroffsetX
- new x offsetoffsetY
- new y offset- Returns:
- true if the text was moved, false otherwise
- Since:
- 1.0.0
-
moveText
boolean moveText(int id, int offsetX, int offsetY, int durationMs) Moves text to a new location. If the provided id is invalid, this method does nothing.- Parameters:
id
- the text id returned by createTextoffsetX
- new x offsetoffsetY
- new y offsetdurationMs
- duration in milliseconds over which to animate the move (0 = immediate)- Returns:
- true if the text was moved, false otherwise
- Since:
- 1.3.0
-
setTextVisible
boolean setTextVisible(int id, boolean visible) Changes visibility of text. If the provided id is invalid, this method does nothing.- Parameters:
id
- the text id returned by createTextvisible
- new visibility- Returns:
- true if the text's visibility was changed, false otherwise
- Since:
- 1.0.0
-
removeText
boolean removeText(int id) Removes a previously created text block. If the provided id is invalid, this method does nothing.- Parameters:
id
- the text id returned by createText- Returns:
- true if the text was removed, false otherwise
- Since:
- 1.0.0
-
commit
void commit()Commits canvas changes made since the last commit.- Since:
- 1.0.0
-
commit
Commits canvas changes made since the last commit.- Parameters:
callback
- callback to be notified when the commit is complete- Since:
- 1.1.0
-
clear
void clear()Clears the entire canvas. This includes the background layer, all images and all text blocks.- Since:
- 1.0.0
-