
Security News
Browserslist-rs Gets Major Refactor, Cutting Binary Size by Over 1MB
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
angular-canvas
Advanced tools
šØ Angular canvas renderer with support DefaultDomRenderer.
Features:
npm i angular-canvas
Create canvas element:
import { CanvasElement, NgCanvasElement, NgCanvas } from 'angular-canvas';
@CanvasElement({
selector: 'graph-line'
})
export class GraphLineElement implements NgCanvasElement {
// parent element
public parent: NgCanvas;
// canvas element redraw until all NgCanvasElement needDraw as true
public needDraw: boolean;
setNgProperty(name: string, value: any): void {
this[name] = value;
// redraw all element in one canvas context after set ng property
this.parent.drawAll();
}
draw(context: CanvasRenderingContext2D, time: number): void {
context.strokeStyle = 'red';
...
}
}
Register this element in module
import { CanvasDomModule } from 'angular-canvas';
...
@NgModule({
...
imports: [
CanvasDomModule.forRoot(
[
GraphLineElement,
...
]
),
And declare component use canvas render
@CanvasComponent
component.ts
@CanvasComponent
@Component({
selector: 'app-graph-canvas-example',
templateUrl: './graph-canvas-example.component.html',
styleUrls: ['./graph-canvas-example.component.scss'],
})
component.html
<p>Graph example</p>
<canvas class="first">
<rect [x]="mouseX" [y]="20" w="20" h="20"></rect>
<line [x1]="10" [x2]="100" [y1]="10" [y2]="200"></line>
</canvas>
<canvas>
<graph-line
[data]="data"
[step]="step"
[deltaX]="deltaX"
strokeStyle="orange"
></graph-line>
<graph-line
[data]="data2"
[step]="step"
[deltaX]="deltaX"
strokeStyle="green"
></graph-line>
<graph-line [data]="data3" [deltaX]="deltaX" strokeStyle="blue"></graph-line>
</canvas>
Game example:
NgCanvas
- main component with selector canvas
public element: HTMLCanvasElement;
public drawAll(): void; // redraw all register elements in one canvas context
NgCanvasElement
- canvas element interface for register in module
style?: CSSStyleDeclaration;
classList?: DOMTokenList;
needDraw?: boolean; // canvas element redraw until all NgCanvasElement needDraw as true
parent: NgCanvas; // canvas parent element
onInit?(context: CanvasRenderingContext2D): void;
onDestroy?(context: CanvasRenderingContext2D): void;
/**
* Method for draw element, *time* - requestAnimationTime
*/
draw(context: CanvasRenderingContext2D, time?: number): void;
// standart renderer methods
appendChild?(newChild: any): void;
addClass?(name): void;
insertBefore?(newChild: any, refChild: any): void;
setNgAttribute?(name: string, value: string, namespace?: string | null): void;
setAttribute?(name: string, value: string, namespace?: string | null): void;
setNgProperty?(name: string, value: any): void;
setStyle?(style: string, value: any, flags?: RendererStyleFlags2): void;
setValue?(value: any): void;
removeAttribute?(name: string, namespace?: string | null): void;
removeChild?(oldChild: any): void;
removeClass?(name: string): void;
removeStyle?(style: string, flags?: RendererStyleFlags2): void;
setAttributeNS?(namespaceUri: string, name: string, value: string): void;
removeAttributeNS?(namespaceUri: string, name: string): void;
CanvasComponent
- Decorator, need for use canvas renderer
CanvasElement
- Decorator, for register canvas elements in storage metadata
support only one parameter: selector
CanvasDomModule.forRoot([])
register elements in AppModule
FAQs
Angular canvas renderer
We found that angular-canvas demonstrated a not healthy version release cadence and project activity because the last version was released a year ago.Ā It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.