Browse Source

begin initial integration of applyImageToGrid.

master
Craig Oates 5 years ago
parent
commit
7007ed60db
  1. 8
      DeathSocket/Domain.fs
  2. 22
      DeathSocket/GridPainter.fs
  3. 6
      DeathSocket/Validation.fs
  4. 17
      DeathSocketCLI/Commands.fs

8
DeathSocket/Domain.fs

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

22
DeathSocket/GridPainter.fs

@ -213,4 +213,24 @@ namespace DeathSocket
with
| :? 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
}

6
DeathSocket/Validation.fs

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

17
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."
@ -91,7 +92,7 @@
let ag imgPath numRows numColumns pWidth colour newPath =
``add-grid`` imgPath numRows numColumns pWidth colour newPath
let lc () =``list-colours`` ()
let lc () = ``list-colours`` ()
(* SkiaSharp Command-Methods -- NOT FOR MASS CONSUMPTION
=======================================================================
@ -120,4 +121,18 @@
buildSkiaRGBSpec imgPath numRows numColumns pWidth r g b newPath
|> 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