UNPKG

@turbox3d/graphic-component-pixi

Version:

Graphic component library based on pixi

51 lines 2.61 kB
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck"; import _createClass from "@babel/runtime/helpers/esm/createClass"; import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn"; import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf"; import _inherits from "@babel/runtime/helpers/esm/inherits"; function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); } function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); } import { Mesh2D } from '@turbox3d/renderer-pixi'; import * as PIXI from 'pixi.js'; import DrawUtils from '../draw-utils'; var Line2d = /*#__PURE__*/function (_Mesh2D) { function Line2d() { var _this; _classCallCheck(this, Line2d); _this = _callSuper(this, Line2d, arguments); _this.view = new PIXI.Graphics(); return _this; } _inherits(Line2d, _Mesh2D); return _createClass(Line2d, [{ key: "draw", value: function draw() { var _a, _b, _c, _d, _e; var _this$props = this.props, _this$props$lineWidth = _this$props.lineWidth, lineWidth = _this$props$lineWidth === void 0 ? 2 : _this$props$lineWidth, _this$props$lineColor = _this$props.lineColor, lineColor = _this$props$lineColor === void 0 ? 0xffffff : _this$props$lineColor, start = _this$props.start, end = _this$props.end, _this$props$alignment = _this$props.alignment, alignment = _this$props$alignment === void 0 ? 0.5 : _this$props$alignment, _this$props$zIndex = _this$props.zIndex, zIndex = _this$props$zIndex === void 0 ? 0 : _this$props$zIndex; this.view.clear(); this.view.zIndex = zIndex; DrawUtils.drawLine(this.view, { x0: start.x, y0: start.y, x1: end.x, y1: end.y, lineWidth: lineWidth, lineColor: lineColor, alignment: alignment }); this.view.rotation = (_a = this.props.rotation) !== null && _a !== void 0 ? _a : 0; this.view.scale.set((_c = (_b = this.props.scale) === null || _b === void 0 ? void 0 : _b.x) !== null && _c !== void 0 ? _c : 1, (_e = (_d = this.props.scale) === null || _d === void 0 ? void 0 : _d.y) !== null && _e !== void 0 ? _e : 1); } }]); }(Mesh2D); export { Line2d as default };