Browse Source

refactor add-default command (applyImageToGrid).

master
Craig Oates 6 years ago
parent
commit
0e88720ae2
  1. 10
      DeathSocket/Domain.fs
  2. 9
      DeathSocket/GridPainter.fs
  3. 11
      DeathSocketCLI/Commands.fs

10
DeathSocket/Domain.fs

@ -96,8 +96,10 @@
///The number of columns the grid will have. ///The number of columns the grid will have.
columns: int } columns: int }
/// Discriminated Union representing the various specification types
/// Death Socket can use to apply a grid to an image.
type ImageSpec = type ImageSpec =
| BrushSpec of BrushSpec | Brush of BrushSpec
| RGBASpec of RGBASpec | RGBA of RGBASpec
| SkiaSpec of SkiaSpec | Skia of SkiaSpec
| SkiaRGBSpec of SkiaRGBSpec | SkiaRGB of SkiaRGBSpec

9
DeathSocket/GridPainter.fs

@ -219,17 +219,18 @@ namespace DeathSocket
async { async {
try try
match spec with match spec with
| BrushSpec b -> | Brush b ->
validateIO b.originalPath b.savePath |> ignore validateIO b.originalPath b.savePath |> ignore
drawBrushSpecGrid b drawBrushSpecGrid b
| RGBASpec r -> | RGBA r ->
validateIO r.originalPath r.savePath |> ignore validateIO r.originalPath r.savePath |> ignore
drawRGBAGrid r drawRGBAGrid r
| SkiaSpec s -> | Skia s ->
validateIO s.originalPath s.savePath |> ignore validateIO s.originalPath s.savePath |> ignore
drawSkiaGrid s drawSkiaGrid s
| SkiaRGBSpec sR -> | SkiaRGB sR ->
validateIO sR.originalPath sR.savePath |> ignore validateIO sR.originalPath sR.savePath |> ignore
drawSkiaRGBGrid sR
with with
| :? FileNotFoundException as ex -> | :? FileNotFoundException as ex ->
printfn "File could not be found at %s" ex.Message printfn "File could not be found at %s" ex.Message

11
DeathSocketCLI/Commands.fs

@ -39,8 +39,9 @@
let ``add-default`` imgPath newPath = let ``add-default`` imgPath newPath =
try try
printfn "[INFO.] Adding default grid to image..." printfn "[INFO.] Adding default grid to image..."
buildDefaultSpec imgPath newPath Brush (buildDefaultSpec imgPath newPath)
|> applyBrushSpecGridAsync |> applyImageToGrid
//|> applyBrushSpecGridAsync
|> Async.Start |> Async.Start
showEndOfCommandMessage showEndOfCommandMessage
with with
@ -126,12 +127,12 @@
let dutest () = let dutest () =
printf "saving image..." printf "saving image..."
let b = let b =
BrushSpec (buildDefaultSpec "C:\Users\craig\Desktop\du-test.jpg" "C:\Users\craig\Desktop\du-test-brush.jpg") Brush (buildDefaultSpec "C:\Users\craig\Desktop\du-test.jpg" "C:\Users\craig\Desktop\du-test-brush.jpg")
// let r = buildRGBASpec... // let r = buildRGBASpec...
let s = let s =
SkiaSpec (buildSkiaSpec "C:\Users\craig\Desktop\du-test.jpg" 5 5 (float32 2) "Red" "C:\Users\craig\Desktop\du-test-skia.jpg") Skia (buildSkiaSpec "C:\Users\craig\Desktop\du-test.jpg" 5 5 (float32 2) "Red" "C:\Users\craig\Desktop\du-test-skia.jpg")
let sR = let sR =
SkiaRGBSpec (buildSkiaRGBSpec "C:\Users\craig\Desktop\du-test.jpg" 5 5 (float32 2) 12 56 121 "C:\Users\craig\Desktop\du-test-skia.jpg") SkiaRGB (buildSkiaRGBSpec "C:\Users\craig\Desktop\du-test.jpg" 5 5 (float32 2) 12 56 121 "C:\Users\craig\Desktop\du-test-skia.jpg")
sR sR
|> applyImageToGrid |> applyImageToGrid
|> Async.RunSynchronously |> Async.RunSynchronously

Loading…
Cancel
Save