# Feature request: Rectangle\<\>::withHeightKeepingCentre(int height)

**URL:** <https://forum.juce.com/t/feature-request-rectangle-withheightkeepingcentre-int-height/36184>\
**Category:** General JUCE discussion\
**Created:** [November 15, 2019, 5:17pm UTC](https://forum.juce.com/t/feature-request-rectangle-withheightkeepingcentre-int-height/36184 "2019-11-15T17:17:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jimc](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/jimc/32/16067_2.png) [@jimc](https://forum.juce.com/u/jimc)\
**Post date:** [November 15, 2019, 5:17pm UTC](https://forum.juce.com/t/feature-request-rectangle-withheightkeepingcentre-int-height/36184/1 "2019-11-15T17:17:12Z")

</div>

Rectangle withHeightKeepingCentre(int height)  
{  
return withSizeKeepingCentre(getWidth(), height);  
}

and likewise for withWidthKeepingCentre.

These are annoying to express sometimes otherwise 😉

---

<div class="post-metadata">

**Author:** ![yfede](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/yfede/32/506_2.png) [@yfede](https://forum.juce.com/u/yfede)\
**Post date:** [November 21, 2019, 9:17am UTC](https://forum.juce.com/t/feature-request-rectangle-withheightkeepingcentre-int-height/36184/2 "2019-11-21T09:17:01Z")

</div>

It’d be very nice if someone would come up with some template magic to implement a generic

`changeKeeping (Rectangle <T> &, enum whatToChange, T changedValue, enum whatToKeep)`

with the two enums expressing the Rectangle aspects like:

```auto
enum RectangleAspects
{
    x,
    y,
    rightX,
    bottomY,
    width,
    height,
    top,
    left,
    right,
    bottom,
    centreX,
    centreY,
}

```

I’ve expressed it as a free function that acts on a Rectangle, but I have nothing in contrary if someone at JUCE could implement it as a Rectangle member!
