AI2 Component  (Version nb184)
com.google.appinventor.components.runtime.Canvas Class Reference
Inheritance diagram for com.google.appinventor.components.runtime.Canvas:
com.google.appinventor.components.runtime.AndroidViewComponent com.google.appinventor.components.runtime.ComponentContainer com.google.appinventor.components.runtime.VisibleComponent com.google.appinventor.components.runtime.Component

Classes

interface  ExtensionGestureDetector
 
class  FlingGestureListener
 
class  MotionEventParser
 

Public Member Functions

 Canvas (ComponentContainer container)
 
void Initialize ()
 
View getView ()
 
Activity getContext ()
 
void registerCustomGestureDetector (ExtensionGestureDetector detector)
 
void removeCustomGestureDetector (Object detector)
 
boolean ready ()
 
Activity $context ()
 
Form $form ()
 
void $add (AndroidViewComponent component)
 
void setChildWidth (AndroidViewComponent component, int width)
 
void setChildHeight (AndroidViewComponent component, int height)
 
void Width (int width)
 
void Height (int height)
 
int BackgroundColor ()
 
void BackgroundColor (int argb)
 
String BackgroundImage ()
 
void BackgroundImage (String path)
 
void BackgroundImageinBase64 (String imageUrl)
 
int PaintColor ()
 
void PaintColor (int argb)
 
float FontSize ()
 
void FontSize (float size)
 
float LineWidth ()
 
void LineWidth (float width)
 
int TextAlignment ()
 
void TextAlignment (int alignment)
 
boolean ExtendMovesOutsideCanvas ()
 
void ExtendMovesOutsideCanvas (boolean extend)
 
void Touched (float x, float y, boolean touchedAnySprite)
 
void TouchDown (float x, float y)
 
void TouchUp (float x, float y)
 
void Flung (float x, float y, float speed, float heading, float xvel, float yvel, boolean flungSprite)
 
void Dragged (float startX, float startY, float prevX, float prevY, float currentX, float currentY, boolean draggedAnySprite)
 
void Clear ()
 
void DrawPoint (int x, int y)
 
void DrawCircle (int centerX, int centerY, float radius, boolean fill)
 
void DrawLine (int x1, int y1, int x2, int y2)
 
void DrawShape (YailList pointList, boolean fill)
 
void DrawArc (int left, int top, int right, int bottom, float startAngle, float sweepAngle, boolean useCenter, boolean fill)
 
void DrawText (String text, int x, int y)
 
void DrawTextAtAngle (String text, int x, int y, float angle)
 
int GetBackgroundPixelColor (int x, int y)
 
void SetBackgroundPixelColor (int x, int y, @IsColor int color)
 
int GetPixelColor (int x, int y)
 
String Save ()
 
String SaveAs (String fileName)
 
- Public Member Functions inherited from com.google.appinventor.components.runtime.AndroidViewComponent
boolean Visible ()
 
void Visible (boolean visibility)
 
int Width ()
 
void WidthPercent (int pCent)
 
void setLastWidth (int width)
 
int getSetWidth ()
 
void setLastHeight (int height)
 
int getSetHeight ()
 
void CopyWidth (AndroidViewComponent sourceComponent)
 
int Height ()
 
void HeightPercent (int pCent)
 
void CopyHeight (AndroidViewComponent sourceComponent)
 
int Column ()
 
void Column (int column)
 
int Row ()
 
void Row (int row)
 
HandlesEventDispatching getDispatchDelegate ()
 
- Public Member Functions inherited from com.google.appinventor.components.runtime.ComponentContainer
int Width ()
 
int Height ()
 

Protected Member Functions

void findSpriteCollisions (Sprite movedSprite)
 
- Protected Member Functions inherited from com.google.appinventor.components.runtime.AndroidViewComponent
 AndroidViewComponent (ComponentContainer container)
 
- Protected Member Functions inherited from com.google.appinventor.components.runtime.VisibleComponent
 VisibleComponent ()
 

Additional Inherited Members

- Static Public Attributes inherited from com.google.appinventor.components.runtime.Component
static final String ASSET_DIRECTORY = "component"
 
static final int ALIGNMENT_NORMAL = 0
 
static final int ALIGNMENT_CENTER = 1
 
static final int ALIGNMENT_OPPOSITE = 2
 
static final int ACCELEROMETER_SENSITIVITY_WEAK = 1
 
static final int ACCELEROMETER_SENSITIVITY_MODERATE = 2
 
static final int ACCELEROMETER_SENSITIVITY_STRONG = 3
 
static final int BUTTON_SHAPE_DEFAULT = 0
 
static final int BUTTON_SHAPE_ROUNDED = 1
 
static final int BUTTON_SHAPE_RECT = 2
 
static final int BUTTON_SHAPE_OVAL = 3
 
static final int COLOR_NONE = 0x00FFFFFF
 
static final int COLOR_BLACK = 0xFF000000
 
static final int COLOR_BLUE = 0xFF0000FF
 
static final int COLOR_CYAN = 0xFF00FFFF
 
static final int COLOR_DKGRAY = 0xFF444444
 
static final int COLOR_GRAY = 0xFF888888
 
static final int COLOR_GREEN = 0xFF00FF00
 
static final int COLOR_LTGRAY = 0xFFCCCCCC
 
static final int COLOR_MAGENTA = 0xFFFF00FF
 
static final int COLOR_ORANGE = 0xFFFFC800
 
static final int COLOR_PINK = 0xFFFFAFAF
 
static final int COLOR_RED = 0xFFFF0000
 
static final int COLOR_WHITE = 0xFFFFFFFF
 
static final int COLOR_YELLOW = 0xFFFFFF00
 
static final int COLOR_DEFAULT = 0x00000000
 
static final String DEFAULT_VALUE_COLOR_NONE = "&H00FFFFFF"
 
static final String DEFAULT_VALUE_COLOR_BLACK = "&HFF000000"
 
static final String DEFAULT_VALUE_COLOR_BLUE = "&HFF0000FF"
 
static final String DEFAULT_VALUE_COLOR_CYAN = "&HFF00FFFF"
 
static final String DEFAULT_VALUE_COLOR_DKGRAY = "&HFF444444"
 
static final String DEFAULT_VALUE_COLOR_GRAY = "&HFF888888"
 
static final String DEFAULT_VALUE_COLOR_GREEN = "&HFF00FF00"
 
static final String DEFAULT_VALUE_COLOR_LTGRAY = "&HFFCCCCCC"
 
static final String DEFAULT_VALUE_COLOR_MAGENTA = "&HFFFF00FF"
 
static final String DEFAULT_VALUE_COLOR_ORANGE = "&HFFFFC800"
 
static final String DEFAULT_VALUE_COLOR_PINK = "&HFFFFAFAF"
 
static final String DEFAULT_VALUE_COLOR_RED = "&HFFFF0000"
 
static final String DEFAULT_VALUE_COLOR_WHITE = "&HFFFFFFFF"
 
static final String DEFAULT_VALUE_COLOR_YELLOW = "&HFFFFFF00"
 
static final String DEFAULT_VALUE_COLOR_DEFAULT = "&H00000000"
 
static final float FONT_DEFAULT_SIZE = 14
 
static final int LAYOUT_ORIENTATION_HORIZONTAL = ComponentConstants.LAYOUT_ORIENTATION_HORIZONTAL
 
static final int LAYOUT_ORIENTATION_VERTICAL = ComponentConstants.LAYOUT_ORIENTATION_VERTICAL
 
static final int SCALING_SCALE_PROPORTIONALLY = 0
 
static final int SCALING_SCALE_TO_FIT = 1
 
static final int TYPEFACE_DEFAULT = 0
 
static final int TYPEFACE_SANSSERIF = 1
 
static final int TYPEFACE_SERIF = 2
 
static final int TYPEFACE_MONOSPACE = 3
 
static final int LENGTH_PREFERRED = -1
 
static final int LENGTH_FILL_PARENT = -2
 
static final int LENGTH_UNKNOWN = -3
 
static final int LENGTH_PERCENT_TAG = -1000
 
static final int TOAST_LENGTH_SHORT = 0
 
static final int TOAST_LENGTH_LONG = 1
 
static final int DIRECTION_NORTH = 1
 
static final int DIRECTION_NORTHEAST = 2
 
static final int DIRECTION_EAST = 3
 
static final int DIRECTION_SOUTHEAST = 4
 
static final int DIRECTION_SOUTH = -1
 
static final int DIRECTION_SOUTHWEST = -2
 
static final int DIRECTION_WEST = -3
 
static final int DIRECTION_NORTHWEST = -4
 
static final int DIRECTION_NONE = 0
 
static final int DIRECTION_MIN = -4
 
static final int DIRECTION_MAX = 4
 
static float SLIDER_MIN_VALUE = 10
 
static float SLIDER_MAX_VALUE = 50
 
static float SLIDER_THUMB_VALUE = (SLIDER_MIN_VALUE + SLIDER_MAX_VALUE) / 2.0f
 
static final String DEFAULT_VALUE_TEXT_TO_SPEECH_COUNTRY = ""
 
static final String DEFAULT_VALUE_TEXT_TO_SPEECH_LANGUAGE = ""
 
- Protected Attributes inherited from com.google.appinventor.components.runtime.AndroidViewComponent
final ComponentContainer container
 

Detailed Description

A two-dimensional touch-sensitive rectangular panel on which drawing can be done and sprites can be moved.

The BackgroundColor(), PaintColor(), BackgroundImage(), Width(), and Height() of the Canvas can be set in either the Designer or in the Blocks Editor. The Width and Height are measured in pixels and must be positive.

Any location on the Canvas can be specified as a pair of (X, Y) values, where

  • X is the number of pixels away from the left edge of the Canvas
  • Y is the number of pixels away from the top edge of the Canvas

There are events to tell when and where a Canvas has been touched or a Sprite (ImageSprite or Ball) has been dragged. There are also methods for drawing points, lines, circles, shapes, arcs, and text.

@internaldoc

Conceptually, a sprite consists of the following layers, from back to front (with items in front being drawn on top):

To the user, the first three layers are all the background, in terms of the behavior of SetBackgroundPixelColor(int,int,int) and GetBackgroundPixelColor(int,int). For historical reasons, changing the background color or image clears the drawing layer.

Definition at line 132 of file Canvas.java.

Constructor & Destructor Documentation

◆ Canvas()

com.google.appinventor.components.runtime.Canvas.Canvas ( ComponentContainer  container)

Definition at line 750 of file Canvas.java.

Member Function Documentation

◆ $add()

void com.google.appinventor.components.runtime.Canvas.$add ( AndroidViewComponent  component)

Adds a component to a container.

After this method is finished executing, the given component's view must have LayoutParams, even if the component cannot be added to the container until later.

Parameters
componentcomponent associated with view

Implements com.google.appinventor.components.runtime.ComponentContainer.

Definition at line 882 of file Canvas.java.

◆ $context()

Activity com.google.appinventor.components.runtime.Canvas.$context ( )

Returns the activity context (which can be retrieved from the root container - aka the form).

Returns
activity context

Implements com.google.appinventor.components.runtime.ComponentContainer.

Definition at line 872 of file Canvas.java.

◆ $form()

Form com.google.appinventor.components.runtime.Canvas.$form ( )

Returns the form that ultimately contains this container.

Returns
form

Implements com.google.appinventor.components.runtime.ComponentContainer.

Definition at line 877 of file Canvas.java.

◆ BackgroundColor() [1/2]

int com.google.appinventor.components.runtime.Canvas.BackgroundColor ( )

Returns the button's background color as an alpha-red-green-blue integer, i.e.,

0xAARRGGBB

. An alpha of

00

indicates fully transparent and

FF

means opaque.

Returns
background color in the format 0xAARRGGBB, which includes alpha, red, green, and blue components

Definition at line 1021 of file Canvas.java.

◆ BackgroundColor() [2/2]

void com.google.appinventor.components.runtime.Canvas.BackgroundColor ( int  argb)

Specifies the Canvas's background color as an alpha-red-green-blue integer, i.e.,

0xAARRGGBB

. An alpha of

00

indicates fully transparent and

FF

means opaque. The background color only shows if there is no background image.

Parameters
argbbackground color in the format 0xAARRGGBB, which includes alpha, red, green, and blue components

Definition at line 1037 of file Canvas.java.

◆ BackgroundImage() [1/2]

String com.google.appinventor.components.runtime.Canvas.BackgroundImage ( )

Returns the path of the canvas background image.

Returns
the path of the canvas background image

Definition at line 1049 of file Canvas.java.

◆ BackgroundImage() [2/2]

void com.google.appinventor.components.runtime.Canvas.BackgroundImage ( String  path)

Specifies the name of a file containing the background image for the Canvas.

@internaldoc

See MediaUtil#determineMediaSource for information about what a path can be.

Parameters
paththe path of the canvas background image

Definition at line 1065 of file Canvas.java.

◆ BackgroundImageinBase64()

void com.google.appinventor.components.runtime.Canvas.BackgroundImageinBase64 ( String  imageUrl)

Specifies the backgound image in Base64 format imageUrl will be in format of: iVBORw0KG...s//f+4z/6Z @suppressdoc

Parameters
imageUrlthe base64 format for an image

Definition at line 1080 of file Canvas.java.

◆ Clear()

void com.google.appinventor.components.runtime.Canvas.Clear ( )

Clears the canvas, without removing the background image, if one was provided.

Definition at line 1344 of file Canvas.java.

◆ Dragged()

void com.google.appinventor.components.runtime.Canvas.Dragged ( float  startX,
float  startY,
float  prevX,
float  prevY,
float  currentX,
float  currentY,
boolean  draggedAnySprite 
)

When the user does a drag from one point (prevX, prevY) to another (x, y). The pair (startX, startY) indicates where the user first touched the screen, and "draggedAnySprite" indicates whether a sprite is being dragged.

Parameters
startXthe starting x-coordinate
startYthe starting y-coordinate
prevXthe previous x-coordinate (possibly equal to startX)
prevYthe previous y-coordinate (possibly equal to startY)
currentXthe current x-coordinate
currentYthe current y-coordinate
draggedAnySprite

Definition at line 1330 of file Canvas.java.

◆ DrawArc()

void com.google.appinventor.components.runtime.Canvas.DrawArc ( int  left,
int  top,
int  right,
int  bottom,
float  startAngle,
float  sweepAngle,
boolean  useCenter,
boolean  fill 
)

Draw an arc on Canvas, by drawing an arc from a specified oval (specified by left, top, right & bottom). Start angle is 0 when heading to the right, and increase when rotate clockwise. When useCenter is true, a sector will be drawed instead of an arc. When fill is true, a filled arc (or sector) will be drawed instead of just an outline.

Parameters
leftthe left end of the oval
topthe top of the oval
rightthe right end of the oval
bottomthe bottom of the oval
startAnglethe start angle of the arc, rightward as 0, clockwise as positive, in degree
sweepAnglethe sweep angle of the arc, clockwise as positive, in degree
useCenterfill a sector instead of just an arc (when true)
filltrue for filled arc (or sector); false for outline only

Definition at line 1495 of file Canvas.java.

◆ DrawCircle()

void com.google.appinventor.components.runtime.Canvas.DrawCircle ( int  centerX,
int  centerY,
float  radius,
boolean  fill 
)

Draws a circle (filled in) with the given radius centered at the given coordinates on the Canvas.

Parameters
centerXx-coordinate of the center of the circle
centerYy-coordinate of the center of the circle
radiusradius of the circle
filltrue for filled circle; false for circle outline

Definition at line 1372 of file Canvas.java.

◆ DrawLine()

void com.google.appinventor.components.runtime.Canvas.DrawLine ( int  x1,
int  y1,
int  x2,
int  y2 
)

Draws a line between the given coordinates on the canvas.

Parameters
x1x coordinate of first point
y1y coordinate of first point
x2x coordinate of second point
y2y coordinate of second point

Definition at line 1391 of file Canvas.java.

◆ DrawPoint()

void com.google.appinventor.components.runtime.Canvas.DrawPoint ( int  x,
int  y 
)

Draws a point at the given coordinates on the canvas.

Parameters
xx coordinate
yy coordinate

Definition at line 1355 of file Canvas.java.

◆ DrawShape()

void com.google.appinventor.components.runtime.Canvas.DrawShape ( YailList  pointList,
boolean  fill 
)

Draws a shape on the canvas. pointList should be a list contains sub-lists with two number which represents a coordinate. The first point and last point does not need to be the same. e.g. ((x1 y1) (x2 y2) (x3 y3)) When fill is true, the shape will be filled.

Parameters
pointListA list of points, should contains sub-lists with two number which represents a coordinate. The first point and last point does not need to be the same. e.g. ((x1 y1) (x2 y2) (x3 y3))
filltrue for filled shape; false for shape outline

Definition at line 1415 of file Canvas.java.

◆ DrawText()

void com.google.appinventor.components.runtime.Canvas.DrawText ( String  text,
int  x,
int  y 
)

Draws the specified text relative to the specified coordinates using the values of the FontSize(float) and TextAlignment(int) properties.

Parameters
textthe text to draw
xthe x-coordinate of the origin
ythe y-coordinate of the origin

Definition at line 1518 of file Canvas.java.

◆ DrawTextAtAngle()

void com.google.appinventor.components.runtime.Canvas.DrawTextAtAngle ( String  text,
int  x,
int  y,
float  angle 
)

Draws the specified text starting at the specified coordinates at the specified angle using the values of the FontSize(float) and TextAlignment(int) properties.

Parameters
textthe text to draw
xthe x-coordinate of the origin
ythe y-coordinate of the origin
anglethe angle (in degrees) at which to draw the text

Definition at line 1538 of file Canvas.java.

◆ ExtendMovesOutsideCanvas() [1/2]

boolean com.google.appinventor.components.runtime.Canvas.ExtendMovesOutsideCanvas ( )

Definition at line 1231 of file Canvas.java.

◆ ExtendMovesOutsideCanvas() [2/2]

void com.google.appinventor.components.runtime.Canvas.ExtendMovesOutsideCanvas ( boolean  extend)

@suppressdoc

Parameters
extend

Definition at line 1241 of file Canvas.java.

◆ findSpriteCollisions()

void com.google.appinventor.components.runtime.Canvas.findSpriteCollisions ( Sprite  movedSprite)
protected

Checks if the given sprite now overlaps with or abuts any other sprite or has ceased to do so. If there is a sprite that is newly in collision with it, Sprite#CollidedWith(Sprite) is called for each sprite with the other sprite as an argument. If two sprites that had been in collision are no longer colliding, Sprite#NoLongerCollidingWith(Sprite) is called for each sprite with the other as an argument. Collisions are only recognized between sprites that are both com.google.appinventor.components.runtime.Sprite#Visible() and com.google.appinventor.components.runtime.Sprite#Enabled().

Parameters
movedSpritethe sprite that has just changed position

Definition at line 927 of file Canvas.java.

◆ Flung()

void com.google.appinventor.components.runtime.Canvas.Flung ( float  x,
float  y,
float  speed,
float  heading,
float  xvel,
float  yvel,
boolean  flungSprite 
)

When a fling gesture (quick swipe) is made on the canvas: provides the (x,y) position of the start of the fling, relative to the upper left of the canvas. Also provides the speed (pixels per millisecond) and heading (0-360 degrees) of the fling, as well as the x velocity and y velocity components of the fling's vector. The value "flungSprite" is true if a sprite was located near the the starting point of the fling gesture.

Parameters
xx-coordinate of touched point
yy-coordinate of touched point
speedthe speed of the fling sqrt(xspeed^2 + yspeed^2)
headingthe heading of the fling
xvelthe speed in x-direction of the fling
yvelthe speed in y-direction of the fling
flungSprite

Definition at line 1307 of file Canvas.java.

◆ FontSize() [1/2]

float com.google.appinventor.components.runtime.Canvas.FontSize ( )

Definition at line 1135 of file Canvas.java.

◆ FontSize() [2/2]

void com.google.appinventor.components.runtime.Canvas.FontSize ( float  size)

Specifies the font size of text drawn on the Canvas.

Parameters
size

Definition at line 1147 of file Canvas.java.

◆ GetBackgroundPixelColor()

int com.google.appinventor.components.runtime.Canvas.GetBackgroundPixelColor ( int  x,
int  y 
)

Gets the color of the given pixel, ignoring sprites.

Parameters
xthe x-coordinate
ythe y-coordinate
Returns
the color at that location as an alpha-red-blue-green integer, or Component#COLOR_NONE if that point is not on this Canvas

Definition at line 1556 of file Canvas.java.

◆ getContext()

Activity com.google.appinventor.components.runtime.Canvas.getContext ( )

Definition at line 796 of file Canvas.java.

◆ GetPixelColor()

int com.google.appinventor.components.runtime.Canvas.GetPixelColor ( int  x,
int  y 
)

Gets the color of the given pixel, including sprites.

Parameters
xthe x-coordinate
ythe y-coordinate
Returns
the color at that location as an alpha-red-blue-green integer, or Component#COLOR_NONE if that point is not on this Canvas

Definition at line 1591 of file Canvas.java.

◆ getView()

View com.google.appinventor.components.runtime.Canvas.getView ( )

Returns the View that is displayed in the UI.

Reimplemented from com.google.appinventor.components.runtime.AndroidViewComponent.

Definition at line 792 of file Canvas.java.

◆ Height()

void com.google.appinventor.components.runtime.Canvas.Height ( int  height)

Specifies the type%'s vertical height, measured in pixels.

@internaldoc The height can only be set to >0 or -1 (automatic) or -2 (fill parent) or to a value less then or equal to LENGTH_PERCENT_TAG (which is later converted to pixels.

Parameters
height

Reimplemented from com.google.appinventor.components.runtime.AndroidViewComponent.

Definition at line 997 of file Canvas.java.

◆ Initialize()

void com.google.appinventor.components.runtime.Canvas.Initialize ( )

Definition at line 773 of file Canvas.java.

◆ LineWidth() [1/2]

float com.google.appinventor.components.runtime.Canvas.LineWidth ( )

Returns the currently specified stroke width

Returns
width

Definition at line 1159 of file Canvas.java.

◆ LineWidth() [2/2]

void com.google.appinventor.components.runtime.Canvas.LineWidth ( float  width)

Specifies the width of lines drawn on the Canvas.

Parameters
width

Definition at line 1171 of file Canvas.java.

◆ PaintColor() [1/2]

int com.google.appinventor.components.runtime.Canvas.PaintColor ( )

Returns the currently specified paint color as an alpha-red-green-blue integer, i.e.,

0xAARRGGBB

. An alpha of

00

indicates fully transparent and

FF

means opaque.

Returns
paint color in the format 0xAARRGGBB, which includes alpha, red, green, and blue components

Definition at line 1101 of file Canvas.java.

◆ PaintColor() [2/2]

void com.google.appinventor.components.runtime.Canvas.PaintColor ( int  argb)

Specifies the paint color as an alpha-red-green-blue integer, i.e.,

0xAARRGGBB

. An alpha of

00

indicates fully transparent and

FF

means opaque.

Parameters
argbpaint color in the format 0xAARRGGBB, which includes alpha, red, green, and blue components

Definition at line 1116 of file Canvas.java.

◆ ready()

boolean com.google.appinventor.components.runtime.Canvas.ready ( )

Returns whether the layout associated with this view has been computed. If so, Width() and Height() will be properly initialized.

Returns
true
if it is safe to call Width() and {}, false otherwise

Definition at line 820 of file Canvas.java.

◆ registerCustomGestureDetector()

void com.google.appinventor.components.runtime.Canvas.registerCustomGestureDetector ( ExtensionGestureDetector  detector)

Definition at line 801 of file Canvas.java.

◆ removeCustomGestureDetector()

void com.google.appinventor.components.runtime.Canvas.removeCustomGestureDetector ( Object  detector)

Definition at line 806 of file Canvas.java.

◆ Save()

String com.google.appinventor.components.runtime.Canvas.Save ( )

Saves a picture of this Canvas to the device's external storage. If an error occurs, the Screen's ErrorOccurred event will be called.

Returns
the full path name of the saved file, or the empty string if the save failed

Definition at line 1608 of file Canvas.java.

◆ SaveAs()

String com.google.appinventor.components.runtime.Canvas.SaveAs ( String  fileName)

Saves a picture of this Canvas to the device's external storage in the file named fileName. fileName must end with one of ".jpg", ".jpeg", or ".png" (which determines the file type: JPEG, or PNG).

Returns
the full path name of the saved file, or the empty string if the save failed

Definition at line 1637 of file Canvas.java.

◆ SetBackgroundPixelColor()

void com.google.appinventor.components.runtime.Canvas.SetBackgroundPixelColor ( int  x,
int  y,
@IsColor int  color 
)

Sets the color of the given pixel. This has no effect if the coordinates are out of bounds.

Parameters
xthe x-coordinate
ythe y-coordinate
colorthe color as an alpha-red-blue-green integer

Definition at line 1572 of file Canvas.java.

◆ setChildHeight()

void com.google.appinventor.components.runtime.Canvas.setChildHeight ( AndroidViewComponent  component,
int  height 
)

◆ setChildWidth()

void com.google.appinventor.components.runtime.Canvas.setChildWidth ( AndroidViewComponent  component,
int  width 
)

◆ TextAlignment() [1/2]

int com.google.appinventor.components.runtime.Canvas.TextAlignment ( )

Returns the alignment of the canvas's text: center, normal (starting at the specified point in drawText()), or opposite (ending at the specified point in drawText()).

Returns
one of Component#ALIGNMENT_NORMAL, Component#ALIGNMENT_CENTER or Component#ALIGNMENT_OPPOSITE

Definition at line 1191 of file Canvas.java.

◆ TextAlignment() [2/2]

void com.google.appinventor.components.runtime.Canvas.TextAlignment ( int  alignment)

Specifies the alignment of the canvas's text: center, normal (starting at the specified point in DrawText or DrawTextAtAngle(String, int, int, float)), or opposite (ending at the specified point in DrawText(String, int, int) or DrawTextAtAngle(String, int, int, float)).

Parameters
alignmentone of Component#ALIGNMENT_NORMAL, Component#ALIGNMENT_CENTER or Component#ALIGNMENT_OPPOSITE

Definition at line 1210 of file Canvas.java.

◆ TouchDown()

void com.google.appinventor.components.runtime.Canvas.TouchDown ( float  x,
float  y 
)

When the user begins touching the canvas (places finger on canvas and leaves it there): provides the (x,y) position of the touch, relative to the upper left of the canvas

Parameters
xx-coordinate of the point that was touched
yy-coordinate of the point that was touched

Definition at line 1271 of file Canvas.java.

◆ Touched()

void com.google.appinventor.components.runtime.Canvas.Touched ( float  x,
float  y,
boolean  touchedAnySprite 
)

When the user touches the canvas and then immediately lifts finger: provides the (x,y) position of the touch, relative to the upper left of the canvas. TouchedAnySprite is true if the same touch also touched a sprite, and false otherwise.

Parameters
xx-coordinate of the point that was touched
yy-coordinate of the point that was touched
touchedAnySprite

Definition at line 1258 of file Canvas.java.

◆ TouchUp()

void com.google.appinventor.components.runtime.Canvas.TouchUp ( float  x,
float  y 
)

When the user stops touching the canvas (lifts finger after a TouchDown event): provides the (x,y) position of the touch, relative to the upper left of the canvas

Parameters
xx-coordinate of the point that was touched
yy-coordinate of the point that was touched

Definition at line 1284 of file Canvas.java.

◆ Width()

void com.google.appinventor.components.runtime.Canvas.Width ( int  width)

Specifies the horizontal width of the type%, measured in pixels.

@internaldoc The width can only be set to >0 or -1 (automatic) or -2 (fill parent) or to a value less then or equal to LENGTH_PERCENT_TAG (which is later converted to pixels.

Parameters
width

Reimplemented from com.google.appinventor.components.runtime.AndroidViewComponent.

Definition at line 973 of file Canvas.java.


The documentation for this class was generated from the following file: