🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

@hc-master/white-ink

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hc-master/white-ink

A processor that generates printed white ink for png and svg files

latest
npmnpm
Version
0.1.6
Version published
Maintainers
1
Created
Source

定制酒包装白墨处理

根据svg和png图片,生成对应白墨颜色的数据;

使用

Installation

npm i @hc-master/white-ink

Quick start

import { whiteInkForSvg, whiteInkForPng } from '@hc-master/white-ink';
// 模块默认导出两个方法,分别处理svg与png的白墨生成
function App() {
  const handleInk = async function(type:'svg'|'png') {
    switch (type) {
      case 'svg':
        // whiteInkForSvg生成的数据为svg内容的字符串
        const svgStr = await whiteInkForSvg(demoSvg)
        break;
      case 'png':
        // whiteInkForPng生成的数据为图片base64的字符串
        const base64 = await whiteInkForPng(demPng, {
          // 输出格式(默认png)
          suffix: 'png',
          // 填充像素值时的执行回调,须返回一个rgba对象值
          // @param v - 当前像素的rgb对象值
          change(v) {
            return { r:0,g:0,b:0,a:1 }
          }
        })
        break;
    }
  }
  return (
    <>
      <div className="card">
        <button onClick={() => handleInk('svg')}>生产svg白墨</button>
        <button onClick={() => handleInk('png')}>生产png白墨</button>
      </div>
    </>
  )
}

Keywords

SVG

FAQs

Package last updated on 06 Jun 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts