From ee2911e07114070bfa3f2427fcab4d8a30c9b634 Mon Sep 17 00:00:00 2001 From: Craig Oates Date: Sun, 21 Oct 2018 11:25:45 +0100 Subject: [PATCH] update comments an remove obsolete functions. --- DeathSocket/Domain.fs | 34 ++------------------------ DeathSocket/GridPainter.fs | 46 ++++++++++++++++++++++++++++++------ DeathSocket/ImageServices.fs | 9 ++++--- 3 files changed, 47 insertions(+), 42 deletions(-) diff --git a/DeathSocket/Domain.fs b/DeathSocket/Domain.fs index f6f7a4a..040a157 100644 --- a/DeathSocket/Domain.fs +++ b/DeathSocket/Domain.fs @@ -5,30 +5,8 @@ module Domain = open System.Drawing - open System - /// - /// The specification used by Death Socket when adding a grid to an image. - /// - [] - type ImageSpec = - { /// The original path of the image which the grid is being added to. - originalPath: string - /// The location of the new gridded image. - savePath: string - /// The (System.Drawing) brush used to draw the grid. This determines the colour. - colour: Brush - /// The thickness of the line on the grid. - penWidth: float32 - /// The number of rows the grid will have. - rows: int - ///The number of columns the grid will have. - columns: int } - - /// /// The specification which uses System.Drawing brush to draw a grid. - /// - // REPLACING IMAGESPEC type BrushSpec = { /// The original path of the image which the grid is being added to. originalPath: string @@ -43,6 +21,8 @@ ///The number of columns the grid will have. columns: int } + /// The specification which uses includes individual RGBA values to + /// draw a grid. type RGBASpec = { originalPath: string savePath: string @@ -52,14 +32,4 @@ blue: float penWidth: float32 rows: int - columns: int } - - type CMYKSpec = - { originalPath: string - savePath: string - cyan: float - magenta: float - yellow: float - key: float32 - rows: int columns: int } \ No newline at end of file diff --git a/DeathSocket/GridPainter.fs b/DeathSocket/GridPainter.fs index 517eb39..60dfa1a 100644 --- a/DeathSocket/GridPainter.fs +++ b/DeathSocket/GridPainter.fs @@ -12,7 +12,7 @@ namespace DeathSocket open ImageServices /// - /// Uses the information included in spec and creates a gridded image. + /// Uses the information included in spec to create a gridded image. /// It then asynchronously saves it. /// Please stick to .bmp, .jpg or .png files. /// The other (image) file types have not been tested. @@ -30,7 +30,6 @@ namespace DeathSocket /// This is because it is locked whilst in this function. /// let applyBrushSpecGridAsync (spec: BrushSpec) = - // The spec is to be changed to Brush Spec. async { try validateFilePath spec.originalPath |> ignore @@ -41,6 +40,23 @@ namespace DeathSocket printfn "File could not be found at %s" ex.Message } + /// + /// Uses the information included in spec to create a gridded image. It + /// then asynchronously saves it. Please stick to .bmp, .jpg or .png + /// files. The other (image) file types have not been tested. + /// + /// + /// The specification used to generate the gridded image. + /// + /// + /// If the file the grid is being applied to cannot be found, + /// a FileNotFoundException will be thrown. + /// + /// let applyRGBAGridAsync (spec: RGBASpec) = async { try @@ -52,15 +68,31 @@ namespace DeathSocket printfn "File could not be found at %s" ex.Message } + /// + /// Creates a Sytsem.Drawing SolidBrush from the individual RGBA values. + /// + /// The red value. + /// The green value. + /// The blue value. + /// The alpha value. + /// + /// Death Socket uses System.Drawing and not System.Media for colours + /// and brushes. + /// let makeSolidBrushFromRGBA r g b a = makeBrushFromRGBA r g b a + /// + /// Creates a System.Drawing SolidBrush from a RGBASpec. + /// + /// + ///The specification which the brush is made from. + /// + /// + /// Death Socket uses System.Drawing and not System.Media for colours + /// and brushes. + /// let makeSolidBrushFromRGBASpec spec = makeBrushFromRGBASpec spec - // let applyCMYKGridAsync -- to be added at a later date. - - // not tested or completed. - //let makeSolidBrushFromCMYK c m y k = "" - /// /// Determines the (Pen) points needed to draw the appropriate number of horizontal lines (I.E. rows). /// Each item in the array includes a start and end co-ordinate (point) for each line. diff --git a/DeathSocket/ImageServices.fs b/DeathSocket/ImageServices.fs index 750e026..8babd60 100644 --- a/DeathSocket/ImageServices.fs +++ b/DeathSocket/ImageServices.fs @@ -3,7 +3,6 @@ open System.Drawing open System.Drawing.Imaging open DeathSocket - open Validation open ColourServices let createHorizontalLines width height rows = @@ -18,8 +17,13 @@ [| Point ((interval * point), 0) Point ((interval * point), height)|]|] + (* Note on Use of Temp File in Functions which Add A Grid Overlay + =========================================================================== + The temp. file is used in the functions below are there to convert images + with indexed pixels. Instead of listig them all, just assume any function + with a "*Spec" type as a parameter will use this "temp" file. *) + let drawBrushSpecGrid (spec: BrushSpec) = - // The temp. file is used as a way to convert images with indexed pixels. use original = Bitmap.FromFile spec.originalPath use temp = new Bitmap(original) use clone = temp.Clone(new Rectangle(0, 0, temp.Width, temp.Height), PixelFormat.Format32bppArgb) @@ -35,7 +39,6 @@ clone.Save (spec.savePath) let drawRGBAGrid (spec: RGBASpec) = - // The temp. file is used as a way to convert images with indexed pixels. use original = Bitmap.FromFile spec.originalPath use temp = new Bitmap(original) use clone = temp.Clone(new Rectangle(0, 0, temp.Width, temp.Height), PixelFormat.Format32bppArgb)