MCPcopy
hub / github.com/chartjs/Chart.js / drawBorder

Function drawBorder

src/elements/element.arc.ts:241–290  ·  view source on GitHub ↗
(
  ctx: CanvasRenderingContext2D,
  element: ArcElement,
  offset: number,
  spacing: number,
  circular: boolean,
)

Source from the content-addressed store, hash-verified

239}
240
241function drawBorder(
242 ctx: CanvasRenderingContext2D,
243 element: ArcElement,
244 offset: number,
245 spacing: number,
246 circular: boolean,
247) {
248 const {fullCircles, startAngle, circumference, options} = element;
249 const {borderWidth, borderJoinStyle, borderDash, borderDashOffset, borderRadius} = options;
250 const inner = options.borderAlign === 'inner';
251
252 if (!borderWidth) {
253 return;
254 }
255
256 ctx.setLineDash(borderDash || []);
257 ctx.lineDashOffset = borderDashOffset;
258
259 if (inner) {
260 ctx.lineWidth = borderWidth * 2;
261 ctx.lineJoin = borderJoinStyle || 'round';
262 } else {
263 ctx.lineWidth = borderWidth;
264 ctx.lineJoin = borderJoinStyle || 'bevel';
265 }
266
267 let endAngle = element.endAngle;
268 if (fullCircles) {
269 pathArc(ctx, element, offset, spacing, endAngle, circular);
270 for (let i = 0; i < fullCircles; ++i) {
271 ctx.stroke();
272 }
273 if (!isNaN(circumference)) {
274 endAngle = startAngle + (circumference % TAU || TAU);
275 }
276 }
277
278 if (inner) {
279 clipArc(ctx, element, endAngle);
280 }
281
282 if (options.selfJoin && endAngle - startAngle >= PI && borderRadius === 0 && borderJoinStyle !== 'miter') {
283 clipSelf(ctx, element, endAngle);
284 }
285
286 if (!fullCircles) {
287 pathArc(ctx, element, offset, spacing, endAngle, circular);
288 ctx.stroke();
289 }
290}
291
292export interface ArcProps extends Point {
293 startAngle: number;

Callers 1

drawMethod · 0.85

Calls 3

pathArcFunction · 0.85
clipArcFunction · 0.85
clipSelfFunction · 0.85

Tested by

no test coverage detected