• xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!


    svg & stroke & style & class

    svg selected style

    methods

    1. style

    2. class, !important

    3. fill, stroke, stroke-width, fill-opacity: 0.5;

    4. 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-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-5" />
      Sorry, your browser does not support inline SVG.
    </svg>
    
    </body>
    </html>
    
    
    style="fill:lime; stroke:purple; stroke-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-5"></polygon>
    
    

    css class

    stroke-width, stroke

    .selected-class {
        fill: #ccc !important;
        stroke- 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-​5">​</polygon>​
    poly.getBBox();
    // SVGRect {x: 249.5, y: 0.5,  425, height: 136}
    poly.getBoundingClientRect();
    // DOMRect {x: 174.64999389648438, y: 190.35000610351562,  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,  425, height: 136}
    poly.getBoundingClientRect();
    // DOMRect {x: 174.64999389648438, y: 190.35000610351562,  297.5, height: 95.19998168945312, top: 190.35000610351562, …}
    
    
    
    
    

  • 相关阅读:
    Solon 开发进阶,二、体外扩展机制
    Solon Web 开发,二、开发知识准备
    Solon Web 开发,四、请求上下文
    CODING 项目协同 2.0 —— 让协作有条不紊
    (三)React组件的三大特性 State
    (四)React组件的三大特性 Props
    (五)React的三大特性 refs
    (二)React的组件的创建 ,js类的基础复习
    (一)React系列文章:虚拟DOM的创建与解释,注意的相关规则
    [源码解析] PyTorch 分布式(16) 使用异步执行实现批处理 RPC
  • 原文地址:https://www.cnblogs.com/xgqfrms/p/12303736.html
Copyright © 2020-2023  润新知