import Point from '../core/point' import FixedPoint from '../core/fixedpoint' import {AttachCAD as CAD} from '../index' import Line from '../core/fixedline' interface pointStyle { storkeColor?: string, fillColor?: string, hoverStorkeColor?: string, hoverFillColor?: string } interface lineStyle { width: number, color: string } export interface Style { setDefaultPointStyle: (args: pointStyle) => void, setDefaultLineStyle: (args: lineStyle) => void, } // 给cad点设置默认样式 export const attachStyle = (cad: CAD) => { let fixedPointStyle = { fillColor: 'rgb(0, 200, 175)', storkeColor: 'green' } let pointStyle = { fillColor: 'rgba(245, 255, 0, 0.7)', storkeColor: 'rgba(245, 255, 255, 0.3)' } cad.setDefaultPointStyle = (args) => { args.storkeColor && (fixedPointStyle.storkeColor = args.storkeColor) args.fillColor && (fixedPointStyle.fillColor = args.fillColor) args.hoverStorkeColor && (pointStyle.storkeColor = args.hoverStorkeColor) args.hoverFillColor && (pointStyle.fillColor = args.hoverFillColor) setTimeout(() => { cad.loadData(cad.getData()); }, 100) } let lineStyle = { width: 3, color: 'rgb(255,255,255)' } const addProcessing = cad.addProcessing cad.addProcessing = (...args) => { let processing = addProcessing.call(cad, ...args) FixedPoint.Setting.set(processing.render, fixedPointStyle) Point.Setting.set(processing.render, pointStyle) Line.Setting.set(processing.render, lineStyle) return processing } cad.setDefaultLineStyle = args => { args.width && (lineStyle.width = args.width) args.color && (lineStyle.color = args.color) setTimeout(() => { cad.loadData(cad.getData()); }, 100) } }