Skip to content

Commit

Permalink
Merge pull request #1234 from richardeakin/rect_moveULTo
Browse files Browse the repository at this point in the history
RectT::moveULTo(), getMoveULTo()
  • Loading branch information
richardeakin committed Dec 20, 2015
2 parents fda4f63 + 4289de5 commit dd16254
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
8 changes: 7 additions & 1 deletion include/cinder/Rect.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,14 @@ class RectT {
void clipBy( const RectT &clip );
RectT getClipBy( const RectT &clip ) const;
Area getInteriorArea() const;
//! Translates the RectT by \a off
void offset( const Vec2T &offset );
RectT getOffset( const Vec2T &off ) const { RectT result( *this ); result.offset( off ); return result; }
//! Returns a copy of the RectT translated by \a off
RectT getOffset( const Vec2T &off ) const;
//! Translates the RectT so that its upper-left corner is \a newUL
void moveULTo( const Vec2T &newUL );
//! Returns a copy of the RectT translated so that its upper-left corner is \a newUL
RectT getMoveULTo( const Vec2T &newUL ) const;
void inflate( const Vec2T &amount );
RectT inflated( const Vec2T &amount ) const;
//! Translates the rectangle so that its center is at \a center
Expand Down
20 changes: 20 additions & 0 deletions src/cinder/Rect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,26 @@ void RectT<T>::offset( const Vec2T &offset )
y2 += offset.y;
}

template<typename T>
RectT<T> RectT<T>::getOffset( const Vec2T &off ) const
{
RectT result( *this ); result.offset( off ); return result;
}

template<typename T>
void RectT<T>::moveULTo( const Vec2T &newUL )
{
set( newUL.x, newUL.y, newUL.x + getWidth(), newUL.y + getHeight() );
}

template<typename T>
RectT<T> RectT<T>::getMoveULTo( const Vec2T &newUL ) const
{
RectT result( *this );
result.moveULTo( newUL );
return result;
}

template<typename T>
void RectT<T>::inflate( const Vec2T &amount )
{
Expand Down

0 comments on commit dd16254

Please sign in to comment.