Browse Source

begin initial integration of applyImageToGrid.

master
Craig Oates 6 years ago
parent
commit
7007ed60db
  1. 6
      DeathSocket/Domain.fs
  2. 20
      DeathSocket/GridPainter.fs
  3. 4
      DeathSocket/Validation.fs
  4. 15
      DeathSocketCLI/Commands.fs

6
DeathSocket/Domain.fs

@ -95,3 +95,9 @@
rows: int
///The number of columns the grid will have.
columns: int }
type ImageSpec =
| BrushSpec of BrushSpec
| RGBASpec of RGBASpec
| SkiaSpec of SkiaSpec
| SkiaRGBSpec of SkiaRGBSpec

20
DeathSocket/GridPainter.fs

@ -214,3 +214,23 @@ namespace DeathSocket
| :? FileNotFoundException as ex ->
printfn "File could not be found at %s" ex.Message
}
let applyImageToGrid (spec: ImageSpec) =
async {
try
match spec with
| BrushSpec b ->
validateIO b.originalPath b.savePath |> ignore
drawBrushSpecGrid b
| RGBASpec r ->
validateIO r.originalPath r.savePath |> ignore
drawRGBAGrid r
| SkiaSpec s ->
validateIO s.originalPath s.savePath |> ignore
drawSkiaGrid s
| SkiaRGBSpec sR ->
validateIO sR.originalPath sR.savePath |> ignore
with
| :? FileNotFoundException as ex ->
printfn "File could not be found at %s" ex.Message
}

4
DeathSocket/Validation.fs

@ -14,3 +14,7 @@
| ".png" -> ()
| ".PNG" -> ()
| _ -> invalidArg "savePath" "The file type must be a .jpg or .png file."
let validateIO iPath oPath =
validateFilePath iPath
validateSaveFileType oPath

15
DeathSocketCLI/Commands.fs

@ -8,6 +8,7 @@
open System.IO
open Console.Waterworks
open Console.Waterworks.Attributes
open DeathSocket.Domain
let showEndOfCommandMessage = "[INFO.] Task completed."
@ -121,3 +122,17 @@
|> applySkiaRGBGridAsync
|> Async.Start
showEndOfCommandMessage
let dutest () =
printf "saving image..."
let b =
BrushSpec (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")
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")
sR
|> applyImageToGrid
|> Async.RunSynchronously
showEndOfCommandMessage
Loading…
Cancel
Save