| 310 | } |
| 311 | |
| 312 | function drawBorder( |
| 313 | ctx: CanvasRenderingContext2D, |
| 314 | element: ArcElement, |
| 315 | offset: number, |
| 316 | spacing: number, |
| 317 | circular: boolean, |
| 318 | ) { |
| 319 | const {fullCircles, startAngle, circumference, options} = element; |
| 320 | const {borderWidth, borderJoinStyle, borderDash, borderDashOffset, borderRadius} = options; |
| 321 | const inner = options.borderAlign === 'inner'; |
| 322 | |
| 323 | if (!borderWidth) { |
| 324 | return; |
| 325 | } |
| 326 | |
| 327 | ctx.setLineDash(borderDash || []); |
| 328 | ctx.lineDashOffset = borderDashOffset; |
| 329 | |
| 330 | if (inner) { |
| 331 | ctx.lineWidth = borderWidth * 2; |
| 332 | ctx.lineJoin = borderJoinStyle || 'round'; |
| 333 | } else { |
| 334 | ctx.lineWidth = borderWidth; |
| 335 | ctx.lineJoin = borderJoinStyle || 'bevel'; |
| 336 | } |
| 337 | |
| 338 | let endAngle = element.endAngle; |
| 339 | const isFullCircle = Math.abs(endAngle - startAngle) >= TAU - 1e-4; |
| 340 | if (fullCircles) { |
| 341 | pathArc(ctx, element, offset, spacing, endAngle, circular); |
| 342 | for (let i = 0; i < fullCircles; ++i) { |
| 343 | ctx.stroke(); |
| 344 | } |
| 345 | if (!isNaN(circumference)) { |
| 346 | endAngle = startAngle + (circumference % TAU || TAU); |
| 347 | } |
| 348 | } |
| 349 | |
| 350 | if (inner) { |
| 351 | clipArc(ctx, element, endAngle); |
| 352 | } |
| 353 | |
| 354 | const skipSelfClip = isFullCircle && element.innerRadius > 0; |
| 355 | if (!skipSelfClip && options.selfJoin && endAngle - startAngle >= PI && borderRadius === 0 && borderJoinStyle !== 'miter') { |
| 356 | clipSelf(ctx, element, endAngle); |
| 357 | } |
| 358 | |
| 359 | if (!fullCircles) { |
| 360 | pathArc(ctx, element, offset, spacing, endAngle, circular); |
| 361 | ctx.stroke(); |
| 362 | } |
| 363 | } |
| 364 | |
| 365 | export interface ArcProps extends Point { |
| 366 | startAngle: number; |