question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Shape.Box is placed strangely

See original GitHub issue

When you create a Box, it is rendered with its center on the top left of the original dimensions used to create it.

relevantly:

lazy val position: Point = dimensions.position - (Point(square) / 2) - (stroke.width / 2)

I’m wondering if a box shape is really needed, or if box-specific constructors for a Polygon would suffice.

Shape.Polygon(myRectangle.corners, ..., ...)

works identically in place of the broken

Shape.Box(myRectangle, ..., ...)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
davesmith00000commented, May 3, 2021

Fixed, will be in the next release.

1reaction
nrktktcommented, Apr 25, 2021

Thanks for the thoughtful response!

  1. I don’t think I’d have noticed that box was really square under the hood if it looked like a rectangle on the screen
  2. I think positioning the box from the top left (by default) seems natural, given a) how Graphics behave and b) that you can change the reference point

Particularly, with the current API I’m not sure how the ref and the position relate. I would expect that the position would be the top left of the dimensions adjusted by the ref (ie. dimensions.topLeft + size/2 to get a centered position). Circle would be a bit less surprising to have the origin in the center (or maybe I’d expect the origin to be top left with a ref defaulted to the center). But then it’s very surprising that a Polygon behaves differently than a Box, which I would assume is just a performance optimized Polygon with four sides at 90* angles.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Packing Irregular Shaped Items: UPS - Reunion
Use these guidelines and tips to help you pack your irregularly shaped items correctly. This document contains: Bundled and Strapped Boxes ...
Read more >
Weird SQUARE BOXES in updated fields - Oracle Communities
I updates few hundreds of records by multiple updte statements where i copied and inserted values. I think I left some blank spaces...
Read more >
How can I adjust these weirdly large margins on my text box?
Not only a waste of space but weird looking. I adjusted all margins to 0 under text and shape using Format Shape -...
Read more >
How to Package Odd-Shaped/Sized Objects for Shipping?
Take another, similar box and place it below or next to the first box ... On the other hand, packaging weird-shaped objects is...
Read more >
Strange rectangle shape appears in the middle of cardView if I ...
This happens because of elevation . Set cardElevation to 0dp and check <androidx.cardview.widget.CardView android:layout_width="160dp" ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found