canvas (android)

Contains functions for working with graphics on Android

Constants

VertexMode : map = {TRIANGLES=0, TRIANGLE_STRIP=1, TRIANGLE_FAN=2}

Action : map =

11 elements
{
  DOWN=0,
  UP=1,
  MOVE=2,
  MULTIPLE=2,
  CANCEL=3,
  OUTSIDE=4,
  POINTER_DOWN=5,
  POINTER_UP=6,
  POINTER_INDEX_SHIFT=8,
  MASK=255,
  POINTER_INDEX_MASK=65280
}

BitmapCompressFormat : map = {JPEG=0, PNG=1, WEBP=2}

EdgeType : map = {BW=0, AA=1}

Cap : map = {BUTT=0, ROUND=1, SQUARE=2}

Style : map = {FILL=0, STROKE=1, FILL_AND_STROKE=2}

BitmapConfig : map = {ALPHA_8=0, RGB_565=1, ARGB_4444=2, ARGB_8888=3}

Join : map = {MITER=0, ROUND=1, BEVEL=2}

Align : map = {LEFT=0, CENTER=1, RIGHT=2}

DisplayMetrics : map =

7 elements
{
  density=,
  densityDpi=,
  scaledDensity=,
  widthPixels=,
  heightPixels=,
  xdpi=,
  ydpi=
}

Functions

createBitmap(...)createBitmap(bitmap) - creates a copy of the bitmap.

createBitmap(bytes) - creates bitmap from byte array.

createBitmap(w, h) - creates new bitmap with the given size.

createBitmap(w, h, config) - creates new bitmap with the given size and config.

createBitmap(bytes, offset, length) - creates bitmap from byte array starting from offset.

createBitmap(pixels, w, h, config) - creates new bitmap from pixels array.

createBitmap(bitmap, x, y, w, h) - creates new bitmap from the part of the bitmap.

createBitmap(pixels, offset, stride, w, h, config) - creates new bitmap from pixels array starting from offset.

Returns BitmapValue.

use http, canvas

g = showcanvas()
url = "http://lorempixel.com/640/480/nature"
imageBytes = download(url)
bitmap = createBitmap(imageBytes)
g.drawBitmap(bitmap, 0, 0)
repaint()

createScaledBitmap(srcBitmap, width, height, filter) — scales bitmap to size and returns new BitmapValue

getScreenBitmap() — returns current screen as bitmap

hidecanvas() — closes canvas screen and releases resources

newPath(path = null) 1.5.1 — creates new PathValue

newLinearGradient(x0, y0, x1, y1, colors|color1, positions|color2, tileMode) 1.5.1 — creates new shader

newRadialGradient(cx, cy, radius, colors|color1, positions|color2, tileMode) 1.5.1 — creates new shader

newSweepGradient(cx, cy, colors|color1, positions|color2) 1.5.1 — creates new shader

newBitmapShader(bitmap, modeX, modeY) 1.5.1 — creates new bitmap shader

newComposeShader(shader1, shader2, mode = SRC_OVER) 1.5.1 — creates new composition shader

repaint()

setOnKeyDownEvent()

setOnKeyUpEvent()

setOnLongPressEvent()

setOnTouchEvent()

setGestureDetectorListener(listener) 1.5.1 — sets gesture detector listener

showcanvas() — shows canvas screen and returns GraphicsValue

use canvas
g = showcanvas()

Types

BitmapValue

Functions

compress()

copy()

eraseColor()

extractAlpha()

getAllocationByteCount()

getByteCount()

getDensity()

getGraphics()

getWidth()

getHeight()

getRowBytes()

getPixel()

getPixels()

getScaledWidth()

getScaledHeight()

hasAlpha()

hasMipMap()

isMutable()

isPremultiplied()

isRecycled()

prepareToDraw()

recycle()

setPixel()

setPixels()

GraphicsValue

Functions

ascent()

breakText()

clearShadowLayer()

clipPath(path) 1.5.1

clipRect(x, y, w, h, op = 0)

descent()

drawARGB()

drawArc()

drawBitmap()

drawCircle()

drawColor()

drawLine()

drawOval()

drawPath(path) 1.5.1

drawPoint()

drawRGB()

drawRect()

drawRoundRect()

drawText()

drawTextOnPath(text, path, hOffset, vOffset) 1.5.1

fillCircle()

fillOval()

fillRect()

fillRoundRect()

getAlpha()

getClipBounds()

getColor()

getFillPath(src, dst) 1.5.1

getDensity()

getFlags()

getFontSpacing()

getHeight()

getSaveCount()

getStrokeCap()

getStrokeJoin()

getStrokeMiter()

getStrokeWidth()

getStyle()

getTextAlign()

getTextBounds()

getTextScaleX()

getTextSize()

getTextSkewX()

getTextWidths()

getTypeface()

getWidth()

isAntiAlias()

isDither()

isFakeBoldText()

isFilterBitmap()

isLinearText()

isOpaque()

isStrikeThruText()

isSubpixelText()

isUnderlineText()

measureText()

quickReject()

reset()

restore()

restoreToCount()

rotate()

save()

saveLayer()

saveLayerAlpha()

scale()

setAlpha()

setAntiAlias()

setBitmap()

setColor()

setDensity()

setDither()

setFakeBoldText()

setFilterBitmap()

setFlags()

setLinearText()

setShader(shader) 1.5.1

setShadowLayer(radius, dx, dy, shadowColor)

setStrikeThruText(isEnabled)

setStrokeCap(cap)

setStrokeJoin(join)

setStrokeMiter(miter)

setStrokeWidth()

setStyle()

setSubpixelText()

setTextAlign()

setTextScaleX()

setTextSize()

setTextSkewX()

setTypeface()

setUnderlineText()

skew()

strokeCircle()

strokeOval()

strokeRect()

strokeRoundRect()

translate()