Craig Oates
6 years ago
5 changed files with 26 additions and 24 deletions
@ -1,11 +1,16 @@
|
||||
namespace DeathSocket |
||||
|
||||
open System.IO |
||||
|
||||
module GridPainter = |
||||
|
||||
open Validation |
||||
open ImageServices |
||||
|
||||
let applyGridToImage spec = |
||||
validateFilePath |> ignore |
||||
drawGrid spec |
||||
0 |
||||
let applyGrid spec = |
||||
try |
||||
validateFilePath |> ignore |
||||
drawGrid spec |> ignore |
||||
with |
||||
| :? FileNotFoundException as ex -> printfn"%s" ex.Message |
||||
|
@ -1,34 +1,32 @@
|
||||
module internal ImageServices |
||||
|
||||
open System.Drawing |
||||
open DeathSocket.Domain |
||||
open System.Drawing.Imaging |
||||
open System.Drawing |
||||
open System.Drawing.Imaging |
||||
open DeathSocket |
||||
|
||||
let createHorizontalLines width height columns = |
||||
let interval = width / columns |
||||
[| for point in 1 .. columns -> |
||||
let createHorizontalLines width height rows = |
||||
let interval = width / rows |
||||
[| for point in 1 .. (rows - 1) -> |
||||
[|Point (0, (interval * point)) |
||||
Point (height, (interval * point) )|]|] |
||||
|
||||
let createVerticalLines width height columns = |
||||
let createVerticalLines height columns = |
||||
let interval = height / columns |
||||
[| for point in 1 .. columns -> |
||||
[| for point in 1 .. (columns - 1) -> |
||||
[| Point ((interval * point), 0) |
||||
Point ((interval * point), height)|]|] |
||||
|
||||
let drawGrid spec = |
||||
let img = Bitmap.FromFile spec.filePath |
||||
let img = Bitmap.FromFile spec.originalPath |
||||
let graphics = Graphics.FromImage img |
||||
let pen = new Pen (spec.colour, width = spec.penWidth) |
||||
let horizontalLines = |
||||
createHorizontalLines (img.Size.Width) (img.Size.Height) (spec.columns) |
||||
let verticalLines = |
||||
createVerticalLines (img.Size.Width) (img.Size.Height) (spec.columns) |
||||
let verticalLines = createVerticalLines (img.Size.Height) (spec.columns) |
||||
for line in horizontalLines do graphics.DrawLines (pen, line) |
||||
for line in verticalLines do graphics.DrawLines (pen, line) |
||||
img.Save (spec.savePath, ImageFormat.Png) |
||||
img.Dispose () |
||||
graphics.Dispose () |
||||
pen.Dispose () |
||||
0 |
||||
|
||||
() |
Loading…
Reference in new issue