Browse Source

refactor add-default command (applyImageToGrid).

master
Craig Oates 5 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.
columns: int }
/// Discriminated Union representing the various specification types
/// Death Socket can use to apply a grid to an image.
type ImageSpec =
| BrushSpec of BrushSpec
| RGBASpec of RGBASpec
| SkiaSpec of SkiaSpec
| SkiaRGBSpec of SkiaRGBSpec
| Brush of BrushSpec
| RGBA of RGBASpec
| Skia of SkiaSpec
| SkiaRGB of SkiaRGBSpec

9
DeathSocket/GridPainter.fs

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

11
DeathSocketCLI/Commands.fs

@ -39,8 +39,9 @@
let ``add-default`` imgPath newPath =
try
printfn "[INFO.] Adding default grid to image..."
buildDefaultSpec imgPath newPath
|> applyBrushSpecGridAsync
Brush (buildDefaultSpec imgPath newPath)
|> applyImageToGrid
//|> applyBrushSpecGridAsync
|> Async.Start
showEndOfCommandMessage
with
@ -126,12 +127,12 @@
let dutest () =
printf "saving image..."
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 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 =
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
|> applyImageToGrid
|> Async.RunSynchronously

Loading…
Cancel
Save