circuitscript 0.0.32 → 0.0.34
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/cjs/BaseVisitor.js +187 -39
- package/dist/cjs/antlr/CircuitScriptLexer.js +226 -185
- package/dist/cjs/antlr/CircuitScriptParser.js +1439 -902
- package/dist/cjs/draw_symbols.js +1 -0
- package/dist/cjs/execute.js +14 -12
- package/dist/cjs/globals.js +14 -2
- package/dist/cjs/helpers.js +62 -19
- package/dist/cjs/layout.js +88 -36
- package/dist/cjs/objects/ClassComponent.js +3 -0
- package/dist/cjs/objects/ExecutionScope.js +1 -0
- package/dist/cjs/objects/Frame.js +4 -1
- package/dist/cjs/objects/ParamDefinition.js +1 -7
- package/dist/cjs/objects/types.js +6 -0
- package/dist/cjs/regenerate-tests.js +2 -1
- package/dist/cjs/render.js +238 -42
- package/dist/cjs/visitor.js +162 -27
- package/dist/esm/BaseVisitor.mjs +189 -41
- package/dist/esm/antlr/CircuitScriptLexer.mjs +226 -185
- package/dist/esm/antlr/CircuitScriptParser.mjs +1428 -899
- package/dist/esm/antlr/CircuitScriptVisitor.mjs +9 -2
- package/dist/esm/draw_symbols.mjs +1 -0
- package/dist/esm/execute.mjs +14 -12
- package/dist/esm/globals.mjs +13 -1
- package/dist/esm/helpers.mjs +61 -20
- package/dist/esm/layout.mjs +88 -37
- package/dist/esm/objects/ClassComponent.mjs +3 -0
- package/dist/esm/objects/ExecutionScope.mjs +1 -0
- package/dist/esm/objects/Frame.mjs +5 -1
- package/dist/esm/objects/ParamDefinition.mjs +0 -6
- package/dist/esm/objects/types.mjs +6 -0
- package/dist/esm/regenerate-tests.mjs +2 -1
- package/dist/esm/render.mjs +234 -43
- package/dist/esm/visitor.mjs +164 -29
- package/dist/types/BaseVisitor.d.ts +8 -2
- package/dist/types/antlr/CircuitScriptLexer.d.ts +41 -30
- package/dist/types/antlr/CircuitScriptParser.d.ts +169 -81
- package/dist/types/antlr/CircuitScriptVisitor.d.ts +18 -4
- package/dist/types/draw_symbols.d.ts +2 -1
- package/dist/types/execute.d.ts +6 -3
- package/dist/types/globals.d.ts +11 -0
- package/dist/types/helpers.d.ts +12 -0
- package/dist/types/layout.d.ts +17 -9
- package/dist/types/objects/ClassComponent.d.ts +2 -1
- package/dist/types/objects/ExecutionScope.d.ts +2 -0
- package/dist/types/objects/Frame.d.ts +6 -2
- package/dist/types/objects/ParamDefinition.d.ts +0 -4
- package/dist/types/objects/types.d.ts +4 -2
- package/dist/types/render.d.ts +6 -14
- package/dist/types/visitor.d.ts +10 -2
- package/libs/lib.cst +283 -0
- package/package.json +1 -1
package/dist/types/layout.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Graph, Edge } from '@dagrejs/graphlib';
|
|
2
|
-
import { SymbolGraphic, SymbolText } from "./draw_symbols.js";
|
|
2
|
+
import { SymbolGraphic, SymbolText, SymbolDrawingCommands } from "./draw_symbols.js";
|
|
3
3
|
import { ClassComponent } from "./objects/ClassComponent.js";
|
|
4
4
|
import { SequenceItem } from "./objects/ExecutionScope.js";
|
|
5
5
|
import { WireAutoDirection } from './globals.js';
|
|
@@ -19,14 +19,8 @@ export declare class LayoutEngine {
|
|
|
19
19
|
protected print(...params: any[]): void;
|
|
20
20
|
protected printLevel(level: number, ...params: any[]): void;
|
|
21
21
|
protected padLevel(value: number): string;
|
|
22
|
-
runLayout(sequence: SequenceItem[], nets: [ClassComponent, pin: number, net: Net][]):
|
|
23
|
-
|
|
24
|
-
wires: RenderWire[];
|
|
25
|
-
junctions: RenderJunction[];
|
|
26
|
-
mergedWires: MergedWire[];
|
|
27
|
-
frameObjects: RenderFrame[];
|
|
28
|
-
textObjects: RenderText[];
|
|
29
|
-
};
|
|
22
|
+
runLayout(sequence: SequenceItem[], nets: [ClassComponent, pin: number, net: Net][]): SheetFrame[];
|
|
23
|
+
private flattenFrameItems;
|
|
30
24
|
findJunctions(wireGroups: Map<string, RenderWire[]>): {
|
|
31
25
|
junctions: RenderJunction[];
|
|
32
26
|
mergedWires: MergedWire[];
|
|
@@ -130,6 +124,7 @@ export declare class RenderFrame extends RenderObject {
|
|
|
130
124
|
borderWidth: number;
|
|
131
125
|
width: number | null;
|
|
132
126
|
height: number | null;
|
|
127
|
+
size: string | null;
|
|
133
128
|
subgraphId: string;
|
|
134
129
|
type: RenderFrameType;
|
|
135
130
|
containsTitle: boolean;
|
|
@@ -145,11 +140,24 @@ export declare class RenderJunction {
|
|
|
145
140
|
y: number;
|
|
146
141
|
constructor(x: number, y: number);
|
|
147
142
|
}
|
|
143
|
+
export type SheetFrame = {
|
|
144
|
+
frame: RenderFrame;
|
|
145
|
+
frames: RenderFrame[];
|
|
146
|
+
components: RenderComponent[];
|
|
147
|
+
wires: RenderWire[];
|
|
148
|
+
textObjects: RenderText[];
|
|
149
|
+
junctions: RenderJunction[];
|
|
150
|
+
mergedWires: MergedWire[];
|
|
151
|
+
};
|
|
148
152
|
export declare function CalculatePinPositions(component: ClassComponent): Map<number, {
|
|
149
153
|
x: number;
|
|
150
154
|
y: number;
|
|
151
155
|
angle: number;
|
|
152
156
|
}>;
|
|
157
|
+
export declare function ExtractDrawingRects(drawing: SymbolDrawingCommands): {
|
|
158
|
+
width: number;
|
|
159
|
+
height: number;
|
|
160
|
+
}[];
|
|
153
161
|
type SubGraphInfo = {
|
|
154
162
|
firstNodeId: string;
|
|
155
163
|
components: string[];
|
|
@@ -42,10 +42,11 @@ export declare class ClassComponent {
|
|
|
42
42
|
getPin(pinId: number | string): PinId;
|
|
43
43
|
getNextPinAfter(pinIndex: number): number;
|
|
44
44
|
setParam(key: string, value: number | string): void;
|
|
45
|
+
hasParam(key: string): boolean;
|
|
45
46
|
private refreshParamCache;
|
|
46
47
|
private refreshPinsCache;
|
|
47
48
|
refreshCache(): void;
|
|
48
|
-
getParam(key: string):
|
|
49
|
+
getParam<T>(key: string): T;
|
|
49
50
|
toString(): string;
|
|
50
51
|
static simple(instanceName: string, numPins: number, className: string): ClassComponent;
|
|
51
52
|
isEqual(other: ClassComponent): boolean;
|
|
@@ -4,6 +4,7 @@ import { CFunction, ComponentPinNet, ComponentPinNetPair, ParseSymbolType, Value
|
|
|
4
4
|
import { LayoutDirection } from '../globals.js';
|
|
5
5
|
import { Wire, WireSegment } from './Wire.js';
|
|
6
6
|
import { Frame } from './Frame.js';
|
|
7
|
+
import { ParserRuleContext } from 'antlr4ng';
|
|
7
8
|
export declare class ExecutionScope {
|
|
8
9
|
scopeId: number;
|
|
9
10
|
private nets;
|
|
@@ -14,6 +15,7 @@ export declare class ExecutionScope {
|
|
|
14
15
|
type: ParseSymbolType;
|
|
15
16
|
}>;
|
|
16
17
|
blockStack: Map<number, any>;
|
|
18
|
+
breakStack: ParserRuleContext[];
|
|
17
19
|
wires: Wire[];
|
|
18
20
|
frames: Frame[];
|
|
19
21
|
indentLevel: number;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { FrameType } from "src/globals";
|
|
1
2
|
export declare class Frame {
|
|
2
3
|
parameters: Map<string, any>;
|
|
3
4
|
frameId: number;
|
|
4
|
-
|
|
5
|
+
frameType: FrameType;
|
|
6
|
+
constructor(frameId: number, frameType: FrameType);
|
|
5
7
|
}
|
|
6
8
|
export declare enum FrameParamKeys {
|
|
7
9
|
Title = "title",
|
|
@@ -9,7 +11,9 @@ export declare enum FrameParamKeys {
|
|
|
9
11
|
Padding = "padding",
|
|
10
12
|
Border = "border",
|
|
11
13
|
Width = "width",
|
|
12
|
-
Height = "height"
|
|
14
|
+
Height = "height",
|
|
15
|
+
PaperSize = "paper_size",
|
|
16
|
+
SheetFrame = "sheet_frame"
|
|
13
17
|
}
|
|
14
18
|
export declare enum FramePlotDirection {
|
|
15
19
|
Row = "row",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ExecutionContext } from '../execute.js';
|
|
2
2
|
import { ClassComponent } from './ClassComponent.js';
|
|
3
3
|
import { Net } from './Net.js';
|
|
4
|
-
import { NumericValue, PercentageValue
|
|
4
|
+
import { NumericValue, PercentageValue } from './ParamDefinition.js';
|
|
5
5
|
export type CFunction = (args: CallableParameter[], options?: CFunctionOptions) => CFunctionResult;
|
|
6
6
|
export type CFunctionOptions = {
|
|
7
7
|
netNamespace?: string;
|
|
@@ -25,7 +25,7 @@ export type ComponentPin = [
|
|
|
25
25
|
pinId: number | string
|
|
26
26
|
];
|
|
27
27
|
export type ComplexType = ValueType | ClassComponent | UndeclaredReference | null;
|
|
28
|
-
export type ValueType = boolean | number | string | NumericValue | PercentageValue
|
|
28
|
+
export type ValueType = boolean | number | string | NumericValue | PercentageValue;
|
|
29
29
|
export type CallableParameter = [
|
|
30
30
|
'keyword',
|
|
31
31
|
key: string,
|
|
@@ -39,6 +39,7 @@ export type FunctionDefinedParameter = [name: string, defaultValue: ValueType] |
|
|
|
39
39
|
export declare class UndeclaredReference {
|
|
40
40
|
reference: ReferenceType;
|
|
41
41
|
constructor(reference: ReferenceType);
|
|
42
|
+
throwMessage(): string;
|
|
42
43
|
}
|
|
43
44
|
export declare class DeclaredReference {
|
|
44
45
|
found: boolean;
|
|
@@ -47,6 +48,7 @@ export declare class DeclaredReference {
|
|
|
47
48
|
type?: string;
|
|
48
49
|
value?: any;
|
|
49
50
|
constructor(refType: ReferenceType);
|
|
51
|
+
toString(): string;
|
|
50
52
|
}
|
|
51
53
|
export type ReferenceType = {
|
|
52
54
|
found: boolean;
|
package/dist/types/render.d.ts
CHANGED
|
@@ -1,14 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
debugRects?: BoundBox[];
|
|
8
|
-
frameObjects: RenderFrame[];
|
|
9
|
-
textObjects: RenderText[];
|
|
10
|
-
}): {
|
|
11
|
-
svg: string;
|
|
12
|
-
width: number;
|
|
13
|
-
height: number;
|
|
14
|
-
};
|
|
1
|
+
/// <reference types="pdfkit" />
|
|
2
|
+
import { Svg } from '@svgdotjs/svg.js';
|
|
3
|
+
import { SheetFrame } from "./layout.js";
|
|
4
|
+
export declare function renderSheetsToSVG(sheetFrames: SheetFrame[]): Svg;
|
|
5
|
+
export declare function generateSvgOutput(canvas: Svg, zoomScale?: number): string;
|
|
6
|
+
export declare function generatePdfOutput(doc: PDFKit.PDFDocument, canvas: Svg, sheetSize: string, sheetSizeDefined: boolean, zoomScale?: number): void;
|
package/dist/types/visitor.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Add_component_exprContext, AdditionExprContext, At_blockContext, At_block_pin_exprContext, At_block_pin_expression_complexContext, At_block_pin_expression_simpleContext, At_component_exprContext, BinaryOperatorExprContext, Path_blocksContext, Component_select_exprContext, Create_component_exprContext, Create_graphic_exprContext, DataExprContext, Data_expr_with_assignmentContext, Double_dot_property_set_exprContext, Frame_exprContext, Function_def_exprContext, Keyword_assignment_exprContext, MultiplyExprContext, Nested_propertiesContext, Net_namespace_exprContext, Pin_select_expr2Context, Pin_select_exprContext, Point_exprContext, Property_exprContext, Property_key_exprContext, Property_set_exprContext, Single_line_propertyContext, To_component_exprContext, Wire_exprContext, UnaryOperatorExprContext, Wire_expr_direction_onlyContext, Wire_expr_direction_valueContext,
|
|
1
|
+
import { Add_component_exprContext, AdditionExprContext, At_blockContext, At_block_pin_exprContext, At_block_pin_expression_complexContext, At_block_pin_expression_simpleContext, At_component_exprContext, BinaryOperatorExprContext, Path_blocksContext, Component_select_exprContext, Create_component_exprContext, Create_graphic_exprContext, DataExprContext, Data_expr_with_assignmentContext, Double_dot_property_set_exprContext, Frame_exprContext, Function_def_exprContext, Keyword_assignment_exprContext, MultiplyExprContext, Nested_propertiesContext, Net_namespace_exprContext, Pin_select_expr2Context, Pin_select_exprContext, Point_exprContext, Property_exprContext, Property_key_exprContext, Property_set_exprContext, Single_line_propertyContext, To_component_exprContext, Wire_exprContext, UnaryOperatorExprContext, Wire_expr_direction_onlyContext, Wire_expr_direction_valueContext, If_exprContext, If_inner_exprContext, LogicalOperatorExprContext, Nested_properties_innerContext, Expressions_blockContext, Create_module_exprContext, Property_block_exprContext, While_exprContext, For_exprContext, GraphicCommandExprContext, Graphic_expressions_blockContext, GraphicForExprContext } from './antlr/CircuitScriptParser.js';
|
|
2
2
|
import { ClassComponent } from './objects/ClassComponent.js';
|
|
3
3
|
import { PinTypes } from './objects/PinTypes.js';
|
|
4
4
|
import { ComponentPin, ComponentPinNet } from './objects/types.js';
|
|
@@ -15,7 +15,9 @@ export declare class ParserVisitor extends BaseVisitor {
|
|
|
15
15
|
visitPath_blocks: (ctx: Path_blocksContext) => ComponentPin;
|
|
16
16
|
visitCreate_component_expr: (ctx: Create_component_exprContext) => void;
|
|
17
17
|
visitCreate_graphic_expr: (ctx: Create_graphic_exprContext) => void;
|
|
18
|
-
|
|
18
|
+
visitGraphic_expressions_block: (ctx: Graphic_expressions_blockContext) => void;
|
|
19
|
+
visitGraphicCommandExpr: (ctx: GraphicCommandExprContext) => void;
|
|
20
|
+
visitGraphicForExpr: (ctx: GraphicForExprContext) => void;
|
|
19
21
|
visitCreate_module_expr: (ctx: Create_module_exprContext) => void;
|
|
20
22
|
visitProperty_block_expr: (ctx: Property_block_exprContext) => void;
|
|
21
23
|
visitProperty_expr: (ctx: Property_exprContext) => void;
|
|
@@ -50,6 +52,9 @@ export declare class ParserVisitor extends BaseVisitor {
|
|
|
50
52
|
visitNet_namespace_expr: (ctx: Net_namespace_exprContext) => void;
|
|
51
53
|
visitIf_expr: (ctx: If_exprContext) => void;
|
|
52
54
|
visitIf_inner_expr: (ctx: If_inner_exprContext) => void;
|
|
55
|
+
visitWhile_expr: (ctx: While_exprContext) => void;
|
|
56
|
+
visitFor_expr: (ctx: For_exprContext) => void;
|
|
57
|
+
private resolveDataExpr;
|
|
53
58
|
pinTypes: PinTypes[];
|
|
54
59
|
private parseCreateComponentPins;
|
|
55
60
|
private parseCreateModulePorts;
|
|
@@ -71,6 +76,9 @@ export declare class ParserVisitor extends BaseVisitor {
|
|
|
71
76
|
components: ClassComponent[];
|
|
72
77
|
};
|
|
73
78
|
annotateComponents(): void;
|
|
79
|
+
applySheetFrameComponent(): {
|
|
80
|
+
frameComponent: ClassComponent | null;
|
|
81
|
+
};
|
|
74
82
|
private resolveNets;
|
|
75
83
|
private setComponentOrientation;
|
|
76
84
|
private setComponentFlip;
|
package/libs/lib.cst
CHANGED
|
@@ -220,3 +220,286 @@ def arrow_point():
|
|
|
220
220
|
path: ("M", -10, -5, "L", -5, 0, "L", -10, 5)
|
|
221
221
|
path: ("M", -5, 0, "L", -20, 0)
|
|
222
222
|
hpin: 1, 0, 0, 0, display_pin_id=false
|
|
223
|
+
|
|
224
|
+
def frame_generator(paper_size_name, paper_width, paper_height, margin_x, margin_y):
|
|
225
|
+
inner_frame_margin = 50
|
|
226
|
+
return create component:
|
|
227
|
+
type: "frame"
|
|
228
|
+
display: create graphic:
|
|
229
|
+
fill: "none"
|
|
230
|
+
|
|
231
|
+
# outer rect
|
|
232
|
+
lineColor: "#cccccc"
|
|
233
|
+
rect: paper_width/2, paper_height/2, paper_width, paper_height
|
|
234
|
+
|
|
235
|
+
# inner rect
|
|
236
|
+
lineColor: "#111111"
|
|
237
|
+
rect: paper_width/2, paper_height/2, paper_width - 2 * margin_x, paper_height - 2 * margin_y
|
|
238
|
+
|
|
239
|
+
rect: (paper_width/2, paper_height/2,
|
|
240
|
+
paper_width - 2 * margin_x + inner_frame_margin * 2,
|
|
241
|
+
paper_height - 2 * margin_y + inner_frame_margin * 2)
|
|
242
|
+
|
|
243
|
+
params:
|
|
244
|
+
paper_size: paper_size_name
|
|
245
|
+
paper_width: paper_width
|
|
246
|
+
paper_height: paper_height
|
|
247
|
+
|
|
248
|
+
offset_x: margin_x
|
|
249
|
+
offset_y: margin_y
|
|
250
|
+
|
|
251
|
+
grid_width: paper_width - 2 * margin_x
|
|
252
|
+
grid_height: paper_height - 2 * margin_y
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
def frame_A4 ():
|
|
256
|
+
paper_width = 297 / 25.4 * 1000
|
|
257
|
+
paper_height = 210 / 25.4 * 1000
|
|
258
|
+
margin_x = 400
|
|
259
|
+
margin_y = 400
|
|
260
|
+
|
|
261
|
+
inner_frame_margin = 50
|
|
262
|
+
|
|
263
|
+
horizontal_1 = margin_x - inner_frame_margin
|
|
264
|
+
horizontal_2 = paper_width - margin_x + inner_frame_margin
|
|
265
|
+
|
|
266
|
+
vertical_1 = margin_y - inner_frame_margin
|
|
267
|
+
vertical_2 = paper_height - margin_y + inner_frame_margin
|
|
268
|
+
|
|
269
|
+
tmp_height = paper_height - margin_y * 2 + inner_frame_margin * 2
|
|
270
|
+
tmp_y = margin_y - inner_frame_margin
|
|
271
|
+
|
|
272
|
+
tmp_width = paper_width - margin_x * 2 + inner_frame_margin * 2
|
|
273
|
+
tmp_x = margin_x - inner_frame_margin
|
|
274
|
+
|
|
275
|
+
fontSize = 30
|
|
276
|
+
|
|
277
|
+
ratio_x = 0.16667
|
|
278
|
+
ratio_y = 0.25
|
|
279
|
+
|
|
280
|
+
return create component:
|
|
281
|
+
type: "frame"
|
|
282
|
+
display: create graphic:
|
|
283
|
+
fill: "none"
|
|
284
|
+
|
|
285
|
+
# outer rect
|
|
286
|
+
lineColor: "#cccccc"
|
|
287
|
+
rect: paper_width/2, paper_height/2, paper_width, paper_height
|
|
288
|
+
|
|
289
|
+
# inner rect
|
|
290
|
+
lineColor: "#111111"
|
|
291
|
+
rect: paper_width/2, paper_height/2, paper_width - 2 * margin_x, paper_height - 2 * margin_y
|
|
292
|
+
|
|
293
|
+
rect: (paper_width/2, paper_height/2,
|
|
294
|
+
paper_width - 2 * margin_x + inner_frame_margin * 2,
|
|
295
|
+
paper_height - 2 * margin_y + inner_frame_margin * 2)
|
|
296
|
+
|
|
297
|
+
hline: horizontal_1, (tmp_y + tmp_height * ratio_y), inner_frame_margin
|
|
298
|
+
hline: horizontal_1, (tmp_y + tmp_height * ratio_y * 2), inner_frame_margin
|
|
299
|
+
hline: horizontal_1, (tmp_y + tmp_height * ratio_y * 3), inner_frame_margin
|
|
300
|
+
|
|
301
|
+
hline: horizontal_2, (tmp_y + tmp_height * ratio_y), -inner_frame_margin
|
|
302
|
+
hline: horizontal_2, (tmp_y + tmp_height * ratio_y * 2), -inner_frame_margin
|
|
303
|
+
hline: horizontal_2, (tmp_y + tmp_height * ratio_y * 3), -inner_frame_margin
|
|
304
|
+
|
|
305
|
+
vline: (tmp_x + tmp_width * ratio_x), vertical_1, inner_frame_margin
|
|
306
|
+
vline: (tmp_x + tmp_width * ratio_x * 2), vertical_1, inner_frame_margin
|
|
307
|
+
vline: (tmp_x + tmp_width * ratio_x * 3), vertical_1, inner_frame_margin
|
|
308
|
+
vline: (tmp_x + tmp_width * ratio_x * 4), vertical_1, inner_frame_margin
|
|
309
|
+
vline: (tmp_x + tmp_width * ratio_x * 5), vertical_1, inner_frame_margin
|
|
310
|
+
|
|
311
|
+
vline: (tmp_x + tmp_width * ratio_x), vertical_2, -inner_frame_margin
|
|
312
|
+
vline: (tmp_x + tmp_width * ratio_x * 2), vertical_2, -inner_frame_margin
|
|
313
|
+
vline: (tmp_x + tmp_width * ratio_x * 3), vertical_2, -inner_frame_margin
|
|
314
|
+
vline: (tmp_x + tmp_width * ratio_x * 4), vertical_2, -inner_frame_margin
|
|
315
|
+
vline: (tmp_x + tmp_width * ratio_x * 5), vertical_2, -inner_frame_margin
|
|
316
|
+
|
|
317
|
+
# labels on the columns
|
|
318
|
+
text:
|
|
319
|
+
content: "1"
|
|
320
|
+
offset: tmp_x + tmp_width * ratio_x * 0.5, tmp_y + inner_frame_margin * 0.5 + 2
|
|
321
|
+
fontSize: fontSize
|
|
322
|
+
anchor: "middle"
|
|
323
|
+
vanchor: "middle"
|
|
324
|
+
|
|
325
|
+
text:
|
|
326
|
+
content: "1"
|
|
327
|
+
offset: tmp_x + tmp_width * ratio_x * 0.5, tmp_y + tmp_height - inner_frame_margin * 0.5 + 2
|
|
328
|
+
fontSize: fontSize
|
|
329
|
+
anchor: "middle"
|
|
330
|
+
vanchor: "middle"
|
|
331
|
+
|
|
332
|
+
text:
|
|
333
|
+
content: "2"
|
|
334
|
+
offset: tmp_x + tmp_width * ratio_x * 1.5, tmp_y + inner_frame_margin * 0.5 + 2
|
|
335
|
+
fontSize: fontSize
|
|
336
|
+
anchor: "middle"
|
|
337
|
+
vanchor: "middle"
|
|
338
|
+
|
|
339
|
+
text:
|
|
340
|
+
content: "2"
|
|
341
|
+
offset: tmp_x + tmp_width * ratio_x * 1.5, tmp_y + tmp_height - inner_frame_margin * 0.5 + 2
|
|
342
|
+
fontSize: fontSize
|
|
343
|
+
anchor: "middle"
|
|
344
|
+
vanchor: "middle"
|
|
345
|
+
|
|
346
|
+
text:
|
|
347
|
+
content: "3"
|
|
348
|
+
offset: tmp_x + tmp_width * ratio_x * 2.5, tmp_y + inner_frame_margin * 0.5 + 2
|
|
349
|
+
fontSize: fontSize
|
|
350
|
+
anchor: "middle"
|
|
351
|
+
vanchor: "middle"
|
|
352
|
+
|
|
353
|
+
text:
|
|
354
|
+
content: "3"
|
|
355
|
+
offset: tmp_x + tmp_width * ratio_x * 2.5, tmp_y + tmp_height - inner_frame_margin * 0.5 + 2
|
|
356
|
+
fontSize: fontSize
|
|
357
|
+
anchor: "middle"
|
|
358
|
+
vanchor: "middle"
|
|
359
|
+
|
|
360
|
+
text:
|
|
361
|
+
content: "4"
|
|
362
|
+
offset: tmp_x + tmp_width * ratio_x * 3.5, tmp_y + inner_frame_margin * 0.5 + 2
|
|
363
|
+
fontSize: fontSize
|
|
364
|
+
anchor: "middle"
|
|
365
|
+
vanchor: "middle"
|
|
366
|
+
|
|
367
|
+
text:
|
|
368
|
+
content: "4"
|
|
369
|
+
offset: tmp_x + tmp_width * ratio_x * 3.5, tmp_y + tmp_height - inner_frame_margin * 0.5 + 2
|
|
370
|
+
fontSize: fontSize
|
|
371
|
+
anchor: "middle"
|
|
372
|
+
vanchor: "middle"
|
|
373
|
+
|
|
374
|
+
text:
|
|
375
|
+
content: "5"
|
|
376
|
+
offset: tmp_x + tmp_width * ratio_x * 4.5, tmp_y + inner_frame_margin * 0.5 + 2
|
|
377
|
+
fontSize: fontSize
|
|
378
|
+
anchor: "middle"
|
|
379
|
+
vanchor: "middle"
|
|
380
|
+
|
|
381
|
+
text:
|
|
382
|
+
content: "5"
|
|
383
|
+
offset: tmp_x + tmp_width * ratio_x * 4.5, tmp_y + tmp_height - inner_frame_margin * 0.5 + 2
|
|
384
|
+
fontSize: fontSize
|
|
385
|
+
anchor: "middle"
|
|
386
|
+
vanchor: "middle"
|
|
387
|
+
|
|
388
|
+
text:
|
|
389
|
+
content: "6"
|
|
390
|
+
offset: tmp_x + tmp_width * ratio_x * 5.5, tmp_y + inner_frame_margin * 0.5 + 2
|
|
391
|
+
fontSize: fontSize
|
|
392
|
+
anchor: "middle"
|
|
393
|
+
vanchor: "middle"
|
|
394
|
+
|
|
395
|
+
text:
|
|
396
|
+
content: "6"
|
|
397
|
+
offset: tmp_x + tmp_width * ratio_x * 5.5, tmp_y + tmp_height - inner_frame_margin * 0.5 + 2
|
|
398
|
+
fontSize: fontSize
|
|
399
|
+
anchor: "middle"
|
|
400
|
+
vanchor: "middle"
|
|
401
|
+
|
|
402
|
+
# labels on the rows
|
|
403
|
+
text:
|
|
404
|
+
content: "A"
|
|
405
|
+
offset: tmp_x + inner_frame_margin * 0.5, tmp_y + tmp_height * ratio_y * 0.5
|
|
406
|
+
fontSize: fontSize
|
|
407
|
+
anchor: "middle"
|
|
408
|
+
vanchor: "middle"
|
|
409
|
+
|
|
410
|
+
text:
|
|
411
|
+
content: "A"
|
|
412
|
+
offset: tmp_x + tmp_width - inner_frame_margin * 0.5, tmp_y + tmp_height * ratio_y * 0.5
|
|
413
|
+
fontSize: fontSize
|
|
414
|
+
anchor: "middle"
|
|
415
|
+
vanchor: "middle"
|
|
416
|
+
|
|
417
|
+
text:
|
|
418
|
+
content: "B"
|
|
419
|
+
offset: tmp_x + inner_frame_margin * 0.5, tmp_y + tmp_height * ratio_y * 1.5
|
|
420
|
+
fontSize: fontSize
|
|
421
|
+
anchor: "middle"
|
|
422
|
+
vanchor: "middle"
|
|
423
|
+
|
|
424
|
+
text:
|
|
425
|
+
content: "B"
|
|
426
|
+
offset: tmp_x + tmp_width - inner_frame_margin * 0.5, tmp_y + tmp_height * ratio_y * 1.5
|
|
427
|
+
fontSize: fontSize
|
|
428
|
+
anchor: "middle"
|
|
429
|
+
vanchor: "middle"
|
|
430
|
+
|
|
431
|
+
text:
|
|
432
|
+
content: "C"
|
|
433
|
+
offset: tmp_x + inner_frame_margin * 0.5, tmp_y + tmp_height * ratio_y * 2.5
|
|
434
|
+
fontSize: fontSize
|
|
435
|
+
anchor: "middle"
|
|
436
|
+
vanchor: "middle"
|
|
437
|
+
|
|
438
|
+
text:
|
|
439
|
+
content: "C"
|
|
440
|
+
offset: tmp_x + tmp_width - inner_frame_margin * 0.5, tmp_y + tmp_height * ratio_y * 2.5
|
|
441
|
+
fontSize: fontSize
|
|
442
|
+
anchor: "middle"
|
|
443
|
+
vanchor: "middle"
|
|
444
|
+
|
|
445
|
+
text:
|
|
446
|
+
content: "D"
|
|
447
|
+
offset: tmp_x + inner_frame_margin * 0.5, tmp_y + tmp_height * ratio_y * 3.5
|
|
448
|
+
fontSize: fontSize
|
|
449
|
+
anchor: "middle"
|
|
450
|
+
vanchor: "middle"
|
|
451
|
+
|
|
452
|
+
text:
|
|
453
|
+
content: "D"
|
|
454
|
+
offset: tmp_x + tmp_width - inner_frame_margin * 0.5, tmp_y + tmp_height * ratio_y * 3.5
|
|
455
|
+
fontSize: fontSize
|
|
456
|
+
anchor: "middle"
|
|
457
|
+
vanchor: "middle"
|
|
458
|
+
|
|
459
|
+
params:
|
|
460
|
+
paper_size: "A4"
|
|
461
|
+
paper_width: paper_width
|
|
462
|
+
paper_height: paper_height
|
|
463
|
+
|
|
464
|
+
offset_x: margin_x
|
|
465
|
+
offset_y: margin_y
|
|
466
|
+
|
|
467
|
+
grid_width: paper_width - 2 * margin_x
|
|
468
|
+
grid_height: paper_height - 2 * margin_y
|
|
469
|
+
|
|
470
|
+
|
|
471
|
+
def frame_generator(paper_size_name, paper_width, paper_height, margin_x, margin_y, inner_frame_margin = 50):
|
|
472
|
+
return create component:
|
|
473
|
+
type: "frame"
|
|
474
|
+
display: create graphic:
|
|
475
|
+
fill: "none"
|
|
476
|
+
|
|
477
|
+
# outer rect
|
|
478
|
+
lineColor: "#cccccc"
|
|
479
|
+
rect: paper_width/2, paper_height/2, paper_width, paper_height
|
|
480
|
+
|
|
481
|
+
# inner rect
|
|
482
|
+
lineColor: "#111111"
|
|
483
|
+
rect: paper_width/2, paper_height/2, paper_width - 2 * margin_x, paper_height - 2 * margin_y
|
|
484
|
+
|
|
485
|
+
rect: (paper_width/2, paper_height/2,
|
|
486
|
+
paper_width - 2 * margin_x + inner_frame_margin * 2,
|
|
487
|
+
paper_height - 2 * margin_y + inner_frame_margin * 2)
|
|
488
|
+
|
|
489
|
+
params:
|
|
490
|
+
paper_size: paper_size_name
|
|
491
|
+
paper_width: paper_width
|
|
492
|
+
paper_height: paper_height
|
|
493
|
+
|
|
494
|
+
offset_x: margin_x
|
|
495
|
+
offset_y: margin_y
|
|
496
|
+
|
|
497
|
+
grid_width: paper_width - 2 * margin_x
|
|
498
|
+
grid_height: paper_height - 2 * margin_y
|
|
499
|
+
|
|
500
|
+
def frame_A6():
|
|
501
|
+
paper_width = 148 / 25.4 * 1000
|
|
502
|
+
paper_height = 105 / 25.4 * 1000
|
|
503
|
+
margin = 400
|
|
504
|
+
|
|
505
|
+
return frame_generator("A6", paper_width, paper_height, margin, margin, 20)
|