Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simple marching ants with clean SCSS styling #266

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions src/tools/brush-selection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you meant to remove the previous line too

circle.setAttribute('stroke-width', '1');
circle.setAttribute('stroke-dasharray', '5, 5');

const { canvas, context } = mask;

Expand Down
6 changes: 1 addition & 5 deletions src/tools/polygon-selection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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].reduce((prev, current) => prev + `${current.x}, ${current.y} `, ""));
polyline.setAttribute('stroke', isClosed() ? '#fa6' : '#f60');
polyline.setAttribute('class', isClosed() ? 'closed' : '');
};

const dist = (a: Point, b: Point) => {
Expand Down
4 changes: 0 additions & 4 deletions src/tools/rect-selection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand Down
25 changes: 25 additions & 0 deletions src/ui/scss/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,31 @@ body {
width: 100%;
height: 100%;
cursor: crosshair;

rect, polyline {
fill: none;
stroke-dasharray: 5px;
animation: stroke 0.2s linear infinite;
stroke-dashoffset: 10px;
}

circle {
fill: rgba(255, 102, 0, 0.2);
}

rect, polyline, circle {
stroke: #f60;
stroke-width: 2px;
&.closed{
stroke: #faa;
}
}

@keyframes stroke {
to {
stroke-dashoffset: 0;
}
}
}

#canvas {
Expand Down
Loading