Skip to content

Commit

Permalink
Merge pull request #18 from LaFut/c#sdk
Browse files Browse the repository at this point in the history
Updated C# sdk: added absolute positioning, drawing arcs and sectors, and decimal separator
  • Loading branch information
JustAMan authored Nov 15, 2016
2 parents 488cd2d + 01962e3 commit 9f9328e
Showing 1 changed file with 40 additions and 1 deletion.
41 changes: 40 additions & 1 deletion clients/csharp/VisualClient.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
using System;
using System.Globalization;
using System.IO;
using System.Net.Sockets;
using System.Text;
using System.Threading;

namespace Com.CodeGame.CodeRacing2015.DevKit.CSharpCgdk
namespace Com.CodeGame.CodeWizards2016.DevKit.CSharpCgdk
{
public sealed class VisualClient
{
Expand All @@ -21,6 +24,10 @@ public VisualClient(string host, int port)
};

_writer = new BinaryWriter(_client.GetStream());

CultureInfo newCInfo = (CultureInfo) Thread.CurrentThread.CurrentCulture.Clone();
newCInfo.NumberFormat.NumberDecimalSeparator = ".";
Thread.CurrentThread.CurrentCulture = newCInfo;
}

//---------------------------------------------------------------------
Expand All @@ -43,6 +50,13 @@ public void BeginPost()
SendCommand("begin post");
}

/// <summary>
/// start queueing commands to be displayed on the absolute coordinates
/// </summary>
public void beginAbs() {
SendCommand("begin abs");
}

/// <summary>
/// Mark either "pre" queue of commands as ready to be displayed
/// </summary>
Expand All @@ -59,6 +73,14 @@ public void EndPost()
SendCommand("end post");
}

/// <summary>
// mark either "abs" queue of commands as ready to be displayed
/// <summary>
public void endAbs() {
SendCommand("end abs");
}


/// <summary>
/// Draw a circle at (x, y) with radius r and color color
/// </summary>
Expand Down Expand Up @@ -119,6 +141,23 @@ public void Text(double x, double y, string msg, float r = 0f, float g = 0f, flo
SendCommand($"text {x} {y} {msg} {r} {g} {b}");
}

/// <summary>
/// draw a arc with center at (x, y), radius radius and angle arcAngle, started from startAngle with color color, angles in radians
/// < /summary>
public void Arc(double x, double y, double radius, double startAngle, double arcAngle, float r = 0f, float g = 0f, float b = 0f) {
ValidateColor(r, g, b);
SendCommand($"arc {x} {y} {radius} {startAngle} {arcAngle} {r} {g} {b}");
}

/// <summary>
/// draw a filled arc with center at (x, y), radius radius and angle arcAngle, started from startAngle with color color, angles in radians
/// </summary>
public void FillArc(double x, double y, double radius, double startAngle, double arcAngle, float r = 0f, float g = 0f, float b = 0f) {
ValidateColor(r, g, b);
SendCommand($"fill_arc {x} {y} {radius} {startAngle} {arcAngle} {r} {g} {b}");
}


//---------------------------------------------------------------------
// Helpers
//---------------------------------------------------------------------
Expand Down

0 comments on commit 9f9328e

Please sign in to comment.