mxcad 1.0.396 → 1.0.397

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/mxcad.d.ts CHANGED
@@ -6877,13 +6877,10 @@ export declare class McDbSpline extends McDbCurve {
6877
6877
  /**
6878
6878
  * 构造函数
6879
6879
  * @param imp 实现对象
6880
- * @example
6881
- * ```
6882
6880
  */
6883
6881
  constructor(imp?: any);
6884
6882
  /**
6885
6883
  * 得到样条线的数据.
6886
- * @example
6887
6884
  */
6888
6885
  getNurbsData(): {
6889
6886
  degree: number;
@@ -6898,7 +6895,6 @@ export declare class McDbSpline extends McDbCurve {
6898
6895
  };
6899
6896
  /**
6900
6897
  * 设置样条线的数据.
6901
- * @example
6902
6898
  *
6903
6899
  */
6904
6900
  setNurbsData(data: {
@@ -6914,7 +6910,6 @@ export declare class McDbSpline extends McDbCurve {
6914
6910
  }): boolean;
6915
6911
  /**
6916
6912
  * 得到样条线的拟合数据.
6917
- * @example
6918
6913
  */
6919
6914
  getFitPoints(): {
6920
6915
  degree: number;
@@ -6926,7 +6921,6 @@ export declare class McDbSpline extends McDbCurve {
6926
6921
  };
6927
6922
  /**
6928
6923
  *设置样条线的拟合数据.
6929
- * @example
6930
6924
  */
6931
6925
  setFitPoints(data: {
6932
6926
  degree: number;
@@ -12323,10 +12317,14 @@ export declare class MxCompare {
12323
12317
  * - 修改对象用粉色标注;
12324
12318
  * - 新增对象用绿色标注;
12325
12319
  * - 删除对象用红色标注。
12326
- *
12320
+ * - 背景对象是否只显示删除的对象,默认值1.
12327
12321
  * @param strColor 可选的颜色配置字符串,例如:
12328
- * {"add_color":0xFF0000,"erase_color":0x00FF00,"modify_color":0x0000FF,"not_modify_color":0x505050}
12322
+ * {"add_color":0xFF0000,"erase_color":0x00FF00,"modify_color":0x0000FF,"not_modify_color":0x505050,"background_only_show_erase_obj":1}
12329
12323
  * @returns 是否成功执行重绘。
12324
+ * @example
12325
+ * ```ts
12326
+ * cmp.regenDisplay(JSON.stringify( {"add_color":0xFF0000,"erase_color":0x00FF00,"modify_color":0x0000FF,"not_modify_color":0x505050}));
12327
+ * ```
12330
12328
  */
12331
12329
  regenDisplay(strColor?: string): boolean;
12332
12330
  }
@@ -15042,7 +15040,7 @@ export declare const MxTools: {
15042
15040
  copyMcDbEntityProperties: typeof copyMcDbEntityProperties;
15043
15041
  };
15044
15042
  /**
15045
- * Canvas 转图片工具类,用于把浏览器中的 canvas 内容转换为图片并支持下载或生成图片元素。
15043
+ * 用于把浏览器中的 mxcad canvas 内容转换为图片并支持下载或生成图片元素。
15046
15044
  *
15047
15045
  * @description
15048
15046
  * 该类主要用于在前端页面中将 canvas 绘制结果导出为 PNG、JPEG、BMP、GIF 等常见图片格式,适用于截图、图表导出、图形分享和本地保存等场景。
@@ -15054,34 +15052,38 @@ export declare const MxTools: {
15054
15052
  * - 对 BMP 类型做特殊编码以生成可下载的位图内容。
15055
15053
  *
15056
15054
  * 使用方式:
15057
- * 1. 实例化 MxCanvas2Image;
15058
- * 2. 传入 canvas 元素或元素 id
15059
- * 3. 调用 saveAsImage() 下载图片,或调用 convertToImage() 获取图片节点;
15060
- * 4. 可通过 width、height、type 参数控制导出尺寸和格式;
15061
- * 5. 若需导出 BMP,可按底层编码方式自动生成位图数据。
15055
+ * 1. 使用MxCpp.mxcad.mxdraw.createCanvasImageData,函数准备好Canvas的绘图数据
15056
+ * 2. 实例化 MxCanvas2Image
15057
+ * 3. 传入 canvas 元素或元素 id;
15058
+ * 4. 调用 saveAsImage() 下载图片,或调用 convertToImage() 获取图片节点;
15059
+ * 5. 可通过 width、height、type 参数控制导出尺寸和格式;
15060
+ * 6. 若需导出 BMP,可按底层编码方式自动生成位图数据。
15062
15061
  *
15063
15062
  * 总结:MxCanvas2Image 是一个专门处理 canvas 导出与下载的工具类,适合在 Web 端把绘制内容快速转换为可保存的图片文件或可展示的 IMG 元素。
15064
15063
  *
15065
15064
  * @example
15066
15065
  * ```ts
15067
- * import { MxCanvas2Image } from "mxcad";
15068
- *
15069
- * const canvas = document.getElementById("myCanvas") as HTMLCanvasElement;
15070
- * const converter = new MxCanvas2Image(document);
15071
- *
15072
- * // 直接下载为 PNG
15073
- * converter.saveAsImage(canvas, 800, 600, "png");
15074
- *
15075
- * // 转成图片节点并插入页面
15076
- * const img = converter.convertToImage(canvas, 800, 600, "jpg");
15077
- * document.body.appendChild(img);
15078
- *
15079
- * // 转成 bmp 并下载
15080
- * converter.saveAsImage(canvas, 1024, 768, "bmp");
15066
+ export async function Mx_Test_Canvas2Image() {
15067
+ MxCpp.mxcad.mxdraw.createCanvasImageData(() => {
15068
+ let canvas2image = new MxCanvas2Image(document);
15069
+ const mxcad = MxCpp.getCurrentMxCAD();
15070
+ //canvas2image.saveAsImage(mxcad.mxdraw.getCanvas(), undefined, undefined, "jpg","save.jpg");
15071
+ //canvas2image.saveAsImage(mxcad.mxdraw.getCanvas(), undefined, undefined, "png","save.png");
15072
+ //canvas2image.saveAsImage(mxcad.mxdraw.getCanvas(), 1000, 2000, "bmp","bmp.bmp");
15073
+ let zoom = window.devicePixelRatio;
15074
+ //let img = canvas2image.convertToImage(mxcad.mxdraw.getCanvas(), undefined, undefined, "bmp");
15075
+ let img = canvas2image.convertToImage(mxcad.mxdraw.getCanvas(), undefined, undefined, "jpg");
15076
+ img.width = mxcad.mxdraw.getCanvas().width / zoom;
15077
+ img.height = mxcad.mxdraw.getCanvas().height / zoom;
15078
+ let newWindow: any = window.open();
15079
+ newWindow.document.body.appendChild(img);
15080
+
15081
+ }
15082
+ );
15083
+ }
15081
15084
  * ```
15082
15085
  */
15083
15086
  export declare class MxCanvas2Image {
15084
- private $support;
15085
15087
  private downloadMime;
15086
15088
  private mydocument;
15087
15089
  constructor(in_document?: any);
@@ -15103,7 +15105,7 @@ export declare class MxCanvas2Image {
15103
15105
  * @param height 导出图片的高度,若未指定则使用 canvas 原始高度。
15104
15106
  * @param type 导出图片的类型,可选值为 'png'、'jpeg'、'bmp'、'gif',默认值为 'png'。
15105
15107
  */
15106
- saveAsImage(canvas: any, width: any, height: any, type: any): void;
15108
+ saveAsImage(canvas: any, width: any, height: any, type: any, fileName?: string): void;
15107
15109
  /**
15108
15110
  * 将当前 canvas 转换为图片元素。
15109
15111
  * @description
@@ -15114,7 +15116,7 @@ export declare class MxCanvas2Image {
15114
15116
  * @param type 导出图片的类型,可选值为 'png'、'jpeg'、'bmp'、'gif',默认值为 'png'。
15115
15117
  * @returns
15116
15118
  */
15117
- convertToImage(canvas: any, width: any, height: any, type: any): HTMLImageElement | undefined;
15119
+ convertToImage(canvas: any, width: any, height: any, type: any): HTMLImageElement;
15118
15120
  }
15119
15121
  export type Map = any;
15120
15122
  /**