search
HomeWeChat AppletMini Program DevelopmentLet's talk about how to use a small program to generate posters (plug-in recommended)

How to use a small program to generate posters? In this article, I will recommend a poster generation plug-in - painter, and see how to use it to generate posters. I hope it will be helpful to you!

Let's talk about how to use a small program to generate posters (plug-in recommended)

Mini program native code generation poster

First step:

Download the package and place the painter package in the components directory

 https://github.com/Kujiale-Mobile/Painter

[Related learning recommendations: 小program development tutorial]

Step 2:

Introduced into the json file of the page

{
  "usingComponents": {
    "painter":"/components/painter/painter"
  }
}

Step 3:

Use the wxml of the page

接收海报的图片容器
<image mode="widthFix" src="{{ posterImg }}" id="goods_qr-code" alt />

<painter wx-if="{{showPainter}}" palette="{{data}}" bind:imgOK="firstImg" />
  
palette        字段作为画图数据的数据源, 图案数据以 json 形式存在
widthPixels    强制指定生成的图片的像素宽度

绘图完成后,可以通过绑定 imgOK 或 imgErr 事件来获得成功后的图片或失败的原因

Step 4:

Use the js of the page

生成海报的方法(){
this.setData({
        template: {
          width: "750rpx",
          height: "1500rpx",
          views: [
            {
              type: &#39;image&#39;,
              url: 图片路路径,
              css: {
                top: &#39;10rpx&#39;,
                left: &#39;10rpx&#39;,
                right: &#39;10rpx&#39;,
                width: &#39;730rpx&#39;,
                height: &#39;1500rpx&#39;
              }
            }
          ]
        }
     })
}

  海报生成完毕自动调用
  
  firstImg(e) {
    console.log(e.detail.path);
    this.setData({
      posterImg: e.detail.path
    })
  },

Plug-in introduction and official website: Painter generates posters

https://codechina.csdn.net/mirrors/Kujiale-Mobile/Painter?utm_source=csdn_github_accelerator

Original address: https://juejin.cn/post/6995356720125968398

Author: Huang Yongchao

For more programming-related knowledge, please visit: Programming Video ! !

The above is the detailed content of Let's talk about how to use a small program to generate posters (plug-in recommended). For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:掘金--黄勇超. If there is any infringement, please contact admin@php.cn delete

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
Will R.E.P.O. Have Crossplay?
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)