Browse Source

rename colour service functions and begin writing RGBa convertion test.

master
Craig Oates 6 years ago
parent
commit
c58b8f0df4
  1. 15
      DeathSocket/ColourServices.fs
  2. 8
      DeathSocket/GridPainter.fs
  3. 2
      DeathSocket/ImageServices.fs
  4. 16
      TestCentre/LibraryTests.fs

15
DeathSocket/ColourServices.fs

@ -1,14 +1,19 @@
module ColourServices module internal ColourServices
open System.Drawing open System.Drawing
open DeathSocket.Domain open DeathSocket.Domain
// not tested // not tested
let convertRGBAToBrush (spec: RGBASpec) = let makeBrushFromRGBASpec (spec: RGBASpec) =
let a = int spec.alpha let a = int spec.alpha
let r = int spec.red let r = int spec.red
let g = int spec.green let g = int spec.green
let b = int spec.blue let b = int spec.blue
let colour = Color.FromArgb (a, r, g, b) let colour = Color.FromArgb (a, r, g, b)
new SolidBrush(colour) new SolidBrush (colour)
// not tested
let makeBrushFromRGBA r g b a =
let colour = Color.FromArgb (a, r, g, b)
new SolidBrush (colour)

8
DeathSocket/GridPainter.fs

@ -1,6 +1,7 @@
namespace DeathSocket namespace DeathSocket
open System.IO open System.IO
open ColourServices
/// Provides functions which help draw gridded overlays onto images. /// Provides functions which help draw gridded overlays onto images.
/// Grid Painter, and all of Death Socket, uses the System.Drawing brushes/colours. /// Grid Painter, and all of Death Socket, uses the System.Drawing brushes/colours.
@ -54,6 +55,13 @@ namespace DeathSocket
// let applyCMYKGridAsync -- to be added at a later date. // let applyCMYKGridAsync -- to be added at a later date.
// not tested.
let makeSolidBrushFromRGBA r g b a = makeBrushFromRGBA r g b a
// not tested or completed.
let makeSolidBrushFromCMYK c m y k =
""
/// <summary> /// <summary>
/// Determines the (Pen) points needed to draw the appropriate number of horizontal lines (I.E. rows). /// 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. /// Each item in the array includes a start and end co-ordinate (point) for each line.

2
DeathSocket/ImageServices.fs

@ -58,7 +58,7 @@
use temp = new Bitmap(original) use temp = new Bitmap(original)
use clone = temp.Clone(new Rectangle(0, 0, temp.Width, temp.Height), PixelFormat.Format32bppArgb) use clone = temp.Clone(new Rectangle(0, 0, temp.Width, temp.Height), PixelFormat.Format32bppArgb)
use graphics = Graphics.FromImage(clone) use graphics = Graphics.FromImage(clone)
use pen = new Pen ((convertRGBAToBrush spec), width = spec.penWidth) use pen = new Pen ((makeBrushFromRGBASpec spec), width = spec.penWidth)
graphics.DrawImage(original,new Rectangle(0, 0, clone.Width, clone.Height)) graphics.DrawImage(original,new Rectangle(0, 0, clone.Width, clone.Height))
let horizontalLines = let horizontalLines =
createHorizontalLines (clone.Size.Width) (clone.Size.Height) (spec.rows) createHorizontalLines (clone.Size.Width) (clone.Size.Height) (spec.rows)

16
TestCentre/LibraryTests.fs

@ -23,7 +23,6 @@
let rand = Random () let rand = Random ()
(* These are duplicates from ConsoleTests.fs (both of them). See point (* These are duplicates from ConsoleTests.fs (both of them). See point
about helpers. Tests for checking these locations can be found in about helpers. Tests for checking these locations can be found in
ConsoleTests.fs. *) ConsoleTests.fs. *)
@ -46,6 +45,8 @@
Intended for horizontal and vertical line tests. *) Intended for horizontal and vertical line tests. *)
let newNum () = rand.Next(1, 1000) let newNum () = rand.Next(1, 1000)
let newRGBANum () = rand.Next (255)
let imagesInLoadingTestArea = let imagesInLoadingTestArea =
Directory.GetFileSystemEntries (loadLocation, "*.png") Directory.GetFileSystemEntries (loadLocation, "*.png")
@ -97,6 +98,15 @@
|> Async.RunSynchronously |> Async.RunSynchronously
(File.Exists sPath) = true (File.Exists sPath) = true
[<Property>]
// need to write a test which tests the colour is the same once coverted.
let ``Can make a solid brush from RGBA values`` () =
let brush =
makeSolidBrushFromRGBA (newRGBANum ()) (newRGBANum ()) (newRGBANum ()) (newRGBANum ())
let b = brush :? SolidBrush
b = true
[<Property>] [<Property>]
let ``Can return a collection of points which represent a grids horizontal lines`` () = let ``Can return a collection of points which represent a grids horizontal lines`` () =
let result = determineHorizontalLines (newNum()) (newNum()) (newNum()) let result = determineHorizontalLines (newNum()) (newNum()) (newNum())
@ -115,7 +125,7 @@
open System open System
open System.IO open System.IO
(* This test is a precaution (a test for the tests if you will...). (* This test is a pre-test test (a test for the tests if you will...).
It is here to make sure the property test has what it needs to run. It is here to make sure the property test has what it needs to run.
If the property test fails, here is a good place to start. If the property test fails, here is a good place to start.
See script.fs (in Test Centre) for information on populating the See script.fs (in Test Centre) for information on populating the
@ -126,7 +136,7 @@
let imagesAreThere = if length < 100 then false else true let imagesAreThere = if length < 100 then false else true
Assert.True imagesAreThere Assert.True imagesAreThere
(* This test is a precaution. If the property tests fails, here is a (* This test is a pre-test test. If the property tests fails, here is a
good place to start. The easiest way to get this test to pass is to good place to start. The easiest way to get this test to pass is to
create a folder called "SavingTestArea" in this projects folder create a folder called "SavingTestArea" in this projects folder
(at the root). You can, also, see script.fs (in Test Centre) for (at the root). You can, also, see script.fs (in Test Centre) for

Loading…
Cancel
Save