In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "how to draw in the middle". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to draw in the middle".
Draw a picture on Canvas
All drawings in must be done in JavaScript:
WXML: (we will use this WXML as a template in the following example if there is no special declaration, so we will not repeat it.)
JS: (we will put JS in onLoad in the next example)
Const ctx = wx.createCanvasContext ('myCanvas') ctx.setFillStyle (' red') ctx.fillRect (10,10,150,75) ctx.draw () first step: create a Canvas drawing context
First, we need to create a Canvas drawing context CanvasContext.
CanvasContext is an object built into Mini Program, and there are some drawing methods:
Const ctx = wx.createCanvasContext ('myCanvas') step 2: describe the drawing using the Canvas drawing context
Next, let's describe what to draw in Canvas.
Set the fill color of the drawing context to red:
Ctx.setFillStyle ('red')
Use the fillRect (x, y, width, height) method to draw a rectangle and fill it with the red you just set:
Ctx.fillRect (10,10,150,75) step 3: draw
Tell the component that you want to draw the description you just gave:
Ctx.draw () Thank you for your reading, the above is the content of "how to draw in". After the study of this article, I believe you have a deeper understanding of the problem of how to draw in, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.