Browse Source

add working P.O.C. in scratch pad and test image to library.

master
Craig Oates 6 years ago
parent
commit
2fe9bec8c0
  1. 3
      DeathSocket/DeathSocket.fsproj
  2. 32
      DeathSocket/ScratchPad.fsx
  3. BIN
      DeathSocket/test-img.jpg

3
DeathSocket/DeathSocket.fsproj

@ -5,10 +5,9 @@
</PropertyGroup>
<ItemGroup>
<Content Include="test-img.jpg" />
<Compile Include="GridPainter.fs" />
<None Include="ScratchPad.fsx" />
</ItemGroup>
<ItemGroup />
</Project>

32
DeathSocket/ScratchPad.fsx

@ -1,5 +1,35 @@
#load "GridPainter.fs"
open DeathSocket
open System.Drawing
open System
open System.Drawing.Imaging
// Initial Idea ==============================================================
// Change the image or its path to suit your purposes.
let img = Bitmap.FromFile (__SOURCE_DIRECTORY__ + "/test-img.jpg")
let graphics = Graphics.FromImage img
let imgWidth = img.Size.Width
let imgHeight = img.Size.Height
(* Keeping it simple here.
Going to just create a 2x2 grid.
In other words, I'm just halving the width and the height. *)
let verticalLine =
let midpoint = imgHeight / 2
[|Point (0, midpoint);
Point (imgWidth, midpoint)|]
let horizontalLine =
let midpoint = imgWidth / 2
[| Point (midpoint, 0);
Point (midpoint, imgWidth)|]
let pen = new Pen (Brushes.Red, width = (float32 (10)) )
graphics.DrawLine (pen, verticalLine.[0], verticalLine.[1])
graphics.DrawLine (pen, horizontalLine.[0], horizontalLine.[1])
let desktop = Environment.GetFolderPath (Environment.SpecialFolder.Desktop)
let savePath = desktop + "/test-grid.png" // Change this to suit you.
img.Save (savePath)
img.Dispose
graphics.Dispose
pen.Dispose
// code to go here...

BIN
DeathSocket/test-img.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 MiB

Loading…
Cancel
Save