From 3e4673742eac9cbe4783b6869ad4837872806be1 Mon Sep 17 00:00:00 2001 From: Robbie Gleichman Date: Fri, 23 Dec 2016 00:40:52 -0800 Subject: [PATCH] Replace custom function with normalizeAngle in transformCorrectedTextBox. --- app/Icons.hs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/Icons.hs b/app/Icons.hs index d341156..1ce1e02 100644 --- a/app/Icons.hs +++ b/app/Icons.hs @@ -237,10 +237,10 @@ textBoxHeightFactor = 1.1 -- BEGIN Text helper functions -- --- TODO May want to use normalizeAngle instead +-- This may be a faster implementation of normalizeAngle --Get the decimal part of a float -reduceAngleRange :: SpecialNum a => a -> a -reduceAngleRange x = x - fromInteger (floor x) +-- reduceAngleRange :: SpecialNum a => a -> a +-- reduceAngleRange x = x - fromInteger (floor x) -- | Given the number of letters in a textbox string, make a rectangle that will -- enclose the text box. Since the normal SVG text has no size, some hackery is @@ -284,7 +284,8 @@ transformCorrectedTextBox :: SpecialBackend b n => transformCorrectedTextBox str textCol borderCol reflect angle = rotateBy textBoxRotation (reflectIfTrue reflect (coloredTextBox textCol (opaque borderCol) str)) where - reducedAngle = reduceAngleRange (angle ^. turn) + -- If normalizeAngle is slow, the commented out function reduceAngleRange might be faster + reducedAngle = normalizeAngle angle ^. turn textBoxRotation = if (reducedAngle > (1/4)) && (reducedAngle < (3/4)) then 1 / 2 else 0 reflectIfTrue shouldReflect dia = if shouldReflect then reflectX dia else dia