microsoft / microsoft/msagljs

No way to alter GeomGraph radX and radY effectively

Open
#91 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
175
Forks
18
Avg merge
6d 3h
Merged PRs (30d)
4

Description

GeomGraph has public attributes radX and radY which contain the corner radius of the graph's bounding rectangle, used when determining the boundaryCurve for the graph.

  • radX and radY in GeomGraph are assigned 10 in the constructor. The constructor then immediately uses these values to construct rrect: RRect.
  • boundaryCurve cannot be altered directly: the setter throws an exception.
  • It can be altered by assigning boundingBox, but in this case it copies the corner radii from the existing RRect, which have previously been assigned 10.
  • So changing radX and radY after constructing the graph does not affect subsequence alterations of boundingBox: they continue to use the values embedded in the boundingBox RRect.

This leaves no apparent API for altering the corner radii.

Expected behavior:

  • changing radX or radY after constructing a GeomGraph and then assigning boundingBox should create a boundaryCurve with the new radii.
  • or a more sophisticated API for either constructing GeomGraph with configurable corner radii
  • or assigning radX and radY invalidates the existing boundaryShape
  • or allow a direct assignment of rrect.

My current workaround uses the last method (which breaks encapsulation):

function setCornerRadius(graph: GeomGraph, radius: number) {
    const bounds = graph.boundingBox;
    const rrect = new RRect({left: bounds.left, top: bounds.top, right: bounds.right, bottom: bounds.bottom, radX: radius, radY: radius});
    (graph as any).rrect = rrect;
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating GeomGraph and inspect its constructor, radX/radY attributes, boundingBox setter, boundaryCurve setter, and internal rrect handling. Reproduce the reported sequence of changing the radii and assigning boundingBox, then verify that the chosen API behavior makes the resulting boundaryCurve use the requested corner radii.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
computer-graphics
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.