@ -4,18 +4,51 @@ namespace DeathSocket
open C o l o u r S e r v i c e s
/// Provides functions which help draw gridded overlays onto i m a g e s .
/// Grid Painter, and all of Death Socket, uses the System.Drawing b r u s h e s / c o l o u r s .
/// If you are using System.Media brushes and colour, you will need to convert t h e m .
/// Death Socket, uses System.Drawing's brushes and c o l o u r s .
/// If you are using System.Media brushes and colour, you will need t o
/// convert them. Death Socket, also, uses SkiaSharp for cross p l a t f o r m
/// functionality. If you are using Death Socket on Windows Desktop, u s e
/// functions which do not include "Skia" in their name. If you are u s i n g
/// Death Socket in a Xamarin/UWP project you should use the S k i a S h a r p
/// f u n c t i o n s .
module GridPainter =
open V a l i d a t i o n
open I m a g e S e r v i c e s
// System.Drawing F u n c t i o n s
// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
/// < s u m m a r y >
/// Determines the (Pen) points needed to draw the appropriate n u m b e r
/// of horizontal lines (I.E. rows). Each item in the array includes a
/// start and end co-ordinate (point) for each l i n e .
/// Use this function when targeting . N e t / M o n o ) .
/// < / s u m m a r y >
/// <param name="width">The width of the i m a g e . < / p a r a m >
/// <param name="height">The height of the i m a g e . < / p a r a m >
/// <param name="rows">The number of rows the grid should h a v e . < / p a r a m >
/// <remarks>You will probably only need these when dealing with G U I ' s . < / r e m a r k s >
let determineHorizontalLines (width: int) (height: int) (rows: int) =
createHorizontalLines width height r o w s
/// < s u m m a r y >
/// Determines the (Pen) points needed to draw the appropriate n u m b e r
/// of vertical lines (I.E. columns). Each item in the array includes a
/// start and end co-ordinate (point) for each l i n e .
/// Use this function when targeting Windows Desktop (or M o n o ) .
/// < / s u m m a r y >
/// <param name="width">The width of the i m a g e . < / p a r a m >
/// <param name="height">The height of the i m a g e . < / p a r a m >
/// <param name="columns">The number of columns the grid should h a v e . < / p a r a m >
/// <remarks>You will probably only need these when dealing with G U I ' s . < / r e m a r k s >
let determineVerticalLines (width: int) (height: int) (columns: int) =
createVerticalLines width height c o l u m n s
/// < s u m m a r y >
/// Uses the information included in spec to create a gridded i m a g e .
/// It then asynchronously saves i t .
/// Please stick to . bmp, . jpg or . png f i l e s .
/// The other (image) file types have not been t e s t e d .
/// It then asynchronously saves it. Uses . jpg or . png formats o n l y .
/// Use this function when targeting . N e t / M o n o ) .
/// < / s u m m a r y >
/// <param n a m e = " s p e c " >
/// The specification used to generate the new gridded i m a g e
@ -33,7 +66,7 @@ namespace DeathSocket
async {
t r y
validateFilePath spec.originalPath |> i g n o r e
validatFileType spec.savePath |> i g n o r e
validateSave FileType spec.savePath |> i g n o r e
drawBrushSpecGrid spec |> i g n o r e
w i t h
| :? FileNotFoundException as ex - >
@ -42,8 +75,8 @@ namespace DeathSocket
/// < s u m m a r y >
/// Uses the information included in spec to create a gridded image. I t
/// then asynchronously saves it. Please stick to . bmp, . jpg or . p n g
/// files. The other (image) file types have not been t e s t e d .
/// then asynchronously saves it. Uses . jpg or . png formats o n l y .
/// Use this function when targeting . N e t / M o n o ) .
/// < / s u m m a r y >
/// <param n a m e = " s p e c " >
/// The specification used to generate the gridded i m a g e .
@ -61,7 +94,7 @@ namespace DeathSocket
async {
t r y
validateFilePath spec.originalPath |> i g n o r e
validatFileType spec.savePath |> i g n o r e
validateSave FileType spec.savePath |> i g n o r e
drawRGBAGrid s p e c
w i t h
| :? FileNotFoundException as ex - >
@ -70,6 +103,7 @@ namespace DeathSocket
/// < s u m m a r y >
/// Creates a Sytsem.Drawing SolidBrush from the individual RGBA v a l u e s .
/// Use this function when targeting . N e t / M o n o ) .
/// < / s u m m a r y >
/// <param name="r">The red v a l u e . < / p a r a m >
/// <param name="g">The green v a l u e . < / p a r a m >
@ -79,10 +113,12 @@ namespace DeathSocket
/// Death Socket uses System.Drawing and not System.Media for c o l o u r s
/// and b r u s h e s .
/// < / r e m a r k s >
let makeSolidBrushFromRGBA r g b a = makeBrushFromRGBA r g b a
let makeSolidBrushFromRGBA (r: int) (g: int) (b:int) (a: int) =
makeBrushFromRGBA r g b a
/// < s u m m a r y >
/// Creates a System.Drawing SolidBrush from a R G B A S p e c .
/// Use this function when targeting . N e t / M o n o ) .
/// < / s u m m a r y >
/// <param n a m e = " s p e c " >
///The specification which the brush is made f r o m .
@ -91,26 +127,90 @@ namespace DeathSocket
/// Death Socket uses System.Drawing and not System.Media for c o l o u r s
/// and b r u s h e s .
/// < / r e m a r k s >
let makeSolidBrushFromRGBASpec spec = makeBrushFromRGBASpec s p e c
let makeSolidBrushFromRGBASpec (spec: RGBASpec) =
makeBrushFromRGBASpec s p e c
// SkiaSharp F u n c t i o n s
// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
/// < s u m m a r y >
/// 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 l i n e .
/// Determines the (SKPoints) points needed to draw the a p p r o p r i a t e
/// number of horizontal lines (I.E. rows). Each item in the a r r a y
/// included a start and end co-ordinate (SKPoint) for each l i n e .
/// Use this function when targeting Xamarin/UWP/.Net Core ( S k i a S h a r p ) .
/// < / s u m m a r y >
/// <param name="width">The width of the i m a g e . < / p a r a m >
/// <param name="height">The height of the i m a g e . < / p a r a m >
/// <param name="rows">The number of rows the grid should h a v e . < / p a r a m >
/// <remarks>You will probably only need these when dealing with G U I ' s . < / r e m a r k s >
let determineHorizontalLines width height rows =
createHorizontalLines width height r o w s
/// <remarks>This function is part of the SkiaSharp functions p r o v i d e d
/// by Death S o c k e t . < / r e m a r k s >
let determineSKHorizontalLines (width: int) (height: int) (rows: int) =
createSKHorizontalLines width height r o w s
/// < s u m m a r y >
/// Determines the (Pen) points needed to draw the appropriate number of vertical lines (I.E. c o l u m n s ) .
/// Each item in the array includes a start and end co-ordinate (point) for each l i n e .
/// Determines the (SKPoints) points needed to draw the a p p r o p r i a t e
/// number of vertical lines (I.E. columns). Each item in the a r r a y
/// included a start and end co-ordinate (SKPoint) for each l i n e .
/// Use this function when targeting Xamarin/UWP/.Net Core ( S k i a S h a r p ) .
/// < / s u m m a r y >
/// <param name="width">The width of the i m a g e . < / p a r a m >
/// <param name="height">The height of the i m a g e . < / p a r a m >
/// <param name="columns">The number of columns the grid should h a v e . < / p a r a m >
/// <remarks>You will probably only need these when dealing with G U I ' s . < / r e m a r k s >
let determineVerticalLines width height columns =
createVerticalLines width height c o l u m n s
/// <param name="columns">The number of columns the grid should h a v e .
/// < / p a r a m >
/// <remarks>This function is part of the SkiaSharp functions p r o v i d e d
/// by Death S o c k e t . < / r e m a r k s >
let determineSKVerticalLines (width: int) (height: int) (columns: int) =
createSKVerticalLines width height c o l u m n s
/// < s u m m a r y >
/// Uses the information included in spec to create a gridded i m a g e .
/// It then asynchronously saves it. Uses . jpg or . png formats o n l y .
/// Use this function when targeting Xamarin/UWP/.Net C o r e .
/// < / s u m m a r y >
/// <param n a m e = " s p e c " >
/// Used to note the orignial file's location and t h e
/// changes the user would like to make to it (including the s a v e
/// location of the modified v e r s i o n ) .
/// < / p a r a m >
/// < r e m a r k s >
/// Make sure the image, which is having the overlay added to i t ,
/// is not in use or needed by another p r o g r a m / p r o c e s s .
/// This is because it is locked whilst in this f u n c t i o n .
/// < / r e m a r k s >
let applySkiaGridAsync (spec: SkiaSpec) =
async {
t r y
validateFilePath spec.originalPath |> i g n o r e
validateSaveFileType spec.savePath |> i g n o r e
drawSkiaGrid s p e c
w i t h
| :? FileNotFoundException as ex - >
printfn "File could not be found at %s" e x . M e s s a g e
}
/// < s u m m a r y >
/// Uses the information included in spec to create a gridded i m a g e .
/// It then asynchronously saves it. Uses . jpg or . png formats o n l y .
/// Use this function when targeting Xamarin/UWP/.Net C o r e .
/// < / s u m m a r y >
/// <param n a m e = " s p e c " >
/// Used to note the orignial file's location and t h e
/// changes the user would like to make to it (including the s a v e
/// location of the modified v e r s i o n ) .
/// < / p a r a m >
/// < r e m a r k s >
/// Make sure the image, which is having the overlay added to i t ,
/// is not in use or needed by another p r o g r a m / p r o c e s s .
/// This is because it is locked whilst in this f u n c t i o n .
/// < / r e m a r k s >
let applySkiaRGBGridAsync (spec: SkiaRGBSpec) =
async {
t r y
validateFilePath spec.originalPath |> i g n o r e
validateSaveFileType spec.savePath |> i g n o r e
drawSkiaRGBGrid s p e c
w i t h
| :? FileNotFoundException as ex - >
printfn "File could not be found at %s" e x . M e s s a g e
}