Created
September 3, 2020 20:12
-
-
Save GuyInGrey/2bc98661c7950ddc4700d22230d23557 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Drawing; | |
using System.Drawing.Imaging; | |
using System.IO; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
using Newtonsoft.Json; | |
using Processing; | |
namespace EDStatistics | |
{ | |
class Program | |
{ | |
static void Main() | |
{ | |
var image = new PSprite(16000, 16000); | |
var pixels = image.Art.GetPixels(); | |
var i = new Coordinates() { x = -42213.81f, y = -29359.81f }; | |
var a = new Coordinates() { x = 40503.81f, y = 39518.34f }; | |
var count = 0; | |
const int BufferSize = 4096; | |
using (var fileStream = File.OpenRead("systemsWithCoordinates.json")) | |
using (var streamReader = new StreamReader(fileStream, Encoding.UTF8, true, BufferSize)) | |
{ | |
string line; | |
while ((line = streamReader.ReadLine()) != null) | |
{ | |
count++; | |
if (count % 5 != 0) { continue; } | |
line = line.Trim(); | |
if (line.Length < 3) { continue; } | |
if (line.Substring(line.Length - 1, 1).Equals(",")) | |
{ | |
line = line.Substring(0, line.Length - 1); | |
} | |
var system = JsonConvert.DeserializeObject<StarSystem>(line); | |
if (system is null) { continue; } | |
var b = system.coords; | |
var c = new Coordinates((b.x - i.x) / (a.x - i.x), (b.y - i.y) / (a.y - i.y)); | |
c.x *= image.Width; | |
c.y *= image.Height; | |
var x = (int)c.x; | |
var y = (int)c.y; | |
var address = (x + (y * image.Width)) * 4; | |
if (address >= pixels.Length || address < 0) { continue; } | |
pixels[address] = 255; | |
pixels[address + 1] = 0; | |
pixels[address + 2] = 0; | |
var old = pixels[address + 3]; | |
pixels[address + 3] = 255;//(byte)(old == 255 ? old : old + 1); | |
var newP = pixels[address + 3]; | |
if (count % 500000 == 0) { Console.Title = count.ToString(); } | |
} | |
} | |
image.Art.SetPixels(pixels); | |
image.Save("image.png"); | |
Console.WriteLine("Finished."); | |
Console.Read(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment