Quantcast
Channel: GoJS - Northwoods Software
Viewing all articles
Browse latest Browse all 7069

Imprecise results when using go.Rect.unionRect()

$
0
0

@Dominic.Lerbs wrote:

Hi,

I am using the go.Rect.unionRect function to create a Rect for multiple GraphObjects:

let allBounds: go.Rect;
graphObjects.each(panel => {
  let bounds = new go.Rect(panel.getDocumentPoint(go.Spot.TopLeft), panel.getDocumentPoint(go.Spot.RightCenter));
  // bounds.bottom = 540
  if (!allBounds) {
    allBounds = bounds;
  } else {
    allBounds = allBounds.unionRect(bounds);
  }
  // allBounds.bottom = 539.9999999999999
  // In some other place: allBounds.containsPoint(bounds) => false
});

The most bottom GraphObject has a bottom coordinate of 540.
However, the resulting union Rect has a bottom coordinate of 539.9999999999999.

This is not good as I am later using go.Rect.containsPoint() Method which returns false.

Any advice?

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 7069

Trending Articles