Browse Source

update NuGets and add initial code for 0.7 features.

master
Craig Oates 5 years ago
parent
commit
f06451572f
  1. 2
      DeathSocket/DeathSocket.fsproj
  2. 10
      DeathSocket/Domain.fs
  3. 30
      DeathSocket/GridPainter.fs
  4. 12
      DeathSocket/ImageServices.fs
  5. 26
      DeathSocket/ScratchPad.fsx
  6. 6
      DeathSocketCLI/DeathSocketCLI.fsproj
  7. 2
      DeathSocketCLI/packages.config
  8. 6
      TestCentre/LibraryTests.fs
  9. 6
      TestCentre/TestCentre.fsproj
  10. 2
      TestCentre/packages.config

2
DeathSocket/DeathSocket.fsproj

@ -30,7 +30,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="SkiaSharp" Version="1.60.3" /> <PackageReference Include="SkiaSharp" Version="1.68.0" />
<PackageReference Include="System.Drawing.Common" Version="4.5.1" /> <PackageReference Include="System.Drawing.Common" Version="4.5.1" />
</ItemGroup> </ItemGroup>

10
DeathSocket/Domain.fs

@ -6,6 +6,7 @@
open System.Drawing open System.Drawing
open SkiaSharp open SkiaSharp
open System.Threading
/// The specification used to note the orignial file's location and the /// The specification used to note the orignial file's location and the
/// changes the user would like to make to it. (including the save /// changes the user would like to make to it. (including the save
@ -102,4 +103,11 @@
| Brush of BrushSpec | Brush of BrushSpec
| RGBA of RGBASpec | RGBA of RGBASpec
| Skia of SkiaSpec | Skia of SkiaSpec
| SkiaRGB of SkiaRGBSpec | SkiaRGB of SkiaRGBSpec
/// Discriminated Union representing the graphics libraries used by
/// Desth Socket. Useful for selecting which one you want to use.
/// System.Drawing for using Windows/Mono and SkiaSharp for Xamarin.
type ImageType =
| SkiaSharp of string
| SystemDrawing of string

30
DeathSocket/GridPainter.fs

@ -58,16 +58,16 @@ namespace DeathSocket
// NOT TESTED // NOT TESTED
/// <summary> /// <summary>
/// Takes an image and determines the current scale it is viewed at /// Determines the current scale an image is viewed at (E.G. scaled
/// (E.G. scaled preview in image viewer). The (pen) line thickness is /// preview in image viewer). The (pen) line thickness is then updated
/// then updated to match this preview scale and can be used when /// to match this preview scale and can be used when drawing a grid
/// drawing a grid line on the scaled preview of the image. /// line on the scaled preview of the image.
/// </summary> /// </summary>
/// <param name="previewWidth"> /// <param name="previewDimension">
/// The width of the image when previewed (I.E. in a GUI). /// The width or height of the image when previewed (I.E. in a GUI).
/// </param> /// </param>
/// <param name="actualWidth"> /// <param name="actualDimension">
/// The width of the actual image. /// The width or height of the actual image.
/// </param> /// </param>
/// <param name="lineThickness"> /// <param name="lineThickness">
/// The thickness of the pen used to draw the grid line. /// The thickness of the pen used to draw the grid line.
@ -78,8 +78,18 @@ namespace DeathSocket
/// SkiaSharp based functions already scale the grid lines for you. So, /// SkiaSharp based functions already scale the grid lines for you. So,
/// you should not need to use this function when using them. /// you should not need to use this function when using them.
/// </remarks> /// </remarks>
let scaleLineThickness (previewWidth: double) (actualWidth: double) (lineThickness: double) = let scaleLineThickness (previewDimension: double) (actualDimension: double) (lineThickness: double) =
lineThickness / (previewWidth / actualWidth) lineThickness / (previewDimension / actualDimension)
// NOT TESTED.
let determineDimension imageType =
match imageType with
| SkiaSharp s ->
validateIO s |> ignore
determineSkiaDimensions s
| SystemDrawing d ->
validateIO d |> ignore
determineSystemDrawingDimensions d
// System.Drawing Functions // System.Drawing Functions
// ======================================================================== // ========================================================================

12
DeathSocket/ImageServices.fs

@ -21,7 +21,13 @@
[| for point in 1 .. (columns - 1) -> [| for point in 1 .. (columns - 1) ->
[| SKPoint ((interval * (float32 point)), (float32 0)) [| SKPoint ((interval * (float32 point)), (float32 0))
SKPoint ((interval * (float32 point)), (float32 height))|]|] SKPoint ((interval * (float32 point)), (float32 height))|]|]
let determineSkiaDimensions filePath =
use fileStream = File.Open (filePath, FileMode.Open)
use skStream = new SKManagedStream (fileStream)
use bitmap = SKBitmap.Decode (skStream)
(bitmap.Width, bitmap.Height)
let drawSkiaGrid (spec: SkiaSpec) = let drawSkiaGrid (spec: SkiaSpec) =
use fileStream = File.Open (spec.originalPath, FileMode.Open) use fileStream = File.Open (spec.originalPath, FileMode.Open)
use skStream = new SKManagedStream (fileStream) use skStream = new SKManagedStream (fileStream)
@ -114,6 +120,10 @@
[| Point ((interval * point), 0) [| Point ((interval * point), 0)
Point ((interval * point), height)|]|] Point ((interval * point), height)|]|]
let determineSystemDrawingDimensions filePath =
use bitmap = Bitmap.FromFile filePath
(bitmap.Width, bitmap.Height)
(* Note on Use of Temp. File in Functions which Add A Grid Overlay (* Note on Use of Temp. File in Functions which Add A Grid Overlay
=========================================================================== ===========================================================================
The temp. file is used in the functions below are there to convert images The temp. file is used in the functions below are there to convert images

26
DeathSocket/ScratchPad.fsx

@ -1,6 +1,7 @@
// These two paths need adjusting to match your computer. // These two paths need adjusting to match your computer.
#r @"C:/Users/craig/.nuget/packages/skiasharp/1.60.3/lib/netstandard1.3/SkiaSharp.dll" #r @"C:/Users/craig/.nuget/packages/skiasharp/1.68.0/lib/netstandard1.3/SkiaSharp.dll"
#r @"C:/Users/craig/.nuget/packages/skiasharp/1.60.3/lib/net45/SkiaSharp.dll" // Currently not working...
// #r @"C:/Users/craig/.nuget/packages/skiasharp/1.68.0/runtimes/win10-x86/nativeassets/uap10.0/libSkiaSharp.dll"
#load "Domain.fs" #load "Domain.fs"
#load "Validation.fs" #load "Validation.fs"
@ -8,19 +9,19 @@
#load "ImageServices.fs" #load "ImageServices.fs"
#load "GridPainter.fs" #load "GridPainter.fs"
open System.Drawing
open System open System
open DeathSocket open System.Drawing
open SkiaSharp
open Validation open Validation
open ImageServices open ImageServices
open SkiaSharp open DeathSocket
(* Death Socket Scripts (* Death Socket Scripts
=============================================================================== ===============================================================================
The code in here can be use to create a gridded image without running the CLI. The code in here can be use to create a gridded image without running the CLI.
You can, also, run checks to see what Death Socket is doing when creating You can, also, run checks to see what Death Socket is doing when creating
a nerw image. *) a new image. *)
let desktop = Environment.GetFolderPath (Environment.SpecialFolder.Desktop) let desktop = Environment.GetFolderPath (Environment.SpecialFolder.Desktop)
@ -40,6 +41,19 @@ let skVerticalLines = createSKVerticalLines 120 450 22
(* You will need to provide the image and specify its load/save location. (* You will need to provide the image and specify its load/save location.
Death Socket assumes either JPEG or PNG files.*) Death Socket assumes either JPEG or PNG files.*)
// Not working at time of writing see "#r" comment (lines 3 and 4)
let skiaSharpDimensions =
determineSkiaDimensions (desktop + "/test.jpg")
let systemDrawingDimensions =
determineSystemDrawingDimensions (desktop + "/test.jpg")
let width = double (fst systemDrawingDimensions) // skiaSharpDimensions
let height = double (snd systemDrawingDimensions) // skiaSharpDimensions
// Change the line thickness (the last parameter) to whatever you want.
let scaledPen = GridPainter.scaleLineThickness width height 8.0
// Brush Specification (uses System.Drawing) // Brush Specification (uses System.Drawing)
Brush ({ originalPath = desktop + "/test.jpg" Brush ({ originalPath = desktop + "/test.jpg"
savePath = desktop + "/grid.png" savePath = desktop + "/grid.png"

6
DeathSocketCLI/DeathSocketCLI.fsproj

@ -66,7 +66,7 @@
</Reference> </Reference>
<Reference Include="mscorlib" /> <Reference Include="mscorlib" />
<Reference Include="SkiaSharp"> <Reference Include="SkiaSharp">
<HintPath>..\packages\SkiaSharp.1.60.3\lib\net45\SkiaSharp.dll</HintPath> <HintPath>..\packages\SkiaSharp.1.68.0\lib\net45\SkiaSharp.dll</HintPath>
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
@ -86,12 +86,12 @@
<Private>True</Private> <Private>True</Private>
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<Import Project="..\packages\SkiaSharp.1.60.3\build\net45\SkiaSharp.targets" Condition="Exists('..\packages\SkiaSharp.1.60.3\build\net45\SkiaSharp.targets')" /> <Import Project="..\packages\SkiaSharp.1.68.0\build\net45\SkiaSharp.targets" Condition="Exists('..\packages\SkiaSharp.1.68.0\build\net45\SkiaSharp.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup> <PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText> <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup> </PropertyGroup>
<Error Condition="!Exists('..\packages\SkiaSharp.1.60.3\build\net45\SkiaSharp.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\SkiaSharp.1.60.3\build\net45\SkiaSharp.targets'))" /> <Error Condition="!Exists('..\packages\SkiaSharp.1.68.0\build\net45\SkiaSharp.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\SkiaSharp.1.68.0\build\net45\SkiaSharp.targets'))" />
</Target> </Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets. Other similar extension points exist, see Microsoft.Common.targets.

2
DeathSocketCLI/packages.config

@ -2,7 +2,7 @@
<packages> <packages>
<package id="Console.Waterworks" version="0.1.0.0-alpha1" targetFramework="net471" /> <package id="Console.Waterworks" version="0.1.0.0-alpha1" targetFramework="net471" />
<package id="FSharp.Core" version="4.5.4" targetFramework="net471" /> <package id="FSharp.Core" version="4.5.4" targetFramework="net471" />
<package id="SkiaSharp" version="1.60.3" targetFramework="net471" /> <package id="SkiaSharp" version="1.68.0" targetFramework="net471" />
<package id="System.Drawing.Common" version="4.5.1" targetFramework="net471" /> <package id="System.Drawing.Common" version="4.5.1" targetFramework="net471" />
<package id="System.ValueTuple" version="4.5.0" targetFramework="net471" /> <package id="System.ValueTuple" version="4.5.0" targetFramework="net471" />
</packages> </packages>

6
TestCentre/LibraryTests.fs

@ -99,12 +99,12 @@
module PropertyTests = module PropertyTests =
open FsCheck.Xunit open System.IO
open DeathSocket
open System.Drawing open System.Drawing
open DeathSocket
open DeathSocket.GridPainter open DeathSocket.GridPainter
open TestingHelpers open TestingHelpers
open System.IO open FsCheck.Xunit
(* With regards to the "saving images" tests, you should end up with (* With regards to the "saving images" tests, you should end up with
one image left over in the SavingTestArea folder. Comment out the one image left over in the SavingTestArea folder. Comment out the

6
TestCentre/TestCentre.fsproj

@ -63,7 +63,7 @@
</Reference> </Reference>
<Reference Include="mscorlib" /> <Reference Include="mscorlib" />
<Reference Include="SkiaSharp"> <Reference Include="SkiaSharp">
<HintPath>..\packages\SkiaSharp.1.60.3\lib\net45\SkiaSharp.dll</HintPath> <HintPath>..\packages\SkiaSharp.1.68.0\lib\net45\SkiaSharp.dll</HintPath>
</Reference> </Reference>
<Reference Include="SmoulderingBeachBall"> <Reference Include="SmoulderingBeachBall">
<HintPath>..\packages\SmoulderingBeachBall.0.4.0-alpha1\lib\netstandard2.0\SmoulderingBeachBall.dll</HintPath> <HintPath>..\packages\SmoulderingBeachBall.0.4.0-alpha1\lib\netstandard2.0\SmoulderingBeachBall.dll</HintPath>
@ -110,10 +110,10 @@
<Error Condition="!Exists('..\packages\xunit.core.2.4.1\build\xunit.core.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\xunit.core.2.4.1\build\xunit.core.props'))" /> <Error Condition="!Exists('..\packages\xunit.core.2.4.1\build\xunit.core.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\xunit.core.2.4.1\build\xunit.core.props'))" />
<Error Condition="!Exists('..\packages\xunit.core.2.4.1\build\xunit.core.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\xunit.core.2.4.1\build\xunit.core.targets'))" /> <Error Condition="!Exists('..\packages\xunit.core.2.4.1\build\xunit.core.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\xunit.core.2.4.1\build\xunit.core.targets'))" />
<Error Condition="!Exists('..\packages\xunit.runner.visualstudio.2.4.1\build\net20\xunit.runner.visualstudio.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\xunit.runner.visualstudio.2.4.1\build\net20\xunit.runner.visualstudio.props'))" /> <Error Condition="!Exists('..\packages\xunit.runner.visualstudio.2.4.1\build\net20\xunit.runner.visualstudio.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\xunit.runner.visualstudio.2.4.1\build\net20\xunit.runner.visualstudio.props'))" />
<Error Condition="!Exists('..\packages\SkiaSharp.1.60.3\build\net45\SkiaSharp.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\SkiaSharp.1.60.3\build\net45\SkiaSharp.targets'))" /> <Error Condition="!Exists('..\packages\SkiaSharp.1.68.0\build\net45\SkiaSharp.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\SkiaSharp.1.68.0\build\net45\SkiaSharp.targets'))" />
</Target> </Target>
<Import Project="..\packages\xunit.core.2.4.1\build\xunit.core.targets" Condition="Exists('..\packages\xunit.core.2.4.1\build\xunit.core.targets')" /> <Import Project="..\packages\xunit.core.2.4.1\build\xunit.core.targets" Condition="Exists('..\packages\xunit.core.2.4.1\build\xunit.core.targets')" />
<Import Project="..\packages\SkiaSharp.1.60.3\build\net45\SkiaSharp.targets" Condition="Exists('..\packages\SkiaSharp.1.60.3\build\net45\SkiaSharp.targets')" /> <Import Project="..\packages\SkiaSharp.1.68.0\build\net45\SkiaSharp.targets" Condition="Exists('..\packages\SkiaSharp.1.68.0\build\net45\SkiaSharp.targets')" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets. Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild"> <Target Name="BeforeBuild">

2
TestCentre/packages.config

@ -3,7 +3,7 @@
<package id="FsCheck" version="2.13.0" targetFramework="net471" /> <package id="FsCheck" version="2.13.0" targetFramework="net471" />
<package id="FsCheck.Xunit" version="2.13.0" targetFramework="net471" /> <package id="FsCheck.Xunit" version="2.13.0" targetFramework="net471" />
<package id="FSharp.Core" version="4.5.4" targetFramework="net471" /> <package id="FSharp.Core" version="4.5.4" targetFramework="net471" />
<package id="SkiaSharp" version="1.60.3" targetFramework="net471" /> <package id="SkiaSharp" version="1.68.0" targetFramework="net471" />
<package id="SmoulderingBeachBall" version="0.4.0-alpha1" targetFramework="net471" /> <package id="SmoulderingBeachBall" version="0.4.0-alpha1" targetFramework="net471" />
<package id="System.Drawing.Common" version="4.5.1" targetFramework="net471" /> <package id="System.Drawing.Common" version="4.5.1" targetFramework="net471" />
<package id="System.ValueTuple" version="4.5.0" targetFramework="net471" /> <package id="System.ValueTuple" version="4.5.0" targetFramework="net471" />

Loading…
Cancel
Save