@mlightcad/graphic-interface 3.2.4 → 3.2.6
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/LICENSE +21 -21
- package/README.md +210 -210
- package/package.json +3 -3
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2025 mlight-lee
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 mlight-lee
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,211 +1,211 @@
|
|
|
1
|
-
# @mlightcad/graphic-interface
|
|
2
|
-
|
|
3
|
-
The graphic-interface package provides the graphics interface for controlling how AutoCAD entities are displayed on screen. This package offers a simplified API compared to AutoCAD ObjectARX's AcGi classes, making it more developer-friendly while maintaining the core functionality needed for rendering CAD entities.
|
|
4
|
-
|
|
5
|
-
## Overview
|
|
6
|
-
|
|
7
|
-
This package provides the graphics interface layer that bridges the gap between the data model and the rendering system. It handles the conversion of AutoCAD entities into drawable objects and provides customization options for how objects are displayed, including colors, layers, visibility, and various rendering styles.
|
|
8
|
-
|
|
9
|
-
## Key Features
|
|
10
|
-
|
|
11
|
-
- **Entity Rendering**: Convert AutoCAD entities to drawable objects
|
|
12
|
-
- **Style Customization**: Control colors, line styles, text styles, and point styles
|
|
13
|
-
- **View Management**: Handle different views and viewports
|
|
14
|
-
- **Arrow and Hatch Support**: Custom arrow types and hatch pattern rendering
|
|
15
|
-
- **Image Rendering**: Support for raster image display
|
|
16
|
-
- **Flexible Rendering**: Extensible rendering system for different output formats
|
|
17
|
-
|
|
18
|
-
## Installation
|
|
19
|
-
|
|
20
|
-
```bash
|
|
21
|
-
npm install @mlightcad/graphic-interface
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
## Key Classes
|
|
25
|
-
|
|
26
|
-
### Core Rendering Classes
|
|
27
|
-
- **AcGiRenderer**: Main interface for rendering entities to drawable objects
|
|
28
|
-
- **AcGiEntity**: Base class for drawable objects that can be rendered
|
|
29
|
-
- **AcGiView**: Represents a view with camera and projection settings
|
|
30
|
-
- **AcGiViewport**: Manages viewport settings and clipping
|
|
31
|
-
|
|
32
|
-
### Style Classes
|
|
33
|
-
- **AcGiArrowType**: Defines different arrow types for dimensions and leaders
|
|
34
|
-
- **AcGiHatchStyle**: Controls hatch pattern rendering and appearance
|
|
35
|
-
- **AcGiImageStyle**: Manages raster image display properties
|
|
36
|
-
- **AcGiLineStyle**: Defines line styles including dash patterns and widths
|
|
37
|
-
- **AcGiPointStyle**: Controls point entity display appearance
|
|
38
|
-
- **AcGiTextStyle**: Manages text rendering properties and formatting
|
|
39
|
-
|
|
40
|
-
## Usage Examples
|
|
41
|
-
|
|
42
|
-
### Basic Entity Rendering
|
|
43
|
-
```typescript
|
|
44
|
-
import { AcGiRenderer, AcGiEntity } from '@mlightcad/graphic-interface';
|
|
45
|
-
import { AcDbLine, AcGePoint3d } from '@mlightcad/data-model';
|
|
46
|
-
|
|
47
|
-
// Create a renderer
|
|
48
|
-
const renderer = new AcGiRenderer();
|
|
49
|
-
|
|
50
|
-
// Create an entity
|
|
51
|
-
const startPoint = new AcGePoint3d(0, 0, 0);
|
|
52
|
-
const endPoint = new AcGePoint3d(10, 10, 0);
|
|
53
|
-
const line = new AcDbLine(startPoint, endPoint);
|
|
54
|
-
|
|
55
|
-
// Render the entity
|
|
56
|
-
const drawableEntity = renderer.renderEntity(line);
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
### Style Configuration
|
|
60
|
-
```typescript
|
|
61
|
-
import {
|
|
62
|
-
AcGiLineStyle,
|
|
63
|
-
AcGiTextStyle,
|
|
64
|
-
AcGiPointStyle,
|
|
65
|
-
AcGiArrowType
|
|
66
|
-
} from '@mlightcad/graphic-interface';
|
|
67
|
-
|
|
68
|
-
// Configure line style
|
|
69
|
-
const lineStyle = new AcGiLineStyle();
|
|
70
|
-
lineStyle.setColor(1); // Red
|
|
71
|
-
lineStyle.setWidth(2.0);
|
|
72
|
-
lineStyle.setDashPattern([10, 5, 5, 5]); // Dashed line
|
|
73
|
-
|
|
74
|
-
// Configure text style
|
|
75
|
-
const textStyle = new AcGiTextStyle();
|
|
76
|
-
textStyle.setFont('Arial');
|
|
77
|
-
textStyle.setHeight(12);
|
|
78
|
-
textStyle.setColor(2); // Yellow
|
|
79
|
-
textStyle.setBold(true);
|
|
80
|
-
|
|
81
|
-
// Configure point style
|
|
82
|
-
const pointStyle = new AcGiPointStyle();
|
|
83
|
-
pointStyle.setSize(5);
|
|
84
|
-
pointStyle.setShape('Circle');
|
|
85
|
-
pointStyle.setColor(3); // Green
|
|
86
|
-
|
|
87
|
-
// Configure arrow style
|
|
88
|
-
const arrowStyle = new AcGiArrowType();
|
|
89
|
-
arrowStyle.setType('ClosedFilled');
|
|
90
|
-
arrowStyle.setSize(3);
|
|
91
|
-
arrowStyle.setColor(1); // Red
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
### View and Viewport Management
|
|
95
|
-
```typescript
|
|
96
|
-
import { AcGiView, AcGiViewport, AcGePoint3d } from '@mlightcad/graphic-interface';
|
|
97
|
-
|
|
98
|
-
// Create a view
|
|
99
|
-
const view = new AcGiView();
|
|
100
|
-
view.setEyePoint(new AcGePoint3d(0, 0, 100));
|
|
101
|
-
view.setTargetPoint(new AcGePoint3d(0, 0, 0));
|
|
102
|
-
view.setUpVector(new AcGeVector3d(0, 1, 0));
|
|
103
|
-
|
|
104
|
-
// Create a viewport
|
|
105
|
-
const viewport = new AcGiViewport();
|
|
106
|
-
viewport.setView(view);
|
|
107
|
-
viewport.setWidth(800);
|
|
108
|
-
viewport.setHeight(600);
|
|
109
|
-
viewport.setZoom(1.0);
|
|
110
|
-
|
|
111
|
-
// Set viewport properties
|
|
112
|
-
viewport.setClippingEnabled(true);
|
|
113
|
-
viewport.setClippingBounds(0, 0, 100, 100);
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
### Hatch Pattern Rendering
|
|
117
|
-
```typescript
|
|
118
|
-
import { AcGiHatchStyle } from '@mlightcad/graphic-interface';
|
|
119
|
-
|
|
120
|
-
// Configure hatch style
|
|
121
|
-
const hatchStyle = new AcGiHatchStyle();
|
|
122
|
-
hatchStyle.setPattern('ANSI31'); // Standard AutoCAD pattern
|
|
123
|
-
hatchStyle.setScale(1.0);
|
|
124
|
-
hatchStyle.setAngle(0);
|
|
125
|
-
hatchStyle.setColor(4); // Cyan
|
|
126
|
-
hatchStyle.setTransparency(0.5);
|
|
127
|
-
|
|
128
|
-
// Apply hatch to an entity
|
|
129
|
-
const hatchedEntity = renderer.renderEntityWithHatch(entity, hatchStyle);
|
|
130
|
-
```
|
|
131
|
-
|
|
132
|
-
### Image Rendering
|
|
133
|
-
```typescript
|
|
134
|
-
import { AcGiImageStyle } from '@mlightcad/graphic-interface';
|
|
135
|
-
|
|
136
|
-
// Configure image style
|
|
137
|
-
const imageStyle = new AcGiImageStyle();
|
|
138
|
-
imageStyle.setBrightness(1.0);
|
|
139
|
-
imageStyle.setContrast(1.0);
|
|
140
|
-
imageStyle.setFade(0.0);
|
|
141
|
-
imageStyle.setTransparency(0.0);
|
|
142
|
-
imageStyle.setClippingEnabled(false);
|
|
143
|
-
|
|
144
|
-
// Render image with style
|
|
145
|
-
const imageEntity = renderer.renderImage(imagePath, imageStyle);
|
|
146
|
-
```
|
|
147
|
-
|
|
148
|
-
### Custom Rendering Pipeline
|
|
149
|
-
```typescript
|
|
150
|
-
import { AcGiRenderer, AcGiEntity } from '@mlightcad/graphic-interface';
|
|
151
|
-
|
|
152
|
-
// Create a custom renderer
|
|
153
|
-
class CustomRenderer extends AcGiRenderer {
|
|
154
|
-
renderEntity(entity: AcDbEntity): AcGiEntity {
|
|
155
|
-
// Custom rendering logic
|
|
156
|
-
const drawable = super.renderEntity(entity);
|
|
157
|
-
|
|
158
|
-
// Apply custom styling
|
|
159
|
-
if (entity.getLayer() === 'HIGHLIGHT') {
|
|
160
|
-
drawable.setHighlighted(true);
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
return drawable;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
renderToCanvas(canvas: HTMLCanvasElement, entities: AcGiEntity[]) {
|
|
167
|
-
const ctx = canvas.getContext('2d');
|
|
168
|
-
|
|
169
|
-
entities.forEach(entity => {
|
|
170
|
-
// Custom canvas rendering
|
|
171
|
-
this.renderEntityToCanvas(ctx, entity);
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
// Use custom renderer
|
|
177
|
-
const customRenderer = new CustomRenderer();
|
|
178
|
-
const drawableEntities = entities.map(entity => customRenderer.renderEntity(entity));
|
|
179
|
-
customRenderer.renderToCanvas(canvas, drawableEntities);
|
|
180
|
-
```
|
|
181
|
-
|
|
182
|
-
### Batch Rendering
|
|
183
|
-
```typescript
|
|
184
|
-
import { AcGiRenderer } from '@mlightcad/graphic-interface';
|
|
185
|
-
|
|
186
|
-
// Batch render multiple entities
|
|
187
|
-
const renderer = new AcGiRenderer();
|
|
188
|
-
const entities = [line1, circle1, polyline1, text1];
|
|
189
|
-
|
|
190
|
-
// Render all entities with consistent styling
|
|
191
|
-
const drawableEntities = renderer.renderEntities(entities, {
|
|
192
|
-
defaultColor: 7, // White
|
|
193
|
-
defaultLayer: '0',
|
|
194
|
-
defaultLinetype: 'CONTINUOUS'
|
|
195
|
-
});
|
|
196
|
-
|
|
197
|
-
// Apply viewport transformations
|
|
198
|
-
viewport.applyTransformations(drawableEntities);
|
|
199
|
-
```
|
|
200
|
-
|
|
201
|
-
## Dependencies
|
|
202
|
-
|
|
203
|
-
- **@mlightcad/geometry-engine**: For geometric operations (peer dependency)
|
|
204
|
-
|
|
205
|
-
## API Documentation
|
|
206
|
-
|
|
207
|
-
For detailed API documentation, visit the [RealDWG-Web documentation](https://mlight-lee.github.io/realdwg-web/).
|
|
208
|
-
|
|
209
|
-
## Contributing
|
|
210
|
-
|
|
1
|
+
# @mlightcad/graphic-interface
|
|
2
|
+
|
|
3
|
+
The graphic-interface package provides the graphics interface for controlling how AutoCAD entities are displayed on screen. This package offers a simplified API compared to AutoCAD ObjectARX's AcGi classes, making it more developer-friendly while maintaining the core functionality needed for rendering CAD entities.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
This package provides the graphics interface layer that bridges the gap between the data model and the rendering system. It handles the conversion of AutoCAD entities into drawable objects and provides customization options for how objects are displayed, including colors, layers, visibility, and various rendering styles.
|
|
8
|
+
|
|
9
|
+
## Key Features
|
|
10
|
+
|
|
11
|
+
- **Entity Rendering**: Convert AutoCAD entities to drawable objects
|
|
12
|
+
- **Style Customization**: Control colors, line styles, text styles, and point styles
|
|
13
|
+
- **View Management**: Handle different views and viewports
|
|
14
|
+
- **Arrow and Hatch Support**: Custom arrow types and hatch pattern rendering
|
|
15
|
+
- **Image Rendering**: Support for raster image display
|
|
16
|
+
- **Flexible Rendering**: Extensible rendering system for different output formats
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npm install @mlightcad/graphic-interface
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Key Classes
|
|
25
|
+
|
|
26
|
+
### Core Rendering Classes
|
|
27
|
+
- **AcGiRenderer**: Main interface for rendering entities to drawable objects
|
|
28
|
+
- **AcGiEntity**: Base class for drawable objects that can be rendered
|
|
29
|
+
- **AcGiView**: Represents a view with camera and projection settings
|
|
30
|
+
- **AcGiViewport**: Manages viewport settings and clipping
|
|
31
|
+
|
|
32
|
+
### Style Classes
|
|
33
|
+
- **AcGiArrowType**: Defines different arrow types for dimensions and leaders
|
|
34
|
+
- **AcGiHatchStyle**: Controls hatch pattern rendering and appearance
|
|
35
|
+
- **AcGiImageStyle**: Manages raster image display properties
|
|
36
|
+
- **AcGiLineStyle**: Defines line styles including dash patterns and widths
|
|
37
|
+
- **AcGiPointStyle**: Controls point entity display appearance
|
|
38
|
+
- **AcGiTextStyle**: Manages text rendering properties and formatting
|
|
39
|
+
|
|
40
|
+
## Usage Examples
|
|
41
|
+
|
|
42
|
+
### Basic Entity Rendering
|
|
43
|
+
```typescript
|
|
44
|
+
import { AcGiRenderer, AcGiEntity } from '@mlightcad/graphic-interface';
|
|
45
|
+
import { AcDbLine, AcGePoint3d } from '@mlightcad/data-model';
|
|
46
|
+
|
|
47
|
+
// Create a renderer
|
|
48
|
+
const renderer = new AcGiRenderer();
|
|
49
|
+
|
|
50
|
+
// Create an entity
|
|
51
|
+
const startPoint = new AcGePoint3d(0, 0, 0);
|
|
52
|
+
const endPoint = new AcGePoint3d(10, 10, 0);
|
|
53
|
+
const line = new AcDbLine(startPoint, endPoint);
|
|
54
|
+
|
|
55
|
+
// Render the entity
|
|
56
|
+
const drawableEntity = renderer.renderEntity(line);
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Style Configuration
|
|
60
|
+
```typescript
|
|
61
|
+
import {
|
|
62
|
+
AcGiLineStyle,
|
|
63
|
+
AcGiTextStyle,
|
|
64
|
+
AcGiPointStyle,
|
|
65
|
+
AcGiArrowType
|
|
66
|
+
} from '@mlightcad/graphic-interface';
|
|
67
|
+
|
|
68
|
+
// Configure line style
|
|
69
|
+
const lineStyle = new AcGiLineStyle();
|
|
70
|
+
lineStyle.setColor(1); // Red
|
|
71
|
+
lineStyle.setWidth(2.0);
|
|
72
|
+
lineStyle.setDashPattern([10, 5, 5, 5]); // Dashed line
|
|
73
|
+
|
|
74
|
+
// Configure text style
|
|
75
|
+
const textStyle = new AcGiTextStyle();
|
|
76
|
+
textStyle.setFont('Arial');
|
|
77
|
+
textStyle.setHeight(12);
|
|
78
|
+
textStyle.setColor(2); // Yellow
|
|
79
|
+
textStyle.setBold(true);
|
|
80
|
+
|
|
81
|
+
// Configure point style
|
|
82
|
+
const pointStyle = new AcGiPointStyle();
|
|
83
|
+
pointStyle.setSize(5);
|
|
84
|
+
pointStyle.setShape('Circle');
|
|
85
|
+
pointStyle.setColor(3); // Green
|
|
86
|
+
|
|
87
|
+
// Configure arrow style
|
|
88
|
+
const arrowStyle = new AcGiArrowType();
|
|
89
|
+
arrowStyle.setType('ClosedFilled');
|
|
90
|
+
arrowStyle.setSize(3);
|
|
91
|
+
arrowStyle.setColor(1); // Red
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### View and Viewport Management
|
|
95
|
+
```typescript
|
|
96
|
+
import { AcGiView, AcGiViewport, AcGePoint3d } from '@mlightcad/graphic-interface';
|
|
97
|
+
|
|
98
|
+
// Create a view
|
|
99
|
+
const view = new AcGiView();
|
|
100
|
+
view.setEyePoint(new AcGePoint3d(0, 0, 100));
|
|
101
|
+
view.setTargetPoint(new AcGePoint3d(0, 0, 0));
|
|
102
|
+
view.setUpVector(new AcGeVector3d(0, 1, 0));
|
|
103
|
+
|
|
104
|
+
// Create a viewport
|
|
105
|
+
const viewport = new AcGiViewport();
|
|
106
|
+
viewport.setView(view);
|
|
107
|
+
viewport.setWidth(800);
|
|
108
|
+
viewport.setHeight(600);
|
|
109
|
+
viewport.setZoom(1.0);
|
|
110
|
+
|
|
111
|
+
// Set viewport properties
|
|
112
|
+
viewport.setClippingEnabled(true);
|
|
113
|
+
viewport.setClippingBounds(0, 0, 100, 100);
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Hatch Pattern Rendering
|
|
117
|
+
```typescript
|
|
118
|
+
import { AcGiHatchStyle } from '@mlightcad/graphic-interface';
|
|
119
|
+
|
|
120
|
+
// Configure hatch style
|
|
121
|
+
const hatchStyle = new AcGiHatchStyle();
|
|
122
|
+
hatchStyle.setPattern('ANSI31'); // Standard AutoCAD pattern
|
|
123
|
+
hatchStyle.setScale(1.0);
|
|
124
|
+
hatchStyle.setAngle(0);
|
|
125
|
+
hatchStyle.setColor(4); // Cyan
|
|
126
|
+
hatchStyle.setTransparency(0.5);
|
|
127
|
+
|
|
128
|
+
// Apply hatch to an entity
|
|
129
|
+
const hatchedEntity = renderer.renderEntityWithHatch(entity, hatchStyle);
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### Image Rendering
|
|
133
|
+
```typescript
|
|
134
|
+
import { AcGiImageStyle } from '@mlightcad/graphic-interface';
|
|
135
|
+
|
|
136
|
+
// Configure image style
|
|
137
|
+
const imageStyle = new AcGiImageStyle();
|
|
138
|
+
imageStyle.setBrightness(1.0);
|
|
139
|
+
imageStyle.setContrast(1.0);
|
|
140
|
+
imageStyle.setFade(0.0);
|
|
141
|
+
imageStyle.setTransparency(0.0);
|
|
142
|
+
imageStyle.setClippingEnabled(false);
|
|
143
|
+
|
|
144
|
+
// Render image with style
|
|
145
|
+
const imageEntity = renderer.renderImage(imagePath, imageStyle);
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### Custom Rendering Pipeline
|
|
149
|
+
```typescript
|
|
150
|
+
import { AcGiRenderer, AcGiEntity } from '@mlightcad/graphic-interface';
|
|
151
|
+
|
|
152
|
+
// Create a custom renderer
|
|
153
|
+
class CustomRenderer extends AcGiRenderer {
|
|
154
|
+
renderEntity(entity: AcDbEntity): AcGiEntity {
|
|
155
|
+
// Custom rendering logic
|
|
156
|
+
const drawable = super.renderEntity(entity);
|
|
157
|
+
|
|
158
|
+
// Apply custom styling
|
|
159
|
+
if (entity.getLayer() === 'HIGHLIGHT') {
|
|
160
|
+
drawable.setHighlighted(true);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
return drawable;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
renderToCanvas(canvas: HTMLCanvasElement, entities: AcGiEntity[]) {
|
|
167
|
+
const ctx = canvas.getContext('2d');
|
|
168
|
+
|
|
169
|
+
entities.forEach(entity => {
|
|
170
|
+
// Custom canvas rendering
|
|
171
|
+
this.renderEntityToCanvas(ctx, entity);
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// Use custom renderer
|
|
177
|
+
const customRenderer = new CustomRenderer();
|
|
178
|
+
const drawableEntities = entities.map(entity => customRenderer.renderEntity(entity));
|
|
179
|
+
customRenderer.renderToCanvas(canvas, drawableEntities);
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
### Batch Rendering
|
|
183
|
+
```typescript
|
|
184
|
+
import { AcGiRenderer } from '@mlightcad/graphic-interface';
|
|
185
|
+
|
|
186
|
+
// Batch render multiple entities
|
|
187
|
+
const renderer = new AcGiRenderer();
|
|
188
|
+
const entities = [line1, circle1, polyline1, text1];
|
|
189
|
+
|
|
190
|
+
// Render all entities with consistent styling
|
|
191
|
+
const drawableEntities = renderer.renderEntities(entities, {
|
|
192
|
+
defaultColor: 7, // White
|
|
193
|
+
defaultLayer: '0',
|
|
194
|
+
defaultLinetype: 'CONTINUOUS'
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
// Apply viewport transformations
|
|
198
|
+
viewport.applyTransformations(drawableEntities);
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
## Dependencies
|
|
202
|
+
|
|
203
|
+
- **@mlightcad/geometry-engine**: For geometric operations (peer dependency)
|
|
204
|
+
|
|
205
|
+
## API Documentation
|
|
206
|
+
|
|
207
|
+
For detailed API documentation, visit the [RealDWG-Web documentation](https://mlight-lee.github.io/realdwg-web/).
|
|
208
|
+
|
|
209
|
+
## Contributing
|
|
210
|
+
|
|
211
211
|
This package is part of the RealDWG-Web monorepo. Please refer to the main project README for contribution guidelines.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mlightcad/graphic-interface",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.6",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
"require": "./dist/graphic-interface.umd.cjs"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
|
-
"@mlightcad/common": "1.3.
|
|
36
|
-
"@mlightcad/geometry-engine": "3.1.
|
|
35
|
+
"@mlightcad/common": "1.3.6",
|
|
36
|
+
"@mlightcad/geometry-engine": "3.1.9"
|
|
37
37
|
},
|
|
38
38
|
"scripts": {
|
|
39
39
|
"clean": "rimraf dist lib tsconfig.tsbuildinfo",
|