Home > Article > Technology peripherals > WeChat mini program launches snapshot to generate poster components, eliminating the need to manually draw the canvas
News from this site on September 14th. Anyone who has made a WeChat applet to generate posters knows that this function is generally implemented through canvas drawing and server-side drawing, but both require manual scripting. It’s also not very convenient to make.
In order to meet the needs of mini programs to efficiently generate posters, WeChat announced the launch of the snapshot component in the Skyline rendering engine, quickly solving complex layout, long posters and other drawing problems.
According to reports, comparing the existing canvas drawing and server-side drawing methods, the snapshot component has the following advantages:
Easily cope with complex layouts, such as rounded corners and percentages , custom fonts and other styles can be easily adjusted
No width and height restrictions, support the output of ultra-long posters
The calling method is simple and direct Use wxml to implement
In addition, the complete process of using the snapshot component to complete the mini program to generate a poster and save it locally is also very simple:
Use wxml to draw the content of the poster
Use the snapshot component to wrap the wxml of the poster
Call takeSnapshot to obtain the image data
Call fs.writeFileSync Write poster data to local file
Call wx.saveImageToPhotosAlbum Save poster to local file
That is It is said that users can use wxml to write poster layout like writing mini program UI, and then directly fill in dynamic data. This greatly improves the usability. Interested friends of this website can try it in the project.
Advertising Statement: This article contains external jump links (including but not limited to hyperlinks, QR codes, passwords, etc.), which are intended to provide more information, save screening time, and are for reference only. Please note that all articles on this site contain this statement
The above is the detailed content of WeChat mini program launches snapshot to generate poster components, eliminating the need to manually draw the canvas. For more information, please follow other related articles on the PHP Chinese website!