diff --git a/src/tools/brush-selection.ts b/src/tools/brush-selection.ts index 02b04e8d..06a7807c 100644 --- a/src/tools/brush-selection.ts +++ b/src/tools/brush-selection.ts @@ -16,9 +16,6 @@ class BrushSelection { const circle = document.createElementNS(svg.namespaceURI, 'circle') as SVGCircleElement; circle.setAttribute('r', radius.toString()); circle.setAttribute('fill', 'rgba(255, 102, 0, 0.2)'); - circle.setAttribute('stroke', '#f60'); - circle.setAttribute('stroke-width', '1'); - circle.setAttribute('stroke-dasharray', '5, 5'); const { canvas, context } = mask; diff --git a/src/tools/polygon-selection.ts b/src/tools/polygon-selection.ts index 11f419cc..ed6dffba 100644 --- a/src/tools/polygon-selection.ts +++ b/src/tools/polygon-selection.ts @@ -17,17 +17,13 @@ class PolygonSelection { // create polyline element const polyline = document.createElementNS(svg.namespaceURI, 'polyline') as SVGPolylineElement; - polyline.setAttribute('fill', 'none'); - polyline.setAttribute('stroke-width', '1'); - polyline.setAttribute('stroke-dasharray', '5, 5'); - polyline.setAttribute('stroke-dashoffset', '0'); // create canvas const { canvas, context } = mask; const paint = () => { - polyline.setAttribute('points', [...points, currentPoint].filter(v => v).reduce((prev, current) => prev + `${current.x}, ${current.y} `, "")); - polyline.setAttribute('stroke', isClosed() ? '#fa6' : '#f60'); + polyline.setAttribute('points', [...points, currentPoint].reduce((prev, current) => prev + `${current.x}, ${current.y} `, "")); + polyline.setAttribute('class', isClosed() ? 'closed' : ''); }; const dist = (a: Point, b: Point) => { diff --git a/src/tools/rect-selection.ts b/src/tools/rect-selection.ts index e3e0f32e..db9c329e 100644 --- a/src/tools/rect-selection.ts +++ b/src/tools/rect-selection.ts @@ -12,10 +12,6 @@ class RectSelection { // create rect element const rect = document.createElementNS(svg.namespaceURI, 'rect') as SVGRectElement; - rect.setAttribute('fill', 'none'); - rect.setAttribute('stroke', '#f60'); - rect.setAttribute('stroke-width', '1'); - rect.setAttribute('stroke-dasharray', '5, 5'); const start = { x: 0, y: 0 }; const end = { x: 0, y: 0 }; diff --git a/src/ui/scss/style.scss b/src/ui/scss/style.scss index ff1b7b5b..24f79509 100644 --- a/src/ui/scss/style.scss +++ b/src/ui/scss/style.scss @@ -152,6 +152,29 @@ body { width: 100%; height: 100%; cursor: crosshair; + + rect, polyline, polygon, circle { + fill: none; + stroke-dasharray: 5px; + stroke-dashoffset: 10px; + stroke: #f60; + stroke-width: 1px; + animation: stroke 0.2s linear infinite; + + &.closed{ + stroke: #faa; + } + } + + circle { + fill: rgba(255, 102, 0, 0.2); + } + + @keyframes stroke { + to { + stroke-dashoffset: 0; + } + } } #canvas {