Title: Convenience setters for Scene.scale and Scene.offset · Issue #86 · PAIR-code/megaplot · GitHub
Open Graph Title: Convenience setters for Scene.scale and Scene.offset · Issue #86 · PAIR-code/megaplot
X Title: Convenience setters for Scene.scale and Scene.offset · Issue #86 · PAIR-code/megaplot
Description: The SpriteView implementation provides convenient setters for the PositionWorld etc. properties as: set PositionWorld(value: (number[] | {x?: number; y?: number;})) { /* ...some logic... */ } I would like the same convenience setters for...
Open Graph Description: The SpriteView implementation provides convenient setters for the PositionWorld etc. properties as: set PositionWorld(value: (number[] | {x?: number; y?: number;})) { /* ...some logic... */ } I wou...
X Description: The SpriteView implementation provides convenient setters for the PositionWorld etc. properties as: set PositionWorld(value: (number[] | {x?: number; y?: number;})) { /* ...some logic... */ } I wou...
Opengraph URL: https://github.com/PAIR-code/megaplot/issues/86
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Convenience setters for Scene.scale and Scene.offset","articleBody":"The `SpriteView` implementation provides convenient [setters for the `PositionWorld`](https://github.com/PAIR-code/megaplot/blob/main/src/lib/generated/sprite-view-impl.ts#L450) etc. properties as:\r\n\r\n```javascript \r\nset PositionWorld(value: (number[] | {x?: number; y?: number;})) { /* ...some logic... */ }\r\n```\r\n\r\nI would like the same convenience setters for `Scene.scale` and `Scene.offset` as follows.\r\n\r\n```javascript\r\nset scale(value: (number | number[] | {x?: number; y?: number;})) {\r\n if (typeof value === 'number') {\r\n this.scale.x = this.scale.y = value;\r\n } else if (Array.isArray(value)) {\r\n // setter logic similar to SpriteView\r\n } else if (typeof value === 'object') {\r\n // setter logic similar to SpriteView\r\n } else {\r\n throw new TypeError('Argument must be a number, number array, or object.');\r\n }\r\n}\r\n```\r\n\r\nIt seems like this isn't happening now because [`Scene.scale`](https://github.com/PAIR-code/megaplot/blob/main/src/lib/scene-internal.ts#L83) and [`Scene.offset`](https://github.com/PAIR-code/megaplot/blob/main/src/lib/scene-internal.ts#L89) are instances of [`DrawTriggerPoint`](https://github.com/PAIR-code/megaplot/blob/3f4e5acb81cf42b3f64bf8c9f40858b3c3a53dfe/src/lib/draw-trigger-point.ts#L23), but it shouldn't be hard to move these to an internal `private` variable and convert the public interfaces to getters and setters. What might be more difficult to overcome is the philosophical desire to always be setting the `x` and `y` components of a `DrawTriggerPoint` directly.\r\n\r\n","author":{"url":"https://github.com/RyanMullins","@type":"Person","name":"RyanMullins"},"datePublished":"2022-11-07T12:43:49.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/86/megaplot/issues/86"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:1332c32e-97bd-ef2d-3492-696832d2d431 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DB1C:3A2E82:595C37:7A9DA0:6A4DCCD4 |
| html-safe-nonce | 0f331a0d18c9bd5afdb6af5c69e0eb85b91fe4a8a1a06406768239724b68df71 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEQjFDOjNBMkU4Mjo1OTVDMzc6N0E5REEwOjZBNERDQ0Q0IiwidmlzaXRvcl9pZCI6Ijk5MTI0NDEzNjkxMTU4ODU2NCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 8d7560ff17de665dae85769c7f927c8364a786df06526963dafabf0256fc462d |
| hovercard-subject-tag | issue:1438305287 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/PAIR-code/megaplot/86/issue_layout |
| twitter:image | https://opengraph.githubassets.com/2fd57bb3aae03e99b412db745d87bc338a78fd906b1a5ddc3a3a96be4832d292/PAIR-code/megaplot/issues/86 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/2fd57bb3aae03e99b412db745d87bc338a78fd906b1a5ddc3a3a96be4832d292/PAIR-code/megaplot/issues/86 |
| og:image:alt | The SpriteView implementation provides convenient setters for the PositionWorld etc. properties as: set PositionWorld(value: (number[] | {x?: number; y?: number;})) { /* ...some logic... */ } I wou... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | RyanMullins |
| hostname | github.com |
| expected-hostname | github.com |
| None | 06b8a6144231bf3a234f1c2e9993861e07ce98a905912b114aa386c2d7e84b33 |
| turbo-cache-control | no-preview |
| go-import | github.com/PAIR-code/megaplot git https://github.com/PAIR-code/megaplot.git |
| octolytics-dimension-user_id | 29804435 |
| octolytics-dimension-user_login | PAIR-code |
| octolytics-dimension-repository_id | 451893434 |
| octolytics-dimension-repository_nwo | PAIR-code/megaplot |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 451893434 |
| octolytics-dimension-repository_network_root_nwo | PAIR-code/megaplot |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 1d344bdb7547fe6bca17a59bb2b8aac3dc9532a0 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width