@stocksharp/diagram 1.2.2 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/canvas-renderer.js +9 -3
- package/dist/esm/canvas-renderer.js.map +1 -1
- package/dist/esm/color.js +23 -0
- package/dist/esm/color.js.map +1 -1
- package/dist/esm/diagram/palette.js +5 -0
- package/dist/esm/diagram/palette.js.map +1 -1
- package/dist/ssdiagram-headless.js +14 -2
- package/dist/ssdiagram-headless.js.map +2 -2
- package/dist/ssdiagram.js +15 -2
- package/dist/ssdiagram.js.map +2 -2
- package/dist/types/canvas-renderer.d.ts +1 -0
- package/dist/types/canvas-renderer.d.ts.map +1 -1
- package/dist/types/color.d.ts +1 -0
- package/dist/types/color.d.ts.map +1 -1
- package/dist/types/diagram/palette.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/canvas-renderer.ts +9 -3
- package/src/color.ts +26 -0
- package/src/diagram/palette.ts +4 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SvgSurface } from './svg-surface.js';
|
|
2
|
-
import { readableTextOn } from './color.js';
|
|
2
|
+
import { readableOutlineOn, readableTextOn } from './color.js';
|
|
3
3
|
// Internal dependency-free canvas renderer used by StockSharpDiagram.
|
|
4
4
|
//
|
|
5
5
|
// Dependency-free, pure 2D canvas. Demonstrates the hard parts: typed
|
|
@@ -227,6 +227,8 @@ function colorLuminance(color) {
|
|
|
227
227
|
}
|
|
228
228
|
export class Diagram {
|
|
229
229
|
constructor(opts) {
|
|
230
|
+
/// Outline every socket is edged with, refreshed from the background each draw.
|
|
231
|
+
this.portOutline = readableOutlineOn('#1b1b1f');
|
|
230
232
|
this.nodes = [];
|
|
231
233
|
this.links = [];
|
|
232
234
|
this.zones = [];
|
|
@@ -2671,8 +2673,12 @@ export class Diagram {
|
|
|
2671
2673
|
draw(options = SCREEN_RENDER_OPTIONS) {
|
|
2672
2674
|
const ctx = this.ctx;
|
|
2673
2675
|
ctx.clearRect(0, 0, this.width, this.height);
|
|
2674
|
-
|
|
2676
|
+
const background = this.opts.background ?? '#1b1b1f';
|
|
2677
|
+
ctx.fillStyle = background;
|
|
2675
2678
|
ctx.fillRect(0, 0, this.width, this.height);
|
|
2679
|
+
// Read here rather than per socket: an export swaps the background for the duration of
|
|
2680
|
+
// one draw, so this is the only point that sees the colour the sockets land on.
|
|
2681
|
+
this.portOutline = readableOutlineOn(background);
|
|
2676
2682
|
// Entrance animation — scheme rises from below + fades in over
|
|
2677
2683
|
// the opaque background.
|
|
2678
2684
|
let introDy = 0;
|
|
@@ -3033,7 +3039,7 @@ export class Diagram {
|
|
|
3033
3039
|
ctx.fillStyle = this.portColor(this.portFillType(p));
|
|
3034
3040
|
ctx.fill();
|
|
3035
3041
|
ctx.lineWidth = magnet ? 1.5 : 1;
|
|
3036
|
-
ctx.strokeStyle = magnet ? '#ffffff' :
|
|
3042
|
+
ctx.strokeStyle = magnet ? '#ffffff' : this.portOutline;
|
|
3037
3043
|
ctx.stroke();
|
|
3038
3044
|
const runtimeSelected = runtime?.selected === true || (options.selection && this.selectedPort?.port === p);
|
|
3039
3045
|
const breakpoint = runtime?.breakpoint === true;
|