Skip to content

Commit

Permalink
Fir rendering issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
ghent360 committed Apr 29, 2020
1 parent 20996f2 commit f4d8803
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 35 deletions.
14 changes: 4 additions & 10 deletions src/components/CanvasViewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -287,14 +287,8 @@ export class CanvasViewer extends React.Component<CanvasViewerProps, CanvasViewe
}
if (outlineLayers.length > 0) {
outlineLayers.forEach(o => {
let path:Path2D = o.thin;
if (path == undefined) {
// Hmm what to do if there is no thin polygon path
// filling the solid path, just draws the cutout shape.
//path = this.state.polygonPaths.get(o.fileName + ":solid");
}
if (path != undefined) {
outline.push(path);
if (o.thin) {
outline.push(...o.thin);
filledOutline = true;
}
});
Expand Down Expand Up @@ -367,7 +361,7 @@ export class CanvasViewer extends React.Component<CanvasViewerProps, CanvasViewe
outline.forEach(p => context.fill(p));
}
context.fillStyle = this.getSolidColor(l);
context.fill(path);
path.forEach(p => context.fill(p));
}
path = l.thin;
if (path != undefined) {
Expand All @@ -376,7 +370,7 @@ export class CanvasViewer extends React.Component<CanvasViewerProps, CanvasViewe
context.lineWidth = 1/scale;
context.globalAlpha = l.opacity;
context.strokeStyle = this.getBorderColor(l);
context.stroke(path);
path.forEach(p => context.stroke(p));
}
if (l.holes != undefined) {
context.lineWidth = 0;
Expand Down
44 changes: 19 additions & 25 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ export interface LayerInfo {
readonly content:string,
readonly selected:boolean;
readonly opacity:number;
readonly solid:Path2D;
readonly thin:Path2D;
readonly solid:Array<Path2D>;
readonly thin:Array<Path2D>;
readonly color:Color;
}

Expand Down Expand Up @@ -62,8 +62,8 @@ class LayerFile implements LayerInfo {
public centers:ComponentCenters,
public selected:boolean,
public opacity:number,
public solid:Path2D,
public thin:Path2D,
public solid:Array<Path2D>,
public thin:Array<Path2D>,
public color:Color) {}
}

Expand All @@ -80,34 +80,28 @@ function drawPolygon(polygon:Float64Array, context:Path2D) {
}
}

function createPathCache(polygons:GerberPolygons):{solid:Path2D, thin:Path2D} {
let solidPath = undefined;
function createPathCache(polygons:GerberPolygons):{solid:Array<Path2D>, thin:Array<Path2D>} {
let solidPath:Array<Path2D> = [undefined];
if (polygons.solids && polygons.solids.length > 0) {
polygons.solids
solidPath = polygons.solids
.filter(p => p.length > 1)
.forEach(p => {
if (!solidPath) {
solidPath = new Path2D();
}
drawPolygon(p, solidPath);
.map(p => {
let path = new Path2D();
drawPolygon(p, path);
path.closePath();
return path;
});
if (solidPath) {
solidPath.closePath();
}
}
let thinPath = undefined;
let thinPath:Array<Path2D> = undefined;
if (polygons.thins && polygons.thins.length > 0) {
polygons.thins
thinPath = polygons.thins
.filter(p => p.length > 1)
.forEach(p => {
if (!thinPath) {
thinPath = new Path2D();
}
drawPolygon(p, thinPath);
.map(p => {
let path = new Path2D();
drawPolygon(p, path);
path.closePath();
return path;
});
if (thinPath) {
thinPath.closePath();
}
}
return {solid:solidPath, thin:thinPath};
}
Expand Down

0 comments on commit f4d8803

Please sign in to comment.