Home > Technology peripherals > It Industry > WeChat mini program launches snapshot to generate poster components, eliminating the need to manually draw the canvas

WeChat mini program launches snapshot to generate poster components, eliminating the need to manually draw the canvas

PHPz
Release: 2023-09-18 18:05:05
forward
1283 people have browsed it

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

微信小程序推出 snapshot 生成海报组件,不用再手动绘制画布了
▲ Snapshot component generates posters and saves them locally, picture source "WeChat Developer" public account

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!

Related labels:
source:ithome.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template