Home > Article > WeChat Applet > WeChat Mini Program: A json helps you share pictures in your circle of friends
Written in front
I have been working on a small program recently and found that making pictures to share in Moments is a must for every project. There were a lot of pitfalls and it was tedious to write, and I couldn’t find a similar component, so I wrote one myself.
Demo
The left side is drawn by canvasdrawer
, and the right side is the picture given by UI
Features
Easy to use - just one json to draw pictures
Full-featured——meet 90% of usage scenarios
Draw text (line breaks, ellipses beyond content, underline, underline, bold text)
Draw the picture
Draw the rectangle
Experience
git clone https://github.com/kuckboy1994/mp_canvas_drawerIf you want to use it on your mobile phone, just configure your own appid. Two commonly used modes have been configured for you in the compilation mode:
Use
git clone https://github.com/kuckboy1994/mp_canvas_drawer to the local
in components
canvasdrawer Copy to your own project.
{ "usingComponents": { "canvasdrawer": "/components/canvasdrawer/canvasdrawer" } }
<canvasdrawer painting="{{painting}}" bind:getImage="eventGetImage"/>
painting is the
json that needs to be passed in. The
getImage method is a callback function after the drawing is completed, and returns the completed image address in
event.
detail .
The first layer of the data object requires three parameters:
, height
, views
. All numbers in the configuration are unitless. This means that canvas
draws a proportional diagram. To determine the specific display size, simply place the returned image path in the image
tag. Currently, 3 types of configurations can be drawn:
, text
, rect
. The configured attributes basically use camel case names of css, which are relatively easy to understand.
Attribute | Meaning | Default value |
Optional value | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
url | The drawn image address can be a local image, such as: /images/1.jpeg | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
The distance between the upper left corner and the top of the artboard | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
The distance between the upper left corner and the left side of the artboard | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
0 |
##height |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
0 |
text(text)
|
The above is the detailed content of WeChat Mini Program: A json helps you share pictures in your circle of friends. For more information, please follow other related articles on the PHP Chinese website!