feat: Mark diagrams capable of handDrawn

This commit is contained in:
Sidharth Vinod
2025-11-05 00:22:14 +07:00
parent 6f29330dc8
commit f4e2b0dead
6 changed files with 26 additions and 9 deletions

View File

@@ -10,6 +10,9 @@ export const diagram: DiagramDefinition = {
get db() { get db() {
return new ClassDB(); return new ClassDB();
}, },
capabilities: {
handDrawn: true,
},
renderer, renderer,
styles, styles,
init: (cnf) => { init: (cnf) => {

View File

@@ -2,13 +2,16 @@
import erParser from './parser/erDiagram.jison'; import erParser from './parser/erDiagram.jison';
import { ErDB } from './erDb.js'; import { ErDB } from './erDb.js';
import * as renderer from './erRenderer-unified.js'; import * as renderer from './erRenderer-unified.js';
import erStyles from './styles.js'; import styles from './styles.js';
export const diagram = { export const diagram = {
parser: erParser, parser: erParser,
get db() { get db() {
return new ErDB(); return new ErDB();
}, },
capabilities: {
handDrawn: true,
},
renderer, renderer,
styles: erStyles, styles,
}; };

View File

@@ -13,6 +13,9 @@ export const diagram = {
return new FlowDB(); return new FlowDB();
}, },
renderer, renderer,
capabilities: {
handDrawn: true,
},
styles: flowStyles, styles: flowStyles,
init: (cnf: MermaidConfig) => { init: (cnf: MermaidConfig) => {
if (!cnf.flowchart) { if (!cnf.flowchart) {

View File

@@ -43,7 +43,7 @@ export const draw: DrawDefinition = (text, id, _version, diagObj) => {
const group: SVGGroup = svg.append('g'); const group: SVGGroup = svg.append('g');
group.attr('transform', 'translate(' + pieWidth / 2 + ',' + height / 2 + ')'); group.attr('transform', 'translate(' + pieWidth / 2 + ',' + height / 2 + ')');
const { themeVariables } = globalConfig; const { themeVariables, look } = globalConfig;
let [outerStrokeWidth] = parseFontSize(themeVariables.pieOuterStrokeWidth); let [outerStrokeWidth] = parseFontSize(themeVariables.pieOuterStrokeWidth);
outerStrokeWidth ??= 2; outerStrokeWidth ??= 2;
@@ -59,12 +59,14 @@ export const draw: DrawDefinition = (text, id, _version, diagObj) => {
.innerRadius(radius * textPosition) .innerRadius(radius * textPosition)
.outerRadius(radius * textPosition); .outerRadius(radius * textPosition);
group if (look !== 'handDrawn') {
.append('circle') group
.attr('cx', 0) .append('circle')
.attr('cy', 0) .attr('cx', 0)
.attr('r', radius + outerStrokeWidth / 2) .attr('cy', 0)
.attr('class', 'pieOuterCircle'); .attr('r', radius + outerStrokeWidth / 2)
.attr('class', 'pieOuterCircle');
}
const sections: Sections = db.getSections(); const sections: Sections = db.getSections();
const arcs: d3.PieArcDatum<D3Section>[] = createPieArcs(sections); const arcs: d3.PieArcDatum<D3Section>[] = createPieArcs(sections);

View File

@@ -10,6 +10,9 @@ export const diagram: DiagramDefinition = {
get db() { get db() {
return new RequirementDB(); return new RequirementDB();
}, },
capabilities: {
handDrawn: true,
},
renderer, renderer,
styles, styles,
}; };

View File

@@ -10,6 +10,9 @@ export const diagram: DiagramDefinition = {
get db() { get db() {
return new StateDB(2); return new StateDB(2);
}, },
capabilities: {
handDrawn: true,
},
renderer, renderer,
styles, styles,
init: (cnf) => { init: (cnf) => {