Browse Source

refactor draw-image to parse the overlay param's.

master
Craig Oates 6 years ago
parent
commit
220a6c7248
  1. 28
      SmoulderingBeachBallCLI/ConsoleCommands.fs
  2. 38
      SmoulderingBeachBallCLI/Validation.fs

28
SmoulderingBeachBallCLI/ConsoleCommands.fs

@ -12,13 +12,6 @@
let exit () = Environment.Exit (Environment.ExitCode) let exit () = Environment.Exit (Environment.ExitCode)
(* possibe function -- save to desktop and almost set to "default"?
might be to goto for most command calls...
let `draw-basic` imgWidth imgHeight =
buildSimpleSpec
|> makeImage
*)
let ``draw-default`` imgWidth imgHeight = let ``draw-default`` imgWidth imgHeight =
try try
buildDefaultSpec imgWidth imgHeight buildDefaultSpec imgWidth imgHeight
@ -29,9 +22,9 @@
| :? ArgumentException as ex -> ex.Message | :? ArgumentException as ex -> ex.Message
| _ as ex -> ex.Message | _ as ex -> ex.Message
let ``draw-image`` imgWidth imgHeight mainColour path = let ``draw-image`` imgWidth imgHeight mainColour oColour oType path =
try try
buildBasicSpec imgWidth imgHeight mainColour path buildSpec imgWidth imgHeight mainColour oColour oType path
|> makeImage |> makeImage
|> Async.RunSynchronously |> Async.RunSynchronously
showEndOfCommandMessage showEndOfCommandMessage
@ -39,23 +32,6 @@
| :? ArgumentException as ex -> ex.Message | :? ArgumentException as ex -> ex.Message
| _ as ex -> ex.Message | _ as ex -> ex.Message
let ``draw-borderedImage`` imgWidth imgHeight mainColour oColour oType path =
try
buildOverlaySpec imgWidth imgHeight mainColour oColour oType path
|> makeImage
|> Async.RunSynchronously
showEndOfCommandMessage
with
| :? ArgumentException as ex -> ex.Message
| _ as ex -> ex.Message
let ``draw-overlayedImage`` () =
try
showEndOfCommandMessage
with
| :? ArgumentException as ex -> ex.Message
| _ as ex -> ex.Message
let ``list-colours`` () = let ``list-colours`` () =
printfn "[INFO.] Listing available colours..." printfn "[INFO.] Listing available colours..."
for item in colourList do for item in colourList do

38
SmoulderingBeachBallCLI/Validation.fs

@ -52,15 +52,6 @@
} }
spec spec
let buildBasicSpec iWidth iHeight mainColour path =
let spec =
{ width = iWidth;
height = iHeight;
colour = parseColour mainColour
filePath = parsePath path
overlay = None }
spec
let parseOverlay (oType: string) = let parseOverlay (oType: string) =
match oType.ToLower() with match oType.ToLower() with
| "border" -> Border | "border" -> Border
@ -69,17 +60,26 @@
| "f" -> Full | "f" -> Full
| _ -> invalidArg "Overlay Type" "The overlay type must be either 'border' or 'full'." | _ -> invalidArg "Overlay Type" "The overlay type must be either 'border' or 'full'."
// Need to think about building the two spec's seperately and bring them together in one place. let buildOverlaySpec oColour (oType: string) =
// I'm repeating myself a little too much here.
// Also, need to adjust pen width to match the image size (in library proj.).
let buildOverlaySpec iWidth iHeight mainColour oColour oType path =
let oSpec = let oSpec =
{ colour = parseColour oColour; { colour = parseColour oColour;
overlayType = parseOverlay oType } overlayType = parseOverlay oType }
oSpec
let buildMainSpec iWidth iHeight mainColour path oSpec =
let spec = let spec =
{width = iWidth; { width = iWidth;
height = iHeight; height = iHeight;
colour = parseColour mainColour; colour = parseColour mainColour
filePath = parsePath path; filePath = parsePath path
overlay = Some oSpec } overlay = oSpec }
spec spec
let buildSpec iWidth iHeight mainColour oColour (oType: string) path =
let spec =
match oType.ToLower() with
| "none" | "n" -> buildMainSpec iWidth iHeight mainColour path option.None
| _ ->
let oSpec = buildOverlaySpec oColour oType
buildMainSpec iWidth iHeight mainColour path (Some oSpec)
spec

Loading…
Cancel
Save