You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1 line
96 KiB
JavaScript

3 months ago
(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){var CRender=require("../lib/index");window.CRender=CRender},{"../lib/index":6}],2:[function(require,module,exports){"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports["default"]=void 0;var _defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));var _toConsumableArray2=_interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));var _classCallCheck2=_interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));var _color=_interopRequireDefault(require("@jiaminghi/color"));var _bezierCurve=_interopRequireDefault(require("@jiaminghi/bezier-curve"));var _util=require("../plugin/util");var _graphs=_interopRequireDefault(require("../config/graphs"));var _graph=_interopRequireDefault(require("./graph.class"));function ownKeys(object,enumerableOnly){var keys=Object.keys(object);if(Object.getOwnPropertySymbols){var symbols=Object.getOwnPropertySymbols(object);if(enumerableOnly)symbols=symbols.filter(function(sym){return Object.getOwnPropertyDescriptor(object,sym).enumerable});keys.push.apply(keys,symbols)}return keys}function _objectSpread(target){for(var i=1;i<arguments.length;i++){var source=arguments[i]!=null?arguments[i]:{};if(i%2){ownKeys(source,true).forEach(function(key){(0,_defineProperty2["default"])(target,key,source[key])})}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(target,Object.getOwnPropertyDescriptors(source))}else{ownKeys(source).forEach(function(key){Object.defineProperty(target,key,Object.getOwnPropertyDescriptor(source,key))})}}return target}var CRender=function CRender(canvas){(0,_classCallCheck2["default"])(this,CRender);if(!canvas){console.error("CRender Missing parameters!");return}var ctx=canvas.getContext("2d");var clientWidth=canvas.clientWidth,clientHeight=canvas.clientHeight;var area=[clientWidth,clientHeight];canvas.setAttribute("width",clientWidth);canvas.setAttribute("height",clientHeight);this.ctx=ctx;this.area=area;this.animationStatus=false;this.graphs=[];this.color=_color["default"];this.bezierCurve=_bezierCurve["default"];canvas.addEventListener("mousedown",mouseDown.bind(this));canvas.addEventListener("mousemove",mouseMove.bind(this));canvas.addEventListener("mouseup",mouseUp.bind(this))};exports["default"]=CRender;CRender.prototype.clearArea=function(){var _this$ctx;var area=this.area;(_this$ctx=this.ctx).clearRect.apply(_this$ctx,[0,0].concat((0,_toConsumableArray2["default"])(area)))};CRender.prototype.add=function(){var config=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var name=config.name;if(!name){console.error("add Missing parameters!");return}var graphConfig=_graphs["default"].get(name);if(!graphConfig){console.warn("No corresponding graph configuration found!");return}var graph=new _graph["default"](graphConfig,config);if(!graph.validator(graph))return;graph.render=this;this.graphs.push(graph);this.sortGraphsByIndex();this.drawAllGraph();return graph};CRender.prototype.sortGraphsByIndex=function(){var graphs=this.graphs;graphs.sort(function(a,b){if(a.index>b.index)return 1;if(a.index===b.index)return 0;if(a.index<b.index)return-1})};CRender.prototype.delGraph=function(graph){if(typeof graph.delProcessor!=="function")return;graph.delProcessor(this);this.graphs=this.graphs.filter(function(graph){return graph});this.drawAllGraph()};CRender.prototype.delAllGraph=function(){var _this=this;this.graphs.forEach(function(graph){return graph.delProcessor(_this)});this.graphs=this.graphs.filter(funct