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

Function drawedge

InteractiveHtmlBom/web/render.js:124–168  ·  view source on GitHub ↗
(ctx, scalefactor, edge, color)

Source from the content-addressed store, hash-verified

122}
123
124function drawedge(ctx, scalefactor, edge, color) {
125 ctx.strokeStyle = color;
126 ctx.fillStyle = color;
127 ctx.lineWidth = Math.max(1 / scalefactor, edge.width);
128 ctx.lineCap = "round";
129 ctx.lineJoin = "round";
130 if ("svgpath" in edge) {
131 ctx.stroke(new Path2D(edge.svgpath));
132 } else {
133 ctx.beginPath();
134 if (edge.type == "segment") {
135 ctx.moveTo(...edge.start);
136 ctx.lineTo(...edge.end);
137 }
138 if (edge.type == "rect") {
139 ctx.moveTo(...edge.start);
140 ctx.lineTo(edge.start[0], edge.end[1]);
141 ctx.lineTo(...edge.end);
142 ctx.lineTo(edge.end[0], edge.start[1]);
143 ctx.lineTo(...edge.start);
144 }
145 if (edge.type == "arc") {
146 ctx.arc(
147 ...edge.start,
148 edge.radius,
149 deg2rad(edge.startangle),
150 deg2rad(edge.endangle));
151 }
152 if (edge.type == "circle") {
153 ctx.arc(
154 ...edge.start,
155 edge.radius,
156 0, 2 * Math.PI);
157 ctx.closePath();
158 }
159 if (edge.type == "curve") {
160 ctx.moveTo(...edge.start);
161 ctx.bezierCurveTo(...edge.cpa, ...edge.cpb, ...edge.end);
162 }
163 if("filled" in edge && edge.filled)
164 ctx.fill();
165 else
166 ctx.stroke();
167 }
168}
169
170function getChamferedRectPath(size, radius, chamfpos, chamfratio) {
171 // chamfpos is a bitmask, left = 1, right = 2, bottom left = 4, bottom right = 8

Callers 2

drawDrawingFunction · 0.85
drawBgLayerFunction · 0.85

Calls 1

deg2radFunction · 0.85

Tested by

no test coverage detected