svg & stroke & style & class
svg & stroke & style & class
svg selected style
methods
style
class, !important
fill, stroke, stroke-width, fill-opacity: 0.5;
outline, box-shadow
clickSelected(className = `selected-svg`) {
// update select element
const color = this.reverseColor();
this.poly.setAttribute("fill", color);
// this.poly.setAttribute("fill", "#67c23a");
const cssClass = this.poly.getAttribute("class");
// this.poly.setAttribute("class", "selected-svg");
this.poly.setAttribute("class", `${cssClass} ${className}`);
const style = "fill:lime; fill-opacity: 0.5; stroke:purple; stroke-width:10;";
this.poly.setAttribute("style", style);
}
reverseColor() {
const color = this.poly.getAttribute("fill");
return `#` + color.slice(1).split("").reverse().join("");
}
demo polygon
https://www.w3schools.com/graphics/tryit.asp?filename=trysvg_polygon

<!DOCTYPE html>
<html>
<body>
<svg height="210" width="500">
<polygon points="200,10 250,190 160,210" style="fill:lime; stroke:purple; stroke-width:5" />
Sorry, your browser does not support inline SVG.
</svg>
</body>
</html>
style="fill:lime; stroke:purple; stroke-width:5"
style
stroke-width, stroke

<polygon fill="#cccccc" fill-opacity="1" points="249.5 0.5 674.5 0.5 674.5 136.5 249.5 136.5" class="feature selected-class" stroke="#00ff00" style="fill:lime; stroke:purple; stroke-width:5"></polygon>
css class

stroke-width, stroke
.selected-class {
fill: #ccc !important;
stroke-width: 10px !important;
stroke: #0f0 !important;
}
size not change

poly = document.querySelector(`polygon`);
// <polygon fill="#cccccc" fill-opacity="1" points="249.5 0.5 674.5 0.5 674.5 136.5 249.5 136.5" class="feature selected-class" stroke="#00ff00" style="fill:lime; stroke:purple; stroke-width:5"></polygon>
poly.getBBox();
// SVGRect {x: 249.5, y: 0.5, width: 425, height: 136}
poly.getBoundingClientRect();
// DOMRect {x: 174.64999389648438, y: 190.35000610351562, width: 297.5, height: 95.19998168945312, top: 190.35000610351562, …}
poly = document.querySelector(`polygon`);
// <polygon fill="#cccccc" fill-opacity="1" points="249.5 0.5 674.5 0.5 674.5 136.5 249.5 136.5" class="feature selected-class" stroke="#00ff00"></polygon>
poly.getBBox();
// SVGRect {x: 249.5, y: 0.5, width: 425, height: 136}
poly.getBoundingClientRect();
// DOMRect {x: 174.64999389648438, y: 190.35000610351562, width: 297.5, height: 95.19998168945312, top: 190.35000610351562, …}
svg & stroke & style & class的更多相关文章
- 学习SVG系列(3):SVG Stroke属性
SVG stroke 属性 1.stroke 2.stroke-width 3.stroke-linecap 4.stroke-dasharray 5.stroke-opacity 6.stroke- ...
- SVG Stroke属性
一.stroke属性介绍 SVG提供了一个范围广泛stroke属性,用于描述轮廓,其中包括 stroke 指定颜色 stroke-width 指定宽度 stroke-linecap 指定端点样式 st ...
- [翻译svg教程]svg中矩形元素 rect
svg 元素<rect> 是一个矩形元素,用这个元素,可以你可以绘制矩形,设置矩形宽高,边框的宽度颜色,矩形的填充颜色,是否用圆角等 rect 示例 <svg xmlns=" ...
- SVG的使用
一,svg可以在浏览器中直接打开 二,在html使用<img/>标签引用 三,直接在html中使用svg标签 四,作为css背景 SVG支持ie9+ ,chrome 33.0+,firef ...
- HTML5的 2D SVG和SVG DOM的学习笔记(1)
(项目中要使用SVG,只好补充知识了) HTML体系中,最常用的绘制矢量图的技术是SVG和HTML5新增加的canvas元素.这两种技术都支持绘制矢量图和光栅图. 一.SVG概述 可缩放矢量图形(Sc ...
- SVG 学习(一)
SVG 意为可缩放矢量图形(Scalable Vector Graphics). SVG 使用 XML 格式定义图像. 什么是SVG? SVG 指可伸缩矢量图形 (Scalable Vector Gr ...
- SVG的内部事件添加
SVG的内部事件添加: <%@ page language="java" contentType="text/html; charset=UTF-8" p ...
- SVG的text使用
SVG的text使用: 参考:http://www.docin.com/p-7393979.html <%@ page language="java" contentType ...
- SVG的path的使用
SVG的path的使用: 参考:http://justcoding.iteye.com/blog/2226354 <%@ page language="java" conte ...
随机推荐
- Google performance Tools (gperftools) 使用心得
Google performance Tools (gperftools) 使用心得 gperftools是google开发的一款非常实用的工具集,主要包括:性能优异的malloc free内存分配器 ...
- Grafana+Prometheus通过node_exporter监控Linux服务器信息
Grafana+Prometheus通过node_exporter监控Linux服务器信息 一.Grafana+Prometheus通过node_exporter监控Linux服务器信息 1.1nod ...
- Spark调优 | Spark Streaming 调优
Spark调优 | Spark Streaming 调优 1.数据序列化 2.广播大变量 3.数据处理和接收时的并行度 4.设置合理的批处理间隔 5.内存优化 5.1 内存管理 5.2优化策略 5.3 ...
- 通过jenkins构建服务,并发布服务,修改Jenkins以Root用户运行
通过jenkins构建服务,并发布服务,修改Jenkins以Root用户运行 其他博文:从0到1体验Jenkins+Docker+Git+Registry实现CI自动化发布 Jenkins注册中心 一 ...
- libuv事件循环
目录 1.说明 2.数据类型 2.1.uv_loop_t 2.2.uv_walk_cb 3.API 3.1.uv_loop_init 3.2.uv_loop_configure 3.3.uv_loop ...
- canal-adapter1.1.14最新版本安装的过程中出现的NullPointerException异常
记录一下我在安装 canal-adapter1.1.14最新版本安装的过程中出现的NullPointerException异常 以下是我的canal-adapter/logs文件夹内adapter.l ...
- 每个开发人员都应该知道的WebSockets知识
转载请注明出处:葡萄城官网,葡萄城为开发者提供专业的开发工具.解决方案和服务,赋能开发者. 原文出处:https://blog.bitsrc.io/deep-dive-into-websockets- ...
- Codeforces Round #550 (Div. 3) D. Equalize Them All (贪心,模拟)
题意:有一组数,可以选择某个数\(a_i\)相邻的一个数\(a_j\),然后可以让\(a_i\)加上或者减去\(|a_i-a_j|\),问最少操作多少次使得数组中所有数相同. 题解:不难发现,每次操作 ...
- linux下安装python3.7.2
1.到python的官网去下载python3.7.2安装包,必须是Linux版本的 2.在/usr/tmp下下载python安装包 wget https://www.python.org/ftp/py ...
- Python 读Excel数据
一.读取Excel数据的步骤及方式: 1.打开Excel文件 data = xlrd.open_workbook(r'D:\Interface_test\test_data\测试用例.xlsx') 2 ...