jinlin
2024-09-26 7ec9326ce00d08f9d957981f2edff6df26f24a28
web/public/SVGOrigin/Method-Draw-master/editor/extensions/ext-grid.js
@@ -21,7 +21,7 @@
    var svgCanvas = methodDraw.canvas;
    var showGrid = false;
    var assignAttributes = s.assignAttributes;
    var hcanvas = document.createElement('canvas');
    $(hcanvas).hide().appendTo('body');
@@ -35,11 +35,11 @@
        'overflow': 'visible',
        'display': 'none'
    });
    var canvBG = $('#canvas_background');
    canvBG.after(canvasgrid);
        // grid-pattern
        var gridPattern = svgdoc.createElementNS(svgns, "pattern");
@@ -51,7 +51,7 @@
            'width': 100,
            'height': 100
        });
        var gridimg = svgdoc.createElementNS(svgns, "image");
        assignAttributes(gridimg, {
            'x': 0,
@@ -59,7 +59,7 @@
            'width': 100,
            'height': 100
        });
        gridPattern.appendChild(gridimg);
        $('#svgroot defs').append(gridPattern);
@@ -81,25 +81,25 @@
    function updateGrid(zoom) {
        // TODO: Try this with <line> elements, then compare performance difference
        var bgwidth = +canvBG.attr('width');
        var bgheight = +canvBG.attr('height');
        var units = svgedit.units.getTypeMap();
        var unit = units[methodDraw.curConfig.baseUnit]; // 1 = 1px
        var r_intervals = [.01, .1, 1, 10, 100, 1000];
        var d = 0;
        var is_x = (d === 0);
        var dim = is_x ? 'x' : 'y';
        var lentype = is_x?'width':'height';
        var c_elem = svgCanvas.getContentElem();
        var content_d = c_elem.getAttribute(dim)-0;
        var hcanv = hcanvas;
        var u_multi = unit * zoom;
        // Calculate the main number interval
        var raw_m = 100 / u_multi;
        var multi = 1;
@@ -110,7 +110,7 @@
                break;
            }
        }
        var big_int = multi * u_multi;
        // Set the canvas size to the width of the container
@@ -118,9 +118,9 @@
        hcanv.height = big_int;
        var ctx = hcanv.getContext("2d");
        var ruler_d = 0;
        var ruler_d = 0;
        var cur_d = .5;
        var part = big_int / 10;
        ctx.globalAlpha = 0.2;
@@ -135,7 +135,7 @@
            ctx.lineTo(line_num ,sub_d);
        }
        ctx.stroke();
        ctx.beginPath();
        ctx.beginPath();
        ctx.globalAlpha = 0.5;
        ctx.moveTo(cur_d, big_int);
        ctx.lineTo(cur_d, 0);