|
|
|
@ -49,30 +49,37 @@ module ImageMaker =
|
|
|
|
|
| _ as ex -> return ex.Message |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
let private penOffset penWidth = int (penWidth / (float32 2)) |
|
|
|
|
|
|
|
|
|
let private createBorderPath penWidth spec = |
|
|
|
|
let penOffset = int (penWidth / (float32 2)) |
|
|
|
|
[|Point (0, penOffset); // Essentially (0, 0) |
|
|
|
|
Point ((spec.width - penOffset), penOffset); |
|
|
|
|
Point ((spec.width - penOffset), (spec.height - penOffset)); |
|
|
|
|
Point (penOffset, (spec.height - penOffset)); |
|
|
|
|
Point (penOffset, 0)|] |
|
|
|
|
|
|
|
|
|
let private drawImageWithBorder (graphics: Graphics) (pen: Pen) spec = |
|
|
|
|
let offset = penOffset penWidth |
|
|
|
|
[|Point (0, offset); // Essentially (0, 0) |
|
|
|
|
Point ((spec.width - offset), offset); |
|
|
|
|
Point ((spec.width - offset), (spec.height - offset)); |
|
|
|
|
Point (offset, (spec.height - offset)); |
|
|
|
|
Point (offset, 0)|] |
|
|
|
|
|
|
|
|
|
let private drawBorder (graphics: Graphics) (pen: Pen) spec = |
|
|
|
|
printfn "[INFO.] Adding border to image..." |
|
|
|
|
let penPath = createBorderPath pen.Width spec |
|
|
|
|
graphics.DrawLines (pen, penPath) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let private drawImageWithFullOverlay graphics pen spec = |
|
|
|
|
let private drawFullOverlay (graphics: Graphics) (pen: Pen) spec = |
|
|
|
|
drawBorder graphics pen spec |
|
|
|
|
printfn "[INFO.] Adding full overlay to image..." |
|
|
|
|
() |
|
|
|
|
let offset = penOffset pen.Width |
|
|
|
|
// Draws line from top-left to bottom-right of square. |
|
|
|
|
graphics.DrawLine (pen, offset, offset, (spec.width - offset), (spec.height - offset)) |
|
|
|
|
// Draws line from top-right to bottom-left of square. |
|
|
|
|
graphics.DrawLine (pen, (spec.width - offset), offset, offset, (spec.height - offset)) |
|
|
|
|
|
|
|
|
|
let private addOverlayToImage graphics spec = |
|
|
|
|
let overlay = spec.overlay.Value |
|
|
|
|
let pen = new Pen (overlay.colour, Width = 10.0f) |
|
|
|
|
match overlay.overlayType with |
|
|
|
|
| Border -> drawImageWithBorder graphics pen spec |
|
|
|
|
| Full -> drawImageWithFullOverlay graphics pen spec |
|
|
|
|
| Border -> drawBorder graphics pen spec |
|
|
|
|
| Full -> drawFullOverlay graphics pen spec |
|
|
|
|
|
|
|
|
|
let private drawImage spec = |
|
|
|
|
let bitmap = new Bitmap (spec.width, spec.height) |
|
|
|
|