


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
- ##Save the picture
- Multi-picture drawing
- ...
- Small amount of code
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:
- Normal drawing and drawing a single sharing picture.
- Multiple drawings, continuous drawing of shared drawings
Use
git clone https://github.com/kuckboy1994/mp_canvas_drawer
to the local
- put the
in
components
canvasdrawerCopy to your own project.
- Register the component using the page
{ "usingComponents": { "canvasdrawer": "/components/canvasdrawer/canvasdrawer" } }
- Add the following code to the page **.wxml file
<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 painting in the current chestnut is briefly displayed. For detailed configuration, please see
The first layer of the data object requires three parameters:
width
, 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!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Zend Studio 13.0.1
Powerful PHP integrated development environment

SublimeText3 Chinese version
Chinese version, very easy to use

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

SublimeText3 Mac version
God-level code editing software (SublimeText3)