Skip to content

Commit

Permalink
🐛 Deprecate hex.center
Browse files Browse the repository at this point in the history
It ignores the hex's origin, making it a useless, but especially confusing property. See #112.
  • Loading branch information
flauwekeul committed Nov 20, 2023
1 parent 3df50d9 commit cf32269
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 27 deletions.
51 changes: 29 additions & 22 deletions docs/api/classes/Hex.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@

#### Defined in

[hex/hex.ts:103](https://github.com/flauwekeul/honeycomb/blob/master/src/hex/hex.ts#L103)
[hex/hex.ts:107](https://github.com/flauwekeul/honeycomb/blob/master/src/hex/hex.ts#L107)

## Properties

Expand All @@ -72,7 +72,7 @@ Readonly.q

#### Defined in

[hex/hex.ts:100](https://github.com/flauwekeul/honeycomb/blob/master/src/hex/hex.ts#L100)
[hex/hex.ts:104](https://github.com/flauwekeul/honeycomb/blob/master/src/hex/hex.ts#L104)

___

Expand All @@ -86,21 +86,28 @@ Readonly.r

#### Defined in

[hex/hex.ts:101](https://github.com/flauwekeul/honeycomb/blob/master/src/hex/hex.ts#L101)
[hex/hex.ts:105](https://github.com/flauwekeul/honeycomb/blob/master/src/hex/hex.ts#L105)

## Accessors

### <a id="center" name="center"></a> center

`get` **center**(): [`Point`](../interfaces/Point.md)

This returns a point relative to the __top left corner__ of the hex with coordinates `[0, 0]`, ignoring any `origin` you may have set.

**`Deprecated`**

This probably doesn't do what you expect. If you want the center coordinates of a hex, use `hex.x` and `hex.y` instead.
See https://github.com/flauwekeul/honeycomb/discussions/95#discussioncomment-5158862.

#### Returns

[`Point`](../interfaces/Point.md)

#### Defined in

[hex/hex.ts:29](https://github.com/flauwekeul/honeycomb/blob/master/src/hex/hex.ts#L29)
[hex/hex.ts:33](https://github.com/flauwekeul/honeycomb/blob/master/src/hex/hex.ts#L33)

___

Expand All @@ -118,7 +125,7 @@ Readonly.col

#### Defined in

[hex/hex.ts:34](https://github.com/flauwekeul/honeycomb/blob/master/src/hex/hex.ts#L34)
[hex/hex.ts:38](https://github.com/flauwekeul/honeycomb/blob/master/src/hex/hex.ts#L38)

___

Expand All @@ -132,7 +139,7 @@ ___

#### Defined in

[hex/hex.ts:39](https://github.com/flauwekeul/honeycomb/blob/master/src/hex/hex.ts#L39)
[hex/hex.ts:43](https://github.com/flauwekeul/honeycomb/blob/master/src/hex/hex.ts#L43)

___

Expand All @@ -146,7 +153,7 @@ ___

#### Defined in

[hex/hex.ts:44](https://github.com/flauwekeul/honeycomb/blob/master/src/hex/hex.ts#L44)
[hex/hex.ts:48](https://github.com/flauwekeul/honeycomb/blob/master/src/hex/hex.ts#L48)

___

Expand All @@ -164,7 +171,7 @@ Readonly.height

#### Defined in

[hex/hex.ts:48](https://github.com/flauwekeul/honeycomb/blob/master/src/hex/hex.ts#L48)
[hex/hex.ts:52](https://github.com/flauwekeul/honeycomb/blob/master/src/hex/hex.ts#L52)

___

Expand All @@ -178,7 +185,7 @@ ___

#### Defined in

[hex/hex.ts:56](https://github.com/flauwekeul/honeycomb/blob/master/src/hex/hex.ts#L56)
[hex/hex.ts:60](https://github.com/flauwekeul/honeycomb/blob/master/src/hex/hex.ts#L60)

___

Expand All @@ -192,7 +199,7 @@ ___

#### Defined in

[hex/hex.ts:60](https://github.com/flauwekeul/honeycomb/blob/master/src/hex/hex.ts#L60)
[hex/hex.ts:64](https://github.com/flauwekeul/honeycomb/blob/master/src/hex/hex.ts#L64)

___

Expand All @@ -206,7 +213,7 @@ ___

#### Defined in

[hex/hex.ts:72](https://github.com/flauwekeul/honeycomb/blob/master/src/hex/hex.ts#L72)
[hex/hex.ts:76](https://github.com/flauwekeul/honeycomb/blob/master/src/hex/hex.ts#L76)

___

Expand All @@ -220,7 +227,7 @@ ___

#### Defined in

[hex/hex.ts:64](https://github.com/flauwekeul/honeycomb/blob/master/src/hex/hex.ts#L64)
[hex/hex.ts:68](https://github.com/flauwekeul/honeycomb/blob/master/src/hex/hex.ts#L68)

___

Expand All @@ -234,7 +241,7 @@ ___

#### Defined in

[hex/hex.ts:68](https://github.com/flauwekeul/honeycomb/blob/master/src/hex/hex.ts#L68)
[hex/hex.ts:72](https://github.com/flauwekeul/honeycomb/blob/master/src/hex/hex.ts#L72)

___

Expand All @@ -252,7 +259,7 @@ Readonly.row

#### Defined in

[hex/hex.ts:76](https://github.com/flauwekeul/honeycomb/blob/master/src/hex/hex.ts#L76)
[hex/hex.ts:80](https://github.com/flauwekeul/honeycomb/blob/master/src/hex/hex.ts#L80)

___

Expand All @@ -270,7 +277,7 @@ Readonly.s

#### Defined in

[hex/hex.ts:96](https://github.com/flauwekeul/honeycomb/blob/master/src/hex/hex.ts#L96)
[hex/hex.ts:100](https://github.com/flauwekeul/honeycomb/blob/master/src/hex/hex.ts#L100)

___

Expand Down Expand Up @@ -302,7 +309,7 @@ Readonly.width

#### Defined in

[hex/hex.ts:80](https://github.com/flauwekeul/honeycomb/blob/master/src/hex/hex.ts#L80)
[hex/hex.ts:84](https://github.com/flauwekeul/honeycomb/blob/master/src/hex/hex.ts#L84)

___

Expand All @@ -320,7 +327,7 @@ Readonly.x

#### Defined in

[hex/hex.ts:88](https://github.com/flauwekeul/honeycomb/blob/master/src/hex/hex.ts#L88)
[hex/hex.ts:92](https://github.com/flauwekeul/honeycomb/blob/master/src/hex/hex.ts#L92)

___

Expand All @@ -338,7 +345,7 @@ Readonly.y

#### Defined in

[hex/hex.ts:92](https://github.com/flauwekeul/honeycomb/blob/master/src/hex/hex.ts#L92)
[hex/hex.ts:96](https://github.com/flauwekeul/honeycomb/blob/master/src/hex/hex.ts#L96)

## Methods

Expand All @@ -364,7 +371,7 @@ Readonly.y

#### Defined in

[hex/hex.ts:109](https://github.com/flauwekeul/honeycomb/blob/master/src/hex/hex.ts#L109)
[hex/hex.ts:113](https://github.com/flauwekeul/honeycomb/blob/master/src/hex/hex.ts#L113)

___

Expand All @@ -384,7 +391,7 @@ ___

#### Defined in

[hex/hex.ts:113](https://github.com/flauwekeul/honeycomb/blob/master/src/hex/hex.ts#L113)
[hex/hex.ts:117](https://github.com/flauwekeul/honeycomb/blob/master/src/hex/hex.ts#L117)

___

Expand All @@ -398,7 +405,7 @@ ___

#### Defined in

[hex/hex.ts:117](https://github.com/flauwekeul/honeycomb/blob/master/src/hex/hex.ts#L117)
[hex/hex.ts:121](https://github.com/flauwekeul/honeycomb/blob/master/src/hex/hex.ts#L121)

___

Expand All @@ -418,4 +425,4 @@ ___

#### Defined in

[hex/hex.ts:121](https://github.com/flauwekeul/honeycomb/blob/master/src/hex/hex.ts#L121)
[hex/hex.ts:125](https://github.com/flauwekeul/honeycomb/blob/master/src/hex/hex.ts#L125)
2 changes: 1 addition & 1 deletion docs/api/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ ___

#### Defined in

[hex/hex.ts:129](https://github.com/flauwekeul/honeycomb/blob/master/src/hex/hex.ts#L129)
[hex/hex.ts:133](https://github.com/flauwekeul/honeycomb/blob/master/src/hex/hex.ts#L133)

## Coordinates Functions

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions src/hex/hex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,12 @@ export class Hex
return { dimensions, orientation, origin, offset }
}

// todo: add to docs that this always returns a point relative to Hex(0, 0)'s top left corner!
// todo: probably deprecate this, see: https://github.com/flauwekeul/honeycomb/discussions/95#discussioncomment-5158862
/**
* This returns a point relative to the __top left corner__ of the hex with coordinates `[0, 0]`, ignoring any `origin` you may have set.
*
* @deprecated This probably doesn't do what you expect. If you want the center coordinates of a hex, use `hex.x` and `hex.y` instead.
* See https://github.com/flauwekeul/honeycomb/discussions/95#discussioncomment-5158862.
*/
get center(): Point {
const { width, height, x, y } = this
return { x: width / 2 - x, y: height / 2 - y }
Expand Down

0 comments on commit cf32269

Please sign in to comment.