当前位置:网站首页>Js--- SVG to png
Js--- SVG to png
2022-06-23 00:45:00 【Ziwei front end】
/**
* @desc SVG turn PNG
* @param {Object} o Transfer in parameters
* @param {Element} o.svg svg node
* @param {Number} o.scale The zoom
* @param {String} o.toDataType Output data type toDataURL||toBlob
* @param {Function} o.success Successful callback
* @param {Function} o.error Failed callback
*/
function svg2png(o) {
let svg = o.svg;
let scale = o.scale || 1;
let toDataType = o.toDataType || "toDataURL";
let success = o.success || function () { };
let error = o.error || function () { };
let svgData = new XMLSerializer().serializeToString(svg);
let canvas = document.createElement("canvas");
let svgSize = svg.getBoundingClientRect();
canvas.width = svgSize.width * scale;
canvas.height = svgSize.height * scale;
// canvas.style.width = svgSize.width;
// canvas.style.height = svgSize.height;
let ctx = canvas.getContext("2d");
ctx.scale(scale边栏推荐
- Ansible learning summary (8) -- Summary of ansible control right raising related knowledge
- 使用GetX构建更优雅的Flutter页面结构
- Typecho仿盧松松博客主題模板/科技資訊博客主題模板
- Because I said: volatile is a lightweight synchronized, the interviewer asked me to go back and wait for the notice!
- BGP联邦综合实验
- "Hearing" marketing value highlights, Himalaya ushers in a new situation
- MD5加密+盐值工具类
- Kunlundb query optimization (II) project and filter push down
- Quelle est la structure et la façon dont les données sont stockées dans la base de données?
- Why do we not use foreign keys now (2)?
猜你喜欢

#yyds干货盘点# 解决剑指offer:把二叉树打印成多行

Analysis on the wallet system architecture of Baidu trading platform

ROS2暑期学校 ROS2 Summer School 2022-转-

最安全的现货白银的心理分析

Ros2 summer school 2022 transfer-

使用GetX构建更优雅的Flutter页面结构

Quelle est la structure et la façon dont les données sont stockées dans la base de données?

Psychological analysis of the safest spot Silver

TiDB VS MySQL
Because I said: volatile is a lightweight synchronized, the interviewer asked me to go back and wait for the notice!
随机推荐
Oracle ASM uses the CP command in asmcmd to perform remote replication
【滑动窗口】leetcode992. Subarrays with K Different Integers
美团基于 Flink 的实时数仓平台建设新进展
TiDB VS MySQL
华为云招募工业智能领域合作伙伴,强力扶持+商业变现
How to solve the problem that easycvr does not display the interface when RTMP streaming is used?
Why do we seldom use foreign keys?
LINQ 查询
中国国际期货有限公司怎么样,是正规的期货公司吗?网上开户安全吗?
MD5 encryption + salt value tool class
How to calculate the position of gold ETF
3DMAX modeling notes (I): introducing 3DMAX and creating the first model Hello World
SAP ui5 application development tutorial 103 - how to consume the trial version of the third-party library in SAP ui5 applications
Ros2 summer school 2022 transfer-
Express, route, request object, response object, middleware, EJS template
数据库每日一题---第20天:按日期分组销售产品
一文简述:钓鱼攻击知多少
[initial launch] there are too many requests at once, and the database is in danger
數據庫中數據的儲存結構和方式是什麼?
Software construction course ADT and OOP understanding