From 68e65552c11fe8d5cbd2c0f5a6a2a069aebd7d6d Mon Sep 17 00:00:00 2001 From: Craig Oates Date: Sat, 1 Sep 2018 16:42:56 +0100 Subject: [PATCH] remove hard coding of pen offset in border path array. --- SmoulderingBeachBall/ImageMaker.fs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/SmoulderingBeachBall/ImageMaker.fs b/SmoulderingBeachBall/ImageMaker.fs index 4558a66..f36b951 100644 --- a/SmoulderingBeachBall/ImageMaker.fs +++ b/SmoulderingBeachBall/ImageMaker.fs @@ -49,16 +49,17 @@ module ImageMaker = | _ as ex -> return ex.Message } - let private createBorderPath spec = - [|Point (5, 5); - Point ((spec.width - 5), 5); - Point ((spec.width - 5), (spec.height - 5)); - Point (5, (spec.height - 5)); - Point (5, 0)|] + let private createBorderPath penWidth spec = + let penOffset = int (penWidth / (float32 2)) + [|Point (0, penOffset); // Essentially (0, 0) + Point ((spec.width - penOffset), penOffset); + Point ((spec.width - penOffset), (spec.height - penOffset)); + Point (penOffset, (spec.height - penOffset)); + Point (penOffset, 0)|] let private drawImageWithBorder (graphics: Graphics) (pen: Pen) spec = printfn "[INFO.] Adding border to image..." - let penPath = createBorderPath spec + let penPath = createBorderPath pen.Width spec graphics.DrawLines (pen, penPath)