how to change svg polygon size by update it's points in js
how to change svg polygon size by update it's points in js
matrixTransform
https://stackoverflow.com/questions/40493506/get-updated-polygon-points-after-transformations-svg
function screenPolygon(myPoly){
var sCTM = myPoly.getCTM()
var svgRoot = myPoly.ownerSVGElement
var pointsList = myPoly.points;
var n = pointsList.numberOfItems;
for(var m=0;m<n;m++)
{
var mySVGPoint = svgRoot.createSVGPoint();
mySVGPoint.x = pointsList.getItem(m).x
mySVGPoint.y = pointsList.getItem(m).y
mySVGPointTrans = mySVGPoint.matrixTransform(sCTM)
pointsList.getItem(m).x=mySVGPointTrans.x
pointsList.getItem(m).y=mySVGPointTrans.y
}
//---force removal of transform--
myPoly.setAttribute("transform","")
myPoly.removeAttribute("transform")
}
var sCTM = this.poly.getCTM();
// SVGMatrix
var svgRoot = this.poly.ownerSVGElement;
// svg
var mySVGPoint = svgRoot.createSVGPoint();
// SVGPoint {x: 0, y: 0}
log(`sCTM`, sCTM);
log(`svgRoot`, svgRoot);
log(`mySVGPoint`, mySVGPoint);
matrix transforms
https://stackoverflow.com/questions/38525536/svg-polygon-scale-and-set-points-accordingly
Convert SVG polygon points to path
https://stackoverflow.com/questions/16245712/convert-svg-polygon-points-to-path
var points="270,328 270,376 342,376 342,368 358,368 358,320 314,320 298,336 278,336"
var p = points.split(/\s+/);
var path = "";
for( var i = 0, len = p.length; i < len; i++ ){
path += (i && "L" || "M") + p[i]
}
console.log( path )
=> M270,328L270,376L342,376L342,368L358,368L358,320L314,320L298,336L278,336
C#
https://stackoverflow.com/questions/11263936/changing-a-polygons-points
demo
getMinPoint() {
const {
x,
y,
} = this.getBoxSize();
return {
x,
y,
};
}
getMaxPoint() {
const {
x,
y,
width,
height,
} = this.getBoxSize();
return {
x: x + width,
y: y + height,
};
}
getSize() {
const {
width,
height,
} = this.getBoxSize();
return {
width,
height,
};
}
zoomWidth(w) {
// 除最小点, 其他点 x 增大
var sCTM = this.poly.getCTM();
// SVGMatrix
var svgRoot = this.poly.ownerSVGElement;
// svg
var mySVGPoint = svgRoot.createSVGPoint();
// SVGPoint {x: 0, y: 0}
log(`sCTM`, sCTM);
log(`svgRoot`, svgRoot);
log(`mySVGPoint`, mySVGPoint);
const box = this.getBoxSize();
const min = this.getMinPoint();
const max = this.getMaxPoint();
log(`box size`, box, min, max);
log(`poly points`, this.poly.points);
// log(`poly points`, this.poly.getAttribute(`points`));
// 放大 width
const points = [];
[...this.poly.points].forEach(point => {
const {
x,
y,
} = point;
const px = (x === min.x) ? x : x + w;
if(x === min.x) {
log(`min point x`, point)
}
const py = y;
points.push(px, py);
});
this.poly.setAttribute(`points`, points.join(` `));
}
d3
https://stackoverflow.com/questions/49261369/update-polygon-when-points-change-in-d3
zrender
mapbox
canvas
how to change svg polygon size by update it's points in js的更多相关文章
- A workaround to change shared memory size for Docker containers in AWS ECS
Issue Because of not supporting to specify the following docker run parameter, containers in ECS can ...
- svg学习(七)polygon
<polygon> 标签用来创建含有不少于三个边的图形. <?xml version="1.0" standalone="no"?> & ...
- 1. Change the emulator screen size
1. "Windows" ==> "Android Virtual Device Manager" ==> Select one emulator ...
- SVG & convert polygon/polyline to path
SVG & convert polygon/polyline to path SVG Polygon/Polyline to Path Converter https://codepen.io ...
- 【MySQL 5.7 Reference Manual】15.4.2 Change Buffer(变更缓冲)
15.4.2 Change Buffer(变更缓冲) The change buffer is a special data structure that caches changes to se ...
- SVG.js Marker标记和自定义标签
一.SVG.Marker 添加标记 SVG.Marker 标记可以被添加到一个线,折线的各点,多边形和路径.有三种类型的标记:开始,中间和结束.如果开始表示第一个点,则结束中间的最后一点和中间点. v ...
- SVG.js 图案使用和use引用
一.SVG.Pattern 图案设置 var draw = SVG('svg1').size(300, 300); //SVG.Pattern 图案设置 var pattern = draw.patt ...
- SVG.js 颜色渐变使用
一.SVG.Gradient 1.线性渐变.径向渐变,设置渐变的起始点,设置径向渐变的外层半径 var draw = SVG('svg1').size(300, 300); //SVG.Gradien ...
- SVG.js 基础图形绘制整理(二)
一.折线 var draw = SVG('svg1').size(300, 300); //画折线 //使用字符串点 // var polyline=draw.polyline('0,0 100,50 ...
随机推荐
- C++ Primer Plus读书笔记(九)内存模型和名称空间
1.作用域和链接 int num3; static int num4; int main() { } void func1() { static int num1; int num2; } 上边的代码 ...
- 反射型XSS
反射型XSS漏洞详解 http://www.ttlsa.com/safe/xss-description/ 一.原理 如果一个应用程序使用动态页面向用户显示错误消息,就会造成一种常见的XSS漏洞.通常 ...
- 404 GET /nbextensions/jupyter-js-widgets/extension.js
数据科学交流群,群号:189158789,欢迎各位对数据科学感兴趣的小伙伴的加入! 解决办法: 首先要确定你安装和配置nbextensions时有没有加--user,如果当时没加这里就不用加,否则不一 ...
- eclipse中Tomcat修改项目名称
1.打开你的项目目录,找到一个.project文件,打开后修改<name> test</name>中的值,将test修改成你要修改的名字: 2.在项目目录下,打开.settin ...
- UML——部署图
一.What 概念: 1.部署图:用来展示所开发系统的硬件配置和组成.软件布局的一个网络拓扑结构图. 2.组成元素:节点.连接.(补充:处理器.设备.节点属性和操作) 2.1节点(Node):是一个物 ...
- 子网划分、变长子网掩码和TCP/IP排错__散知识点
1.IP零子网(ip subnet-zero):这个命令可以允许你在自己的网络设计中使用第一个和最后一个子网.例如,C类掩码192通常只可以提供子网64和128,但在使用了ip subnet-zero ...
- C++ 标准模板库(STL):vector
目录 1. vector 1.1 vector的定义 1.2 vector容器内元素的访问 1.3 vector 常用函数实例解析 1.4 vector的常见用途 1. vector 变长数组,长度根 ...
- MySQL复合索引探究
复合索引(又称为联合索引),是在多个列上创建的索引.创建复合索引最重要的是列顺序的选择,这关系到索引能否使用上,或者影响多少个谓词条件能使用上索引.复合索引的使用遵循最左匹配原则,只有索引左边的列匹配 ...
- 【LAMP】搭建Web网站过程中的记录【Ubuntu18.04+Apache2.4+PHP7.2+MySQL5.7】
全文使用的环境如题,主机使用的是腾讯云主机. 内容应该会是linux和apache这些所有部分都有一点,因为是遇见一个问题就记录一个. 配置LAMP环境 这部分可以参考这篇文章:https://www ...
- 让visual studio总是以管理员身份启动
环境 win10 visual studio 2019 步骤 找到visual studio的安装目录 怎么找? 右击win10开始菜单中visual studio的快捷方式, 依次选择 更多-> ...