Skip to content

Commit 9d0f457

Browse files
committed
Migrate rendering to shared Eda.Rendering backends
Replace local CoordTransform, IRenderContext, SkiaRenderContext, and SvgRenderContext with shared implementations from Eda.Rendering. Altium-specific component renderers and layer colors remain in this repo.
1 parent 3834cb4 commit 9d0f457

16 files changed

Lines changed: 57 additions & 1332 deletions

File tree

examples/RenderFiles/Program.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,13 @@
3535

3636
using OriginalCircuit.Altium.Models.Pcb;
3737
using OriginalCircuit.Altium.Models.Sch;
38-
using OriginalCircuit.Eda.Enums;
39-
using OriginalCircuit.Eda.Primitives;
4038
using OriginalCircuit.Altium.Rendering;
41-
using PinElectricalType = OriginalCircuit.Altium.Models.Sch.PinElectricalType;
4239
using OriginalCircuit.Altium.Rendering.Raster;
4340
using OriginalCircuit.Altium.Rendering.Svg;
41+
using OriginalCircuit.Eda.Enums;
42+
using OriginalCircuit.Eda.Primitives;
43+
using OriginalCircuit.Eda.Rendering;
44+
using PinElectricalType = OriginalCircuit.Altium.Models.Sch.PinElectricalType;
4445

4546
var outputDir = Path.Combine(Path.GetTempPath(), "AltiumRenderExample");
4647
Directory.CreateDirectory(outputDir);
@@ -294,7 +295,7 @@
294295
{
295296
Width = 2048,
296297
Height = 2048,
297-
BackgroundColor = 0xFF000020, // ARGB: dark blue background
298+
BackgroundColor = EdaColor.FromArgb(0xFF, 0x00, 0x00, 0x20), // dark blue background
298299
AutoZoom = true,
299300
Scale = 1.0
300301
};

src/OriginalCircuit.Altium.Rendering.Core/CoordTransform.cs

Lines changed: 0 additions & 99 deletions
This file was deleted.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
using OriginalCircuit.Eda.Rendering;
2+
3+
namespace OriginalCircuit.Altium.Rendering;
4+
5+
/// <summary>
6+
/// Altium-specific extension methods for <see cref="CoordTransform"/>.
7+
/// </summary>
8+
public static class CoordTransformExtensions
9+
{
10+
/// <summary>
11+
/// Scales a pixel-space length relative to the current zoom level.
12+
/// Used for zoom-independent sizes like line widths (Small=1px, Medium=3px, Large=5px).
13+
/// At 100% zoom the value is returned unchanged; at other zoom levels it is scaled proportionally.
14+
/// </summary>
15+
public static double ScalePixelLength(this CoordTransform transform, double pixelLength) => pixelLength;
16+
17+
/// <summary>
18+
/// Maps the Altium schematic line width enum (0=Small, 1=Medium, 2=Large)
19+
/// to a screen pixel width, scaled by zoom.
20+
/// </summary>
21+
public static double MapLineWidthEnum(this CoordTransform transform, int lineWidthEnum)
22+
{
23+
double px = lineWidthEnum switch
24+
{
25+
0 => 1.0,
26+
1 => 3.0,
27+
2 => 5.0,
28+
_ => 1.0
29+
};
30+
return transform.ScalePixelLength(px);
31+
}
32+
}

src/OriginalCircuit.Altium.Rendering.Core/IRenderContext.cs

Lines changed: 0 additions & 142 deletions
This file was deleted.

0 commit comments

Comments
 (0)