Skip to content

Instantly share code, notes, and snippets.

@trikitrok
Created March 21, 2025 18:56
Show Gist options
  • Save trikitrok/678760f64ba55ded3ad09e442934f7d9 to your computer and use it in GitHub Desktop.
Save trikitrok/678760f64ba55ded3ad09e442934f7d9 to your computer and use it in GitHub Desktop.
Step 2
// Step 2
export class Renderer {
private readonly brush: GDIBrush;
private readonly renderingRoots: Point[];
private readonly colors: ColorMatrix;
private readonly selection: Point[];
constructor(
brush: GDIBrush,
renderingRoots: Point[],
colors: ColorMatrix,
selection: Point[]
) {
this.brush = brush;
this.renderingRoots = renderingRoots;
this.colors = colors;
this.selection = selection;
}
// !!! -> we copied the code of the original method in here and fixed all the compilation problems
public draw(): void {
// some more code in the method
for (const point of this.renderingRoots) {
// a lot more code in the loop
//!! we had to make drawPoint public and add a property for GDIBrush's colorId field
this.brush.drawPoint(point.x, point.y, this.colors.getColor(this.brush.colorId));
}
// a lot more code in the method
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment