PiDraw API
    Preparing search index...

    Class Circle

    A circle, found from exactly one construction: its center and its radius, three points, a center and a tangent line, a diameter, or the triangle it is inscribed in (see ICircleConfig).

    A circle that does not exist (aligned points, a center on its tangent, a radius point on the center, a point without a position) is not drawn: its center and its radius are NaN, and it is drawn again when it exists again.

    Hierarchy (View Summary)

    Index
    followable: true

    Where a point dragged to (x, y) lands on the circle: the nearest point of the circle. The center goes to the right of the circle. A circle that does not exist does not constrain the point.

    referenceable: true

    Whether the label of another figure can be pushed away from this one (see setLabelReference): whether referenceAnchorPoint puts a position on it. A figure that overrides that overrides this too.

    • get center(): XY

      Center of the circle, in pixels. NaN when the circle does not exist. A copy: it follows its points when the circle is computed again.

      Returns XY

    • get config(): ICircleConfig

      The configuration the figure is made from, and the same object until the figure is given another one. The graph reads in it the figures this one depends on (a line through two points...) to draw it again when they move.

      Returns ICircleConfig

    • set config(value: ICircleConfig): void

      Replace the construction of the circle: it finds its place again, and its shape and its label follow.

      Parameters

      Returns void

      InvalidArgumentError if value is not a valid config (see the constructor). The circle is then left as it was.

    • get controls(): Readonly<Partial<IControlsFigure>>

      What the themes keep on the figure (the animation of a point, the steps of a presentation...), by the name of the theme. The figure does not know what the entries mean: a theme writes its own with setControl, after it checked the value, and reads it back here.

      Returns Readonly<Partial<IControlsFigure>>

    • Give a label to the figure. A figure has one label: a previous one is removed from the svg.

      Parameters

      • Optionalcontent: LabelContent

        a text, or texts and fields ({field, digits}) that the figure computes and keeps up to date. The text is written as it is: @ is a character like any other. By default, the name of the figure.

      • options: ILabelOptions = {}

        asHtml writes the label in HTML, for the text of a texConverter.

      Returns Label

      InvalidArgumentError if the content has a field the figure cannot show (see labelFields), or a number of digits that is not an integer of 0 or more. The figure is then left as it was.

    • Draw the stroke as dashes. The pattern is kept: it is applied again by every stroke(), so a figure that builds a new shape keeps its dashes.

      Parameters

      • Optionaldasharray: string | number

        lengths of the dashes and of the gaps, in pixels ('5', '5 2', '5,2,1'), or 'none' for a continuous stroke. By default, DEFAULT_DASH: pixels, so the dashes look the same at any scale, resolution or zoom.

      Returns this

      InvalidArgumentError if the pattern is not made of positive numbers. The figure is then left unchanged.

    • Fill the figure, or apply the current fill again when called without a color.

      Parameters

      • Optionalcolor: string | IColorValue

        the name of a color, or {color, opacity} (opacity from 0 to 1), for instance {color: 'red', opacity: 0.5}. The opacity only concerns the fill: it is the fill-opacity of the shape.

      Returns this

      InvalidArgumentError if the color or the opacity is invalid. The figure is then left unchanged.

    • Where a point dragged by the user to (x, y) lands on the figure: the point of the figure that a point following it takes. Used by the drag of a point (drag=<figure>) and by the Follow figure. A figure that a point can follow overrides it (a line projects the point on the line, a circle on the circle, a plot takes the point of the curve at the same abscissa). By default, the point is not constrained.

      Parameters

      • x: number

        abscissa of the dragged point, in pixels.

      • y: number

        ordinate of the dragged point, in pixels.

      Returns XY

      the position on the figure, in pixels.

    • The points where this circle crosses another one, in pixels: two points, one if they touch.

      Parameters

      Returns XY[] | null

      null if they are apart, one is inside the other, they have the same center, or a circle does not exist.

    • The points where the whole line cuts the circle (not only the part that is drawn), in pixels and in the order of the line: two points, one if the line touches the circle.

      Parameters

      Returns XY[] | null

      null if the line misses the circle, or if the circle or the line does not exist.

    • Put a marker (an arrow head, a cross or a bar) on the ends of the figure. The marker takes the color and the width of the stroke, whatever the order of the calls. The other end is left as it is.

      Parameters

      • options: IMarkOptions = {}

        the side ('start', 'end' or 'both', the default; 'none' removes the markers of both ends, and works on any figure), the size (default 10) and the shape ('->' for an arrow, the default, 'x' for a cross or '|' for a bar).

      Returns this

      InvalidArgumentError if the side, the size or the shape is invalid, or if the shape of the figure cannot carry a marker (only the lines, the polylines, the polygons and the paths can). The figure is then left unchanged.

    • Move the shape of the figure by a vector given in the units of the coordinate system. Each move is added to the previous ones.

      Parameters

      • pos: number

        the vector {x, y}. A number is a move along the Ox axis, move({x: pos, y: 0}).

      Returns this

      InvalidArgumentError if pos is not a finite number nor a {x, y} of finite numbers.

    • Move the shape of the figure by a vector given in the units of the coordinate system. Each move is added to the previous ones.

      Parameters

      • pos: XY

        the vector {x, y}. A number is a move along the Ox axis, move({x: pos, y: 0}).

      Returns this

      InvalidArgumentError if pos is not a finite number nor a {x, y} of finite numbers.

    • Take away what was asked of the figure since it was made, so that a figure that is given another configuration looks like a new one: the appearance, the dashes and the markers, the moves and the scales of the shape, the label, what the themes kept (controls), whether the user holds it, and whether it is hidden. The shape and the configuration stay as they are (the shape is made again, in the default style, by the next config), and so does static, which the figure or its owner sets.

      Returns this

    • Scale the shape of the figure around its center. Each scale is multiplied with the previous ones. The label of the figure is not scaled.

      Parameters

      • value: number | XY

        the factors {x, y}. A number is the same factor on both axes.

      Returns this

      InvalidArgumentError if value is not a finite number nor a {x, y} of finite numbers.

    • Hide the figure, or show it again, for a reason that has a name (slide for a presentation). The figure is hidden as long as one reason holds; hide() and the lack of a position are other causes, which this does not touch. The label goes with the figure.

      Parameters

      • reason: string
      • hidden: boolean

      Returns this

    • Keep the label this far from the figure, in pixels, in the direction where it lies, when the label was asked no push of its own. A point that has a drag handle (a disc over the point) needs it: the handle is over its label.

      Parameters

      • pixels: number

      Returns this

    • Push the label away from another figure: it lies on the side of its anchor that is opposite to the reference, wherever the reference is (a point of a circle, away from the center). The label follows the reference when it moves (Graph.update). Without a reference, the label goes back to the side that the figure chooses for it.

      Parameters

      • reference: AbstractFigure | null

        the figure, or null for none. A figure whose position changes the label stays the one it was built on: it is not a dependency, so a reference never makes a cycle.

      Returns this

      InvalidArgumentError if the figure has no point to be pushed away from (a line, a curve: see referenceable).

    • The circle as TikZ: its center and its radius in units of the coordinate system, then its label. The radius is the one of the x axis; when the axes have different scales it is written for each axis, so that the circle stays round like on screen. Nothing for a circle that is hidden or does not exist.

      Returns string

      InvalidArgumentError if the appearance of the circle has no TikZ equivalent (see AbstractFigure.tikz).

    • Draw the figure again (computed) and update its label, to follow what it depends on.

      Parameters

      • OptionalforceUpdate: boolean

        a figure that is static (it does not depend on anything that moves, as the axes) or isDraggable (the user moves it) is left as it is, unless this is true.

      Returns this