2026_08_31

This commit is contained in:
marco committed 2026-08-31 16:19:06 +02:00
commit 73015386e9
2320 files changed
+80291

No files matched your search

+118
View File
@@ -0,0 +1,118 @@
import { PathCommand } from "../lib/types/path.types";
import { DrawText } from '../lib/drawText'
import { DrawGroup } from '../lib/drawGroup'
import { DrawEllipse } from "../lib/drawEllipse";
import { cal_rotation_dim } from '../lib/drawFunktions'
import { Injectable } from "@nestjs/common";
import { DrawDto, DrawShapeOptionenDto } from "src/_dto/draw.dto";
import { DrawHeader } from "../lib/drawHeader";
interface Para {
scale?: number,
}
@Injectable()
export class DrawMotor {
scale = 0;
winkel = 0;
raster = 4;
obj_height = 0;
obj_width = 0;
height = 0;
width = 0;
offset_x = 0;
offset_y = 0;
red = "#f00000";
normal = "#808080";
green = "#00f000";
constructor() {
this.scale = 2.0;
}
create(optionen?: DrawShapeOptionenDto): DrawGroup {
let color = this.normal;
if (optionen && optionen.state == 'active') color = this.green;
if (optionen && optionen.state == 'error') color = this.red;
let raster = 4.0;
if (optionen && optionen.raster) raster = optionen.raster;
let scale = 2.0;
if (optionen && optionen.scale) scale = optionen.scale;
const x0 = 0;
const x1 = 3 * raster * scale; // länge
const x_m = (x0 + x1) / 2; // mitte kasten
const y0 = 0;
const y1 = 3 * raster * scale; // höhe Kasten
const y_m = (y0 + y1) / 2; //mitte kasten
const radius = x1 / 2;
const obj_h = y0 + y1 + 0 * raster;
const obj_w = x0 + x1 + 0 * raster;
const height = obj_h / scale / raster;
const width = obj_w / scale / raster;
const groupInhalt = new DrawGroup({});
const z_kreis = new DrawEllipse({ cx: x_m, cy: y_m, rx: radius, ry: radius });
const z_text = new DrawText({ x: 5, y: 0, text:"M" });
z_kreis.setAtrr({ fill: color })
groupInhalt.add(z_text);
groupInhalt.add(z_kreis);
this.scale = scale;
this.raster = raster;
this.height = height;
this.width = width;
this.obj_height = obj_h;
this.obj_width = obj_w;
return groupInhalt;
}
getDrawObject(optionen?: DrawShapeOptionenDto): DrawDto {
const groupSvg = this.create(optionen)
const svg = groupSvg.getChildString(false, 0)
return {
name: "motor",
height: this.height,
length: this.width,
px_height: this.obj_height,
px_width: this.obj_width,
raster: this.raster,
scale: this.scale,
offset_x: 0,
offset_y: 0,
svg
}
}
getSvg(optionen?: DrawShapeOptionenDto): string {
const groupSvg = this.create(optionen);
const xaml = optionen && optionen.xaml ? true :false;
const header = new DrawHeader({ lenght: this.obj_width, height: this.obj_height });
header.add(groupSvg);
return header.getChildString(xaml, 0);
}
}