diff --git a/DeathSocket/ScratchPad.fsx b/DeathSocket/ScratchPad.fsx index a1741f9..63444cb 100644 --- a/DeathSocket/ScratchPad.fsx +++ b/DeathSocket/ScratchPad.fsx @@ -8,57 +8,35 @@ open System open DeathSocket open Validation open ImageServices -open System.Drawing.Imaging -open System.IO - -// INITIAL IDEA =============================================================== - -// Change the image or its path to suit your purposes. -let img = Bitmap.FromFile (__SOURCE_DIRECTORY__ + "/test-img.jpg") -let graphics = Graphics.FromImage img -let imgWidth = img.Size.Width -let imgHeight = img.Size.Height -(* Keeping it simple here. Going to just create a 2x2 grid. -In other words, I'm just halving the width and the height. *) -let horizontalLine = - let midpoint = imgHeight / 2 - [|Point (0, midpoint); - Point (imgWidth, midpoint)|] -let verticalLine = - let midpoint = imgWidth / 2 - [| Point (midpoint, 0); - Point (midpoint, imgWidth)|] -let pen = new Pen (Brushes.Red, width = (float32 (10)) ) -graphics.DrawLine (pen, verticalLine.[0], verticalLine.[1]) -graphics.DrawLine (pen, horizontalLine.[0], horizontalLine.[1]) -let formSavePath = - let desktop = Environment.GetFolderPath (Environment.SpecialFolder.Desktop) - desktop + "/test-grid.png" // Change this to suit you. -img.Save (formSavePath) -img.Dispose -graphics.Dispose -pen.Dispose - -// DEATH SOCKET TESTING ======================================================= +(* Death Socket Scripts +=============================================================================== +The code in here can be use to create a gridded image without running the CLI. +You can, also, run checks to see what Death Socket is doing when creating +a nerw image. *) let desktop = Environment.GetFolderPath (Environment.SpecialFolder.Desktop) -let testSavePath = desktop + "/1000x1000.png" // Change this to suit you. -let testImagePath = __SOURCE_DIRECTORY__ + "/1000x1000.png" -let testImg = Bitmap.FromFile (__SOURCE_DIRECTORY__ + "/1000x1000.png") +(* You will need to provide the image at the location specified. It will throw +an exception if the file cannnot be found.*) +let validationTest = validateFilePath (desktop + "/test.jpg") -// Throws an exception if no file is found. -let validationTest = validateFilePath testSavePath -let horizontalLines = - createHorizontalLines (testImg.Size.Width) (testImg.Size.Height) 10 -let verticalLines = - createVerticalLines (testImg.Size.Height) 10 +(* These are not needed to create an image. There here for you to check the +start and end points of each pen stroke/path. *) +let horizontalLines = createHorizontalLines 1000 500 10 +let verticalLines = createVerticalLines 300 600 10 + +(* You will need to provide the image and specify its load/save location. +Death Socket assumes either JPEG or PNG files so use other files at your own +risk. Cannot guarantee they will work. Also, either in this spec. can be +changed to suit your needs. *) let spec = - { originalPath = testImagePath - savePath = testSavePath - colour = Brushes.Red - penWidth = float32 (10) + { originalPath = desktop + "/test.jpg" + savePath = desktop + "/grid.png" + colour = Brushes.Chartreuse + penWidth = (float32 1) rows = 10 columns = 10 } + +// Run this when you have finished building the spec. GridPainter.applyGrid spec |> Async.RunSynchronously