Добавьте файлы проекта.
This commit is contained in:
13
CairoObjective/CairoObjective.csproj
Normal file
13
CairoObjective/CairoObjective.csproj
Normal file
@@ -0,0 +1,13 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="CairoSharp" Version="3.24.24.38" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
21
CairoObjective/DrawObjects/Line.cs
Normal file
21
CairoObjective/DrawObjects/Line.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CairoObjective.DrawObjects
|
||||
{
|
||||
public class Line
|
||||
{
|
||||
public double X1, X2, Y1, Y2;
|
||||
|
||||
public Line(double x1, double y1, double x2, double y2)
|
||||
{
|
||||
X1 = x1;
|
||||
X2 = x2;
|
||||
Y1 = y1;
|
||||
Y2 = y2;
|
||||
}
|
||||
}
|
||||
}
|
||||
72
CairoObjective/Line.cs
Normal file
72
CairoObjective/Line.cs
Normal file
@@ -0,0 +1,72 @@
|
||||
using Cairo;
|
||||
using CairoObjective.DrawObjects;
|
||||
|
||||
namespace CairoObjective
|
||||
{
|
||||
#pragma warning disable CS8602 // Разыменование вероятной пустой ссылки.
|
||||
public class Line
|
||||
{
|
||||
public static double DefaultSize = 1;
|
||||
public static void Make(int pointX1, int pointY1, int pointX2, int pointY2, double size, Cairo.Color color)
|
||||
{
|
||||
Set.CheckContext();
|
||||
var context = Set.Context;
|
||||
context.SetSourceColor(color);
|
||||
context.LineWidth = size;
|
||||
context.MoveTo(pointX1, pointY1);
|
||||
context.LineTo(pointX2, pointY2);
|
||||
context.Stroke();
|
||||
}
|
||||
public static void Make(int pointX1, int pointY1, int pointX2, int pointY2, Cairo.Color color)
|
||||
{
|
||||
Set.CheckContext();
|
||||
var context = Set.Context;
|
||||
context.SetSourceColor(color);
|
||||
context.LineWidth = DefaultSize;
|
||||
context.MoveTo(pointX1, pointY1);
|
||||
context.LineTo(pointX2, pointY2);
|
||||
context.Stroke();
|
||||
}
|
||||
public static void Make(int pointX1, int pointY1, int pointX2, int pointY2, double size)
|
||||
{
|
||||
Set.CheckContext();
|
||||
var context = Set.Context;
|
||||
context.SetSourceColor(Set.Color);
|
||||
context.LineWidth = size;
|
||||
context.MoveTo(pointX1, pointY1);
|
||||
context.LineTo(pointX2, pointY2);
|
||||
context.Stroke();
|
||||
}
|
||||
public static void Make(int pointX1, int pointY1, int pointX2, int pointY2)
|
||||
{
|
||||
Set.CheckContext();
|
||||
var context = Set.Context;
|
||||
context.SetSourceColor(Set.Color);
|
||||
context.LineWidth = DefaultSize;
|
||||
context.MoveTo(pointX1, pointY1);
|
||||
context.LineTo(pointX2, pointY2);
|
||||
context.Stroke();
|
||||
}
|
||||
public static void Make(DrawObjects.Line line)
|
||||
{
|
||||
Set.CheckContext();
|
||||
var context = Set.Context;
|
||||
context.SetSourceColor(Set.Color);
|
||||
context.LineWidth = DefaultSize;
|
||||
context.MoveTo(line.X1, line.Y1);
|
||||
context.LineTo(line.X2, line.Y2);
|
||||
context.Stroke();
|
||||
}
|
||||
public static void Make(DrawObjects.Line line, Color color)
|
||||
{
|
||||
Set.CheckContext();
|
||||
var context = Set.Context;
|
||||
context.SetSourceColor(color);
|
||||
context.LineWidth = DefaultSize;
|
||||
context.MoveTo(line.X1, line.Y1);
|
||||
context.LineTo(line.X2, line.Y2);
|
||||
context.Stroke();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
30
CairoObjective/Set.cs
Normal file
30
CairoObjective/Set.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
namespace CairoObjective
|
||||
{
|
||||
public static class Set
|
||||
{
|
||||
public static void CheckContext()
|
||||
{
|
||||
if (Context == null)
|
||||
{
|
||||
throw new NullReferenceException("Context is Null. Set context on Set class.");
|
||||
}
|
||||
}
|
||||
public static Cairo.Context? Context;
|
||||
public static Cairo.Color Color = new Cairo.Color(1,1,1);//White
|
||||
#pragma warning disable CS8602 // Разыменование вероятной пустой ссылки.
|
||||
public static void Background(Cairo.Color color)
|
||||
{
|
||||
CheckContext();
|
||||
var context = Set.Context;
|
||||
context.SetSourceColor(color);
|
||||
context.Paint();
|
||||
}
|
||||
public static void Background()
|
||||
{
|
||||
CheckContext();
|
||||
var context = Set.Context;
|
||||
context.SetSourceColor(Color);
|
||||
context.Paint();
|
||||
}
|
||||
}
|
||||
}
|
||||
49
CairoObjective/Text.cs
Normal file
49
CairoObjective/Text.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
namespace CairoObjective
|
||||
{
|
||||
#pragma warning disable CS8602 // Разыменование вероятной пустой ссылки.
|
||||
public class Text
|
||||
{
|
||||
public static double DefaultFontSize = 20;//Default Font Size
|
||||
|
||||
public static void Make(string text, int pointX, int pointY, double size, Cairo.Color color)
|
||||
{
|
||||
Set.CheckContext();
|
||||
var context = Set.Context;
|
||||
context.SetSourceColor(color);
|
||||
context.SetFontSize(size);
|
||||
Cairo.TextExtents extents = context.TextExtents(text);
|
||||
context.MoveTo(pointX - extents.Width / 2, pointY + extents.Height / 2);
|
||||
context.ShowText(text);
|
||||
}
|
||||
public static void Make(string text, int pointX, int pointY, Cairo.Color color)
|
||||
{
|
||||
Set.CheckContext();
|
||||
var context = Set.Context;
|
||||
context.SetSourceColor(color);
|
||||
context.SetFontSize(DefaultFontSize);
|
||||
Cairo.TextExtents extents = context.TextExtents(text);
|
||||
context.MoveTo(pointX - extents.Width / 2, pointY + extents.Height / 2);
|
||||
context.ShowText(text);
|
||||
}
|
||||
public static void Make(string text, int pointX, int pointY, double size)
|
||||
{
|
||||
Set.CheckContext();
|
||||
var context = Set.Context;
|
||||
context.SetSourceColor(Set.Color);
|
||||
context.SetFontSize(size);
|
||||
Cairo.TextExtents extents = context.TextExtents(text);
|
||||
context.MoveTo(pointX - extents.Width / 2, pointY + extents.Height / 2);
|
||||
context.ShowText(text);
|
||||
}
|
||||
public static void Make(string text, int pointX, int pointY)
|
||||
{
|
||||
Set.CheckContext();
|
||||
var context = Set.Context;
|
||||
context.SetSourceColor(Set.Color);
|
||||
context.SetFontSize(DefaultFontSize);
|
||||
Cairo.TextExtents extents = context.TextExtents(text);
|
||||
context.MoveTo(pointX - extents.Width / 2, pointY + extents.Height / 2);
|
||||
context.ShowText(text);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user