From 847242a59ffb2e9b6a94cffbb21f524183c29738 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Tue, 30 Jul 2013 23:51:55 +1000 Subject: [PATCH] Add scale operation for regions --- region.cpp | 11 +++++++++++ region.hpp | 1 + 2 files changed, 12 insertions(+) diff --git a/region.cpp b/region.cpp index 9ca19a9b..38008f67 100644 --- a/region.cpp +++ b/region.cpp @@ -67,6 +67,17 @@ region::diameter (void) const { } +template +void +region::scale (double factor) { + x -= (w * factor - w) / 2.0; + y -= (h * factor - h) / 2.0; + + w *= factor; + h *= factor; +} + + template bool region::empty (void) const diff --git a/region.hpp b/region.hpp index 231d23ea..73cd3011 100644 --- a/region.hpp +++ b/region.hpp @@ -46,6 +46,7 @@ namespace util { size_type area (void) const; size_type diameter (void) const; + void scale (double factor); bool empty (void) const;