This commit is contained in:
=
2026-11-12 08:38:54 -05:00
commit c6b224e86e
27 changed files with 392 additions and 0 deletions

106
Raytracer/Program.cs Normal file
View File

@@ -0,0 +1,106 @@
// See https://aka.ms/new-console-template for more information
using System.Text;
using System.Text.Encodings;
namespace Ray
{
struct Vec3
{
double x, y, z;
}
readonly struct Color
{
public readonly byte r, g, b;
public Color(byte r, byte g, byte b)
{
this.r = r;
this.g = g;
this.b = b;
}
}
class BitmapImage
{
public readonly UInt16 width, height;
private Color[,] pixels;
public BitmapImage(UInt16 width, UInt16 height)
{
this.width = width;
this.height = height;
this.pixels = new Color[width,height];
}
public void setPixel(in UInt16 x, in UInt16 y, in Color c)
{
this.pixels[x,y] = c;
}
public void writeImage(in string path)
{
//Rows in BMP images must be divisibly by 4... for some reason.
int padding = (4 - (width * 3) % 4) % 4;
//8 bit color depth + 26 bytes for header and BITMAPCORE header
Int32 bfSize = (width * height * 3) + (padding * this.height) + 26;
using (FileStream fs = new FileStream(path, FileMode.Create))
using (BinaryWriter bw = new BinaryWriter(fs))
{
//File header
bw.Write('B');
bw.Write('M');
bw.Write(bfSize);
bw.Write((Int32)0); //bfReserved 1 and 2
bw.Write((Int32)26);
//DIB header (Bitmap core)
bw.Write((Int32)12);
bw.Write(this.width);
bw.Write(this.height);
bw.Write((Int16)1);
bw.Write((Int16)24);
for (ushort i = 0; i < this.width; i++)
{
for (ushort j = 0; j < this.height; j++)
{
bw.Write(this.pixels[i, j].b);
bw.Write(this.pixels[i, j].g);
bw.Write(this.pixels[i, j].r);
}
for (ushort j = 0; j < padding; j++) //end-of-row padding.
{
bw.Write((byte)0);
}
}
}
}
}
class Raytracer
{
static void Main()
{
var BMP = new BitmapImage(255, 255);
for (ushort i = 0; i < 255; i++)
{
for (ushort j = 0; j < 255; j++)
{
BMP.setPixel(i, j, new Color((byte)i, 0, (byte)j));
}
}
for (ushort i = 200; i < 255; i++)
{
for (ushort j = 200; j < 255; j++)
{
BMP.setPixel(i, j, new Color(0, 255, 0));
}
}
BMP.writeImage("C:/Users/Lizzy/test2.bmp");
}
}
};

View File

@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

View File

@@ -0,0 +1,23 @@
{
"runtimeTarget": {
"name": ".NETCoreApp,Version=v8.0",
"signature": ""
},
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v8.0": {
"Raytracer/1.0.0": {
"runtime": {
"Raytracer.dll": {}
}
}
}
},
"libraries": {
"Raytracer/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
}
}
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,12 @@
{
"runtimeOptions": {
"tfm": "net8.0",
"framework": {
"name": "Microsoft.NETCore.App",
"version": "8.0.0"
},
"configProperties": {
"System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false
}
}
}

View File

@@ -0,0 +1,4 @@
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v8.0", FrameworkDisplayName = ".NET 8.0")]

View File

@@ -0,0 +1,23 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using System;
using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("Raytracer")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
[assembly: System.Reflection.AssemblyProductAttribute("Raytracer")]
[assembly: System.Reflection.AssemblyTitleAttribute("Raytracer")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
// Generated by the MSBuild WriteCodeFragment class.

View File

@@ -0,0 +1 @@
e378de223b87c96dc2c0d6a9c2dcdd819f80d6312e9ae270253e4be16082b3ca

View File

@@ -0,0 +1,13 @@
is_global = true
build_property.TargetFramework = net8.0
build_property.TargetPlatformMinVersion =
build_property.UsingMicrosoftNETSdkWeb =
build_property.ProjectTypeGuids =
build_property.InvariantGlobalization =
build_property.PlatformNeutralAssembly =
build_property.EnforceExtendedAnalyzerRules =
build_property._SupportedPlatformList = Linux,macOS,Windows
build_property.RootNamespace = Raytracer
build_property.ProjectDir = C:\Users\Lizzy\source\repos\Raytracer\Raytracer\
build_property.EnableComHosting =
build_property.EnableGeneratedComInterfaceComImportInterop =

View File

@@ -0,0 +1,8 @@
// <auto-generated/>
global using global::System;
global using global::System.Collections.Generic;
global using global::System.IO;
global using global::System.Linq;
global using global::System.Net.Http;
global using global::System.Threading;
global using global::System.Threading.Tasks;

Binary file not shown.

View File

@@ -0,0 +1 @@
8d9819bd4cb3fc5ce88e0af92e6f3172bfaaaf9edfed30de3ca9ecd4eb30e7b0

View File

@@ -0,0 +1,14 @@
C:\Users\Lizzy\source\repos\Raytracer\Raytracer\bin\Debug\net8.0\Raytracer.exe
C:\Users\Lizzy\source\repos\Raytracer\Raytracer\bin\Debug\net8.0\Raytracer.deps.json
C:\Users\Lizzy\source\repos\Raytracer\Raytracer\bin\Debug\net8.0\Raytracer.runtimeconfig.json
C:\Users\Lizzy\source\repos\Raytracer\Raytracer\bin\Debug\net8.0\Raytracer.dll
C:\Users\Lizzy\source\repos\Raytracer\Raytracer\bin\Debug\net8.0\Raytracer.pdb
C:\Users\Lizzy\source\repos\Raytracer\Raytracer\obj\Debug\net8.0\Raytracer.GeneratedMSBuildEditorConfig.editorconfig
C:\Users\Lizzy\source\repos\Raytracer\Raytracer\obj\Debug\net8.0\Raytracer.AssemblyInfoInputs.cache
C:\Users\Lizzy\source\repos\Raytracer\Raytracer\obj\Debug\net8.0\Raytracer.AssemblyInfo.cs
C:\Users\Lizzy\source\repos\Raytracer\Raytracer\obj\Debug\net8.0\Raytracer.csproj.CoreCompileInputs.cache
C:\Users\Lizzy\source\repos\Raytracer\Raytracer\obj\Debug\net8.0\Raytracer.dll
C:\Users\Lizzy\source\repos\Raytracer\Raytracer\obj\Debug\net8.0\refint\Raytracer.dll
C:\Users\Lizzy\source\repos\Raytracer\Raytracer\obj\Debug\net8.0\Raytracer.pdb
C:\Users\Lizzy\source\repos\Raytracer\Raytracer\obj\Debug\net8.0\Raytracer.genruntimeconfig.cache
C:\Users\Lizzy\source\repos\Raytracer\Raytracer\obj\Debug\net8.0\ref\Raytracer.dll

Binary file not shown.

View File

@@ -0,0 +1 @@
168f6cf40c8ec39129e210947bcc73c35d0fa1b59a1f10868cc2e26f82ab6187

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,72 @@
{
"format": 1,
"restore": {
"C:\\Users\\Lizzy\\source\\repos\\Raytracer\\Raytracer\\Raytracer.csproj": {}
},
"projects": {
"C:\\Users\\Lizzy\\source\\repos\\Raytracer\\Raytracer\\Raytracer.csproj": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "C:\\Users\\Lizzy\\source\\repos\\Raytracer\\Raytracer\\Raytracer.csproj",
"projectName": "Raytracer",
"projectPath": "C:\\Users\\Lizzy\\source\\repos\\Raytracer\\Raytracer\\Raytracer.csproj",
"packagesPath": "C:\\Users\\Lizzy\\.nuget\\packages\\",
"outputPath": "C:\\Users\\Lizzy\\source\\repos\\Raytracer\\Raytracer\\obj\\",
"projectStyle": "PackageReference",
"fallbackFolders": [
"C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages"
],
"configFilePaths": [
"C:\\Users\\Lizzy\\AppData\\Roaming\\NuGet\\NuGet.Config",
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.FallbackLocation.config",
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config"
],
"originalTargetFrameworks": [
"net8.0"
],
"sources": {
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"net8.0": {
"targetAlias": "net8.0",
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
},
"restoreAuditProperties": {
"enableAudit": "true",
"auditLevel": "low",
"auditMode": "direct"
}
},
"frameworks": {
"net8.0": {
"targetAlias": "net8.0",
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48",
"net481"
],
"assetTargetFallback": true,
"warn": true,
"frameworkReferences": {
"Microsoft.NETCore.App": {
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\8.0.412/PortableRuntimeIdentifierGraph.json"
}
}
}
}
}

View File

@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<RestoreSuccess Condition=" '$(RestoreSuccess)' == '' ">True</RestoreSuccess>
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">$(MSBuildThisFileDirectory)project.assets.json</ProjectAssetsFile>
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">$(UserProfile)\.nuget\packages\</NuGetPackageRoot>
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">C:\Users\Lizzy\.nuget\packages\;C:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages</NuGetPackageFolders>
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">6.13.2</NuGetToolVersion>
</PropertyGroup>
<ItemGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<SourceRoot Include="C:\Users\Lizzy\.nuget\packages\" />
<SourceRoot Include="C:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages\" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" />

View File

@@ -0,0 +1,78 @@
{
"version": 3,
"targets": {
"net8.0": {}
},
"libraries": {},
"projectFileDependencyGroups": {
"net8.0": []
},
"packageFolders": {
"C:\\Users\\Lizzy\\.nuget\\packages\\": {},
"C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages": {}
},
"project": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "C:\\Users\\Lizzy\\source\\repos\\Raytracer\\Raytracer\\Raytracer.csproj",
"projectName": "Raytracer",
"projectPath": "C:\\Users\\Lizzy\\source\\repos\\Raytracer\\Raytracer\\Raytracer.csproj",
"packagesPath": "C:\\Users\\Lizzy\\.nuget\\packages\\",
"outputPath": "C:\\Users\\Lizzy\\source\\repos\\Raytracer\\Raytracer\\obj\\",
"projectStyle": "PackageReference",
"fallbackFolders": [
"C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages"
],
"configFilePaths": [
"C:\\Users\\Lizzy\\AppData\\Roaming\\NuGet\\NuGet.Config",
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.FallbackLocation.config",
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config"
],
"originalTargetFrameworks": [
"net8.0"
],
"sources": {
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"net8.0": {
"targetAlias": "net8.0",
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
},
"restoreAuditProperties": {
"enableAudit": "true",
"auditLevel": "low",
"auditMode": "direct"
}
},
"frameworks": {
"net8.0": {
"targetAlias": "net8.0",
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48",
"net481"
],
"assetTargetFallback": true,
"warn": true,
"frameworkReferences": {
"Microsoft.NETCore.App": {
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\8.0.412/PortableRuntimeIdentifierGraph.json"
}
}
}
}

View File

@@ -0,0 +1,8 @@
{
"version": 2,
"dgSpecHash": "FMPI4qfQck4=",
"success": true,
"projectFilePath": "C:\\Users\\Lizzy\\source\\repos\\Raytracer\\Raytracer\\Raytracer.csproj",
"expectedPackageFiles": [],
"logs": []
}