Death Socket consists of three projects. They are a .Net Standard 2.0 library, a console program and a Test Centre. The purpose of this repository is to provide a way for people to add grids to images.
https://www.craigoates.net/Software/project/13
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
174 lines
8.2 KiB
174 lines
8.2 KiB
namespace DeathSocket |
|
|
|
/// The domain types used by Death Socket. |
|
[<AutoOpen>] |
|
module Domain = |
|
|
|
open System.Drawing |
|
open SkiaSharp |
|
open System.Threading |
|
|
|
/// This specification is used to note the orignial file's location and |
|
/// the changes the user would like to make to it. (including the save |
|
/// location of the modified version). Use this spec. if you are using |
|
/// System.Drawing. |
|
type BrushSpec = |
|
{ /// 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 of the grid. |
|
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 } |
|
|
|
/// This specification is used to note the orignial file's location and |
|
/// the changes the user would like to make to it (including the save |
|
/// location of the modified version). This specification includes |
|
/// individual RGBA values to describe the grid's colour. Use this |
|
/// spec. if you are using System.Drawing. |
|
type RGBASpec = |
|
{ /// 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 opacity level of the grid. |
|
/// 0 makes it completely see through and 1 makes it solid. |
|
alpha: float |
|
/// The amount of red the grid's line will have. |
|
red: float |
|
/// The amount of green the grid's line will have. |
|
green: float |
|
/// The amount of blue the grid's line will have. |
|
blue: float |
|
/// 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 } |
|
|
|
/// This specification is used to note the orignial file's location and |
|
/// the changes the user would like to make to it (including the save |
|
/// location of the modified version). Use this spec. if you are using |
|
/// the SkiaSharp library. |
|
type SkiaSpec = |
|
{ /// 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 (SkiaSharp) colour used to draw the grid. |
|
skColour: SKColor |
|
/// 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 } |
|
|
|
/// This specification is used to create a gridded image as an SKData |
|
/// buffer. This spec. allows you to use one of the pre-formed |
|
/// SKColors. This makes it quicker and easier to develop your code |
|
/// when compared to SkiaRGBStream. That requires setting individual |
|
/// RGB values. You this spec. if you are using the SkiaSharp library. |
|
type SkiaBufferSpec = |
|
{ /// The location of the image the grid will be applied to |
|
filePath: string |
|
/// The (SkiaSharp) colour used to draw the grid. |
|
skColour: SKColor |
|
/// 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 } |
|
|
|
/// This specification is used to create a gridded image as a SKData |
|
/// buffer. This spec. allows you to specify the colour of the grid |
|
/// using individual RGB values. This gives you greater control of your |
|
/// colour choice than a SkiaStreamSpec, which requires a pre-formed |
|
/// SKColor value. you this spec. if you are using the SkiaSharp |
|
/// library. |
|
type SkiaRGBBufferSpec = |
|
{ /// The location of the image the grid will be applied to |
|
filePath: string |
|
/// The amount of red (RGB) the grid's line will have. |
|
/// (0 = no red, 255 = red turned up to eleven). |
|
red: float32 |
|
/// The amount of green (RGB) the grid's line will have. |
|
/// (0 = no green, 255 = green turned up to eleven). |
|
green: float32 |
|
/// The amount of blue (RGB) the grid's line will have. |
|
/// (0 = no blue, 255 = blue turned up to eleven). |
|
blue: float32 |
|
/// 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 } |
|
|
|
/// This specification is used to note the orignial file's location and |
|
/// the changes the user would like to make to it (including the save |
|
/// location of the modified version). This specification includes |
|
/// individual RGB values to describe the grid's colour. Use this spec. |
|
/// if you are using the SkiaSharp library. |
|
type SkiaRGBSpec = |
|
{ /// 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 amount of red (RGB) the grid's line will have. |
|
/// (0 = no red, 255 = red turned up to eleven). |
|
red: float32 |
|
/// The amount of green (RGB) the grid's line will have. |
|
/// (0 = no green, 255 = green turned up to eleven). |
|
green: float32 |
|
/// The amount of blue (RGB) the grid's line will have. |
|
/// (0 = no blue, 255 = blue turned up to eleven). |
|
blue: float32 |
|
/// 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 } |
|
|
|
/// A Discriminated Union representing the various specification types |
|
/// Death Socket can use to apply a grid to an image. |
|
type ImageSpec = |
|
/// Spec. which uses System.Drawing and its built-in (colour) Brush. |
|
| Brush of BrushSpec |
|
/// Spec. which uses System.Drawing and individual RGBA values. |
|
| RGBA of RGBASpec |
|
/// Spec. which uses SkiaSharp and its built-in SKColors. |
|
| Skia of SkiaSpec |
|
/// Spec. which uses SkiaSharp and individual RGB values. |
|
| SkiaRGB of SkiaRGBSpec |
|
/// Spec. which uses SkiaSharp and its built-in SKColors. |
|
| SkiaBuffer of SkiaBufferSpec |
|
/// Spec. which uses SkiaSharp and individual RGB values. |
|
| SkiaRGBBuffer of SkiaRGBBufferSpec |
|
|
|
/// A Discriminated Union denoting a type of image. The type refers |
|
/// to the graphics library used to read the image file. |
|
/// The graphics library determines how the image is read and |
|
/// manipulated in memory and the functions you can perform on it. |
|
/// When creating an ImageType, pass in the file path of the image |
|
/// as a string. If you are on Windows or using Mono, SystemDrawing is |
|
/// the recommended choice. If you using Xamarin, SkiaSharp is the |
|
/// recommended choice. |
|
type ImageType = |
|
/// Denotes an image created using SkiaSharp |
|
| SkiaSharp of string |
|
/// Denotes an image created using System.Drawing |
|
| SystemDrawing of string |
|
|
|
type internal longestDimension = |
|
| Width |
|
| Height |