MCPcopy Create free account
hub / github.com/openscopeproject/InteractiveHtmlBom / drawPolygonShape

Function drawPolygonShape

InteractiveHtmlBom/web/render.js:235–252  ·  view source on GitHub ↗
(ctx, scalefactor, shape, color)

Source from the content-addressed store, hash-verified

233}
234
235function drawPolygonShape(ctx, scalefactor, shape, color) {
236 ctx.save();
237 if (!("svgpath" in shape)) {
238 ctx.translate(...shape.pos);
239 ctx.rotate(deg2rad(-shape.angle));
240 }
241 if("filled" in shape && !shape.filled) {
242 ctx.strokeStyle = color;
243 ctx.lineWidth = Math.max(1 / scalefactor, shape.width);
244 ctx.lineCap = "round";
245 ctx.lineJoin = "round";
246 ctx.stroke(getPolygonsPath(shape));
247 } else {
248 ctx.fillStyle = color;
249 ctx.fill(getPolygonsPath(shape));
250 }
251 ctx.restore();
252}
253
254function drawDrawing(ctx, scalefactor, drawing, color) {
255 if (["segment", "arc", "circle", "curve", "rect"].includes(drawing.type)) {

Callers 2

drawDrawingFunction · 0.85
drawBgLayerFunction · 0.85

Calls 3

deg2radFunction · 0.85
getPolygonsPathFunction · 0.85
saveMethod · 0.80

Tested by

no test coverage detected