1.0.2 • Published 2 years ago

darwposter v1.0.2

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

darwposter

  • 绘制海报
  • 可以添加背景图,头像(圆形或者方形),文字大小颜色
 interface IBlockList {
  type: 'img' | 'text'; // 绘制内容的类型,图片或者文字
  value: string; // 图片链接或者文字内容
  posX: number; // x轴坐标
  posY: number; // y轴坐标
  width?: number; // 图片宽度
  height?: number; // 图片高度
  radius?: number; // 圆图半径
  font?: number; // 文字大小
  textColor?: string; // 文字颜色
}
- 调用例子
import { buildPoster4Canvas } from 'darwposter-npm'
const blockList = [
  {
    type: 'img', // 绘制类型img图片,text文字
    value: bg, // 图片地址或者文案
    width: 80, // 元素的宽度
    height: 80, // 元素的高度
    posX: 100, // 元素的x坐标
    posY: 820, // 元素的y坐标
    radius: 50, // 图像的圆角
    avatorColor: 'red', // 头像边框颜色
  },
  {
    type: 'text',
    value: '文案',
    font: 24, // 字体大小
    posX: 50,
    textColor: 'red', // 字体颜色
    posY: 950,
  },
]

// width画布宽度
// height画布高度
// blockList 需要绘制海报的元素
const posterImg = await buildPoster4Canvas(width, height, blockList);