Mini App Document Mini App Document
  • Start
  • Configuration
  • Framework
  • Custom Components
  • Basic ability
  • Configuration
  • Interface
  • FXML syntax
  • FXS syntax
API
Components
IDE
  • Developer
  • Operator
  • Start
  • Configuration
  • Framework
  • Custom Components
  • Basic ability
  • Configuration
  • Interface
  • FXML syntax
  • FXS syntax
API
Components
IDE
  • Developer
  • Operator
  • Start

  • Configuration

  • MiniApp Framework

  • Custom component
  • Basic ability

    • Storage
    • File system
    • Subpackage loading
    • Canvas
      • 1. Use the canvas
        • 1.1 Creates a Canvas drawing context
        • 1.2 Use the Canvas drawing context for drawing description
        • 1.3 Draw
    • Custom tabBar
  • Guide
  • Basic ability
2022-08-05
Directory

Canvas

The Canvas component provides a drawing interface on top of which you can draw arbitrarily. All drawings in Canvas must be done in 'JavaScript'.

<canvas canvas-id="myCanvas" style="border: 1px solid;"/>
const ctx = ft.createCanvasContext('myCanvas')
ctx.setFillStyle('red')
ctx.fillRect(10, 10, 150, 75)
ctx.draw()

# 1. Use the canvas

# 1.1 Creates a Canvas drawing context

First, we need to create a Canvas drawing context, the CanvasContext.
CanvasContext is a built-in object in the Mini App that has some methods for drawing:

const ctx = ft.createCanvasContext('myCanvas')

# 1.2 Use the Canvas drawing context for drawing description

Next, let's describe what we want to draw in the Canvas.
Set the fill color of the drawing context to red:

Draw a rectangle with the fillRect(x, y, width, height) method, filled with the red color you just set:

ctx.fillRect(10, 10, 150, 75)

# 1.3 Draw

Tell the canvas component that you want to draw the description you just described:

Last update: 2022/08/11, 21:21:29
Subpackage loading
Custom tabBar

← Subpackage loading Custom tabBar→

Copyright © 2020-2024 Neuxnet
  • Follow System
  • Light Mode
  • Dark Mode
  • Reading Mode