|
|
|
@ -21,6 +21,7 @@
|
|
|
|
|
open System.Reflection |
|
|
|
|
open System.IO |
|
|
|
|
open DeathSocket.Domain |
|
|
|
|
open SkiaSharp |
|
|
|
|
|
|
|
|
|
let rand = Random () |
|
|
|
|
|
|
|
|
@ -42,7 +43,18 @@
|
|
|
|
|
|
|
|
|
|
let randomBrush () = |
|
|
|
|
let item = allColours.[rand.Next(allColours.Length)] |
|
|
|
|
item.GetValue(null, null) |
|
|
|
|
item.GetValue (null, null) |
|
|
|
|
|
|
|
|
|
let allSKColours = |
|
|
|
|
let properties = |
|
|
|
|
typeof<SKColors>.GetFields |
|
|
|
|
(BindingFlags.Static ||| BindingFlags.Public) |
|
|
|
|
seq {for prop in properties -> prop} |
|
|
|
|
|> Seq.toArray |
|
|
|
|
|
|
|
|
|
let randomSKColour () = |
|
|
|
|
let item = allSKColours.[rand.Next(allSKColours.Length)] |
|
|
|
|
item.GetValue (null) :?> SKColor |
|
|
|
|
|
|
|
|
|
(* Max. value is arbitrary (change for performance). |
|
|
|
|
Min. value is to stop divide by zero exceptions. |
|
|
|
@ -93,6 +105,7 @@
|
|
|
|
|
open DeathSocket.GridPainter |
|
|
|
|
open TestingHelpers |
|
|
|
|
open System.IO |
|
|
|
|
open SkiaSharp |
|
|
|
|
|
|
|
|
|
(* With regards to the "saving images" tests, you should end up with |
|
|
|
|
one image left over in the SavingTestArea folder. Comment out the |
|
|
|
@ -104,14 +117,13 @@
|
|
|
|
|
resetSavingTestArea () |
|
|
|
|
let oPath = generateLoadPath () |
|
|
|
|
let sPath = generateSavePath oPath |
|
|
|
|
let (spec: BrushSpec) = |
|
|
|
|
{ originalPath = oPath |
|
|
|
|
savePath = sPath |
|
|
|
|
colour = randomBrush () :?> Brush |
|
|
|
|
penWidth = float32 (newPenWidth()) |
|
|
|
|
rows = 10 |
|
|
|
|
columns = 10 } |
|
|
|
|
applyBrushSpecGridAsync spec |
|
|
|
|
{ originalPath = oPath |
|
|
|
|
savePath = sPath |
|
|
|
|
colour = randomBrush () :?> Brush |
|
|
|
|
penWidth = float32 (newPenWidth()) |
|
|
|
|
rows = 10 |
|
|
|
|
columns = 10 } |
|
|
|
|
|> applyBrushSpecGridAsync |
|
|
|
|
|> Async.RunSynchronously |
|
|
|
|
(File.Exists sPath) = true |
|
|
|
|
|
|
|
|
@ -120,17 +132,16 @@
|
|
|
|
|
resetSavingTestArea () |
|
|
|
|
let oPath = generateLoadPath () |
|
|
|
|
let sPath = generateSavePath oPath |
|
|
|
|
let (spec: RGBASpec) = |
|
|
|
|
{ originalPath = oPath |
|
|
|
|
savePath = sPath |
|
|
|
|
alpha = float (newRGBANum ()) |
|
|
|
|
red = float (newRGBANum ()) |
|
|
|
|
green = float (newRGBANum ()) |
|
|
|
|
blue = float (newRGBANum ()) |
|
|
|
|
penWidth = float32 (newPenWidth()) |
|
|
|
|
rows = 10 |
|
|
|
|
columns = 10 } |
|
|
|
|
applyRGBAGridAsync spec |
|
|
|
|
{ originalPath = oPath |
|
|
|
|
savePath = sPath |
|
|
|
|
alpha = float (newRGBANum ()) |
|
|
|
|
red = float (newRGBANum ()) |
|
|
|
|
green = float (newRGBANum ()) |
|
|
|
|
blue = float (newRGBANum ()) |
|
|
|
|
penWidth = float32 (newPenWidth()) |
|
|
|
|
rows = 10 |
|
|
|
|
columns = 10 } |
|
|
|
|
|> applyRGBAGridAsync |
|
|
|
|
|> Async.RunSynchronously |
|
|
|
|
(File.Exists sPath) = true |
|
|
|
|
|
|
|
|
@ -165,6 +176,38 @@
|
|
|
|
|
let result = determineVerticalLines (newNum()) (newNum()) (newNum()) |
|
|
|
|
result.Length > 0 |
|
|
|
|
|
|
|
|
|
[<Property>] |
|
|
|
|
let ``Can apply grid to image and save it using SkiaSpec`` () = |
|
|
|
|
resetSavingTestArea() |
|
|
|
|
let oPath = generateLoadPath () |
|
|
|
|
let sPath = generateSavePath oPath |
|
|
|
|
{ originalPath = oPath |
|
|
|
|
savePath= sPath |
|
|
|
|
skColour = randomSKColour () |
|
|
|
|
penWidth = float32 (newPenWidth()) |
|
|
|
|
rows = newNum () |
|
|
|
|
columns = newNum () } |
|
|
|
|
|> applySkiaGridAsync |
|
|
|
|
|> Async.RunSynchronously |
|
|
|
|
(File.Exists sPath) = true |
|
|
|
|
|
|
|
|
|
[<Property>] |
|
|
|
|
let ``Can apply grid to image and save it using SkiaRGBSpec`` () = |
|
|
|
|
resetSavingTestArea() |
|
|
|
|
let oPath = generateLoadPath () |
|
|
|
|
let sPath = generateSavePath oPath |
|
|
|
|
{ originalPath = oPath |
|
|
|
|
savePath= sPath |
|
|
|
|
red = float32 (newRGBANum ()) |
|
|
|
|
green = float32 (newRGBANum ()) |
|
|
|
|
blue = float32 (newRGBANum ()) |
|
|
|
|
penWidth = float32 (newPenWidth()) |
|
|
|
|
rows = newNum () |
|
|
|
|
columns = newNum () } |
|
|
|
|
|> applySkiaRGBGridAsync |
|
|
|
|
|> Async.RunSynchronously |
|
|
|
|
(File.Exists sPath) = true |
|
|
|
|
|
|
|
|
|
[<Property>] |
|
|
|
|
let ``Can return a collection of SKPoints which represent a grids horizontal lines`` () = |
|
|
|
|
let result = determineSKHorizontalLines (newNum()) (newNum()) (newNum()) |
|
|
|
|