• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

excaliburjs / Excalibur / 14804036802

02 May 2025 09:58PM UTC coverage: 5.927% (-83.4%) from 89.28%
14804036802

Pull #3404

github

web-flow
Merge 5c103d7f8 into 0f2ccaeb2
Pull Request #3404: feat: added Graph module to Math

234 of 8383 branches covered (2.79%)

229 of 246 new or added lines in 1 file covered. (93.09%)

13145 existing lines in 208 files now uncovered.

934 of 15759 relevant lines covered (5.93%)

4.72 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/engine/Graphics/Circle.ts
1
import { ImageFiltering } from './Filtering';
2
import { Raster, RasterOptions } from './Raster';
3

4
export interface CircleOptions {
5
  radius: number;
6
}
7

8
/**
9
 * A circle {@apilink Graphic} for drawing circles to the {@apilink ExcaliburGraphicsContext}
10
 *
11
 * Circles default to {@apilink ImageFiltering.Blended}
12
 */
13
export class Circle extends Raster {
UNCOV
14
  private _radius: number = 0;
×
15
  public get radius() {
UNCOV
16
    return this._radius;
×
17
  }
18
  public set radius(value: number) {
UNCOV
19
    this._radius = value;
×
UNCOV
20
    this.width = this._radius * 2;
×
UNCOV
21
    this.height = this._radius * 2;
×
UNCOV
22
    this.flagDirty();
×
23
  }
24
  constructor(options: RasterOptions & CircleOptions) {
UNCOV
25
    super(options);
×
UNCOV
26
    const lineWidth = options.lineWidth ?? (options.strokeColor ? 1 : 0); // default lineWidth in canvas is 1px
×
UNCOV
27
    this.padding = options.padding ?? 2 + lineWidth / 2; // default 2 padding for circles looks nice
×
UNCOV
28
    this.radius = options.radius;
×
UNCOV
29
    this.filtering = options.filtering ?? ImageFiltering.Blended;
×
UNCOV
30
    this.rasterize();
×
31
  }
32

33
  public clone(): Circle {
UNCOV
34
    return new Circle({
×
35
      radius: this.radius,
36
      ...this.cloneGraphicOptions(),
37
      ...this.cloneRasterOptions()
38
    });
39
  }
40

41
  execute(ctx: CanvasRenderingContext2D): void {
UNCOV
42
    if (this.radius > 0) {
×
UNCOV
43
      ctx.beginPath();
×
UNCOV
44
      ctx.arc(this.radius, this.radius, this.radius, 0, Math.PI * 2);
×
45

UNCOV
46
      if (this.color) {
×
UNCOV
47
        ctx.fill();
×
48
      }
49

UNCOV
50
      if (this.strokeColor) {
×
UNCOV
51
        ctx.stroke();
×
52
      }
53
    }
54
  }
55
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc