Files
2023-11-23 20:37:33 +00:00

3 lines
8.6 KiB
JavaScript

var gdjs;(function(s){const n=class extends s.RuntimeObject{constructor(e,t){super(e,t);this._scaleX=1;this._scaleY=1;this._blendMode=0;this._flippedX=!1;this._flippedY=!1;this._customCenter=null;this._customCollisionMask=null;this._fillColor=parseInt(s.rgbToHex(t.fillColor.r,t.fillColor.g,t.fillColor.b),16),this._outlineColor=parseInt(s.rgbToHex(t.outlineColor.r,t.outlineColor.g,t.outlineColor.b),16),this._fillOpacity=t.fillOpacity,this._outlineOpacity=t.outlineOpacity,this._outlineSize=t.outlineSize,this._useAbsoluteCoordinates=t.absoluteCoordinates,this._clearBetweenFrames=t.clearBetweenFrames,this._antialiasing=t.antialiasing,this._renderer=new s.ShapePainterRuntimeObjectRenderer(this,e),this.onCreated()}getRendererObject(){return this._renderer.getRendererObject()}updateFromObjectData(e,t){return(e.fillColor.r!==t.fillColor.r||e.fillColor.g!==t.fillColor.g||e.fillColor.b!==t.fillColor.b)&&this.setFillColor(""+t.fillColor.r+";"+t.fillColor.g+";"+t.fillColor.b),(e.outlineColor.r!==t.outlineColor.r||e.outlineColor.g!==t.outlineColor.g||e.outlineColor.b!==t.outlineColor.b)&&this.setOutlineColor(""+t.outlineColor.r+";"+t.outlineColor.g+";"+t.outlineColor.b),e.fillOpacity!==t.fillOpacity&&this.setFillOpacity(t.fillOpacity),e.outlineOpacity!==t.outlineOpacity&&this.setOutlineOpacity(t.outlineOpacity),e.outlineSize!==t.outlineSize&&this.setOutlineSize(t.outlineSize),e.absoluteCoordinates!==t.absoluteCoordinates&&(this._useAbsoluteCoordinates=t.absoluteCoordinates,this._renderer.updatePositionX(),this._renderer.updatePositionY(),this._renderer.updateAngle(),this._renderer.updateScaleX(),this._renderer.updateScaleY()),e.clearBetweenFrames!==t.clearBetweenFrames&&(this._clearBetweenFrames=t.clearBetweenFrames),!0}stepBehaviorsPreEvents(e){this._clearBetweenFrames&&this.clear(),super.stepBehaviorsPreEvents(e)}onDestroyed(){super.onDestroyed(),this._renderer.destroy()}clear(){this._renderer.clear()}getVisibilityAABB(){return this._useAbsoluteCoordinates?null:this.getAABB()}drawRectangle(e,t,i,o){this._renderer.drawRectangle(e,t,i,o)}drawCircle(e,t,i){this._renderer.drawCircle(e,t,i)}drawLine(e,t,i,o,r){this._renderer.drawLine(e,t,i,o,r)}drawLineV2(e,t,i,o,r){this._renderer.drawLineV2(e,t,i,o,r)}drawEllipse(e,t,i,o){this._renderer.drawEllipse(e,t,i,o)}drawRoundedRectangle(e,t,i,o,r){this._renderer.drawRoundedRectangle(e,t,i,o,r)}drawChamferRectangle(e,t,i,o,r){this._renderer.drawChamferRectangle(e,t,i,o,r)}drawRegularPolygon(e,t,i,o,r){this._renderer.drawRegularPolygon(e,t,i,o,r)}drawStar(e,t,i,o,r,l){this._renderer.drawStar(e,t,i,o,r,l)}drawArc(e,t,i,o,r,l,a){this._renderer.drawArc(e,t,i,o,r,l,a)}drawBezierCurve(e,t,i,o,r,l,a,h){this._renderer.drawBezierCurve(e,t,i,o,r,l,a,h)}drawQuadraticCurve(e,t,i,o,r,l){this._renderer.drawQuadraticCurve(e,t,i,o,r,l)}beginFillPath(e,t){this._renderer.beginFillPath(),this._renderer.drawPathMoveTo(e,t)}endFillPath(){this._renderer.endFillPath()}drawPathMoveTo(e,t){this._renderer.drawPathMoveTo(e,t)}drawPathLineTo(e,t){this._renderer.drawPathLineTo(e,t)}drawPathBezierCurveTo(e,t,i,o,r,l){this._renderer.drawPathBezierCurveTo(e,t,i,o,r,l)}drawPathArc(e,t,i,o,r,l){this._renderer.drawPathArc(e,t,i,o,r,l)}drawPathQuadraticCurveTo(e,t,i,o){this._renderer.drawPathQuadraticCurveTo(e,t,i,o)}closePath(){this._renderer.closePath()}setClearBetweenFrames(e){this._clearBetweenFrames=e}isClearedBetweenFrames(){return this._clearBetweenFrames}setAntialiasing(e){this._antialiasing=e,this._renderer.updateAntialiasing()}getAntialiasing(){return this._antialiasing}checkAntialiasing(e){return this._antialiasing===e}setCoordinatesRelative(e){this._useAbsoluteCoordinates=!e}areCoordinatesRelative(){return!this._useAbsoluteCoordinates}setFillColor(e){const t=e.split(";");t.length<3||(this._fillColor=parseInt(s.rgbToHex(parseInt(t[0],10),parseInt(t[1],10),parseInt(t[2],10)),16))}getFillColorR(){return s.hexNumberToRGB(this._fillColor).r}getFillColorG(){return s.hexNumberToRGB(this._fillColor).g}getFillColorB(){return s.hexNumberToRGB(this._fillColor).b}setOutlineColor(e){const t=e.split(";");t.length<3||(this._outlineColor=parseInt(s.rgbToHex(parseInt(t[0],10),parseInt(t[1],10),parseInt(t[2],10)),16),this._renderer.updateOutline())}getOutlineColorR(){return s.hexNumberToRGB(this._outlineColor).r}getOutlineColorG(){return s.hexNumberToRGB(this._outlineColor).g}getOutlineColorB(){return s.hexNumberToRGB(this._outlineColor).b}setOutlineSize(e){this._outlineSize=e,this._renderer.updateOutline()}getOutlineSize(){return this._outlineSize}setFillOpacity(e){this._fillOpacity=e}getFillOpacity(){return this._fillOpacity}setOutlineOpacity(e){this._outlineOpacity=e,this._renderer.updateOutline()}getOutlineOpacity(){return this._outlineOpacity}setX(e){e!==this.x&&(super.setX(e),this._renderer.updatePositionX())}setY(e){e!==this.y&&(super.setY(e),this._renderer.updatePositionY())}setAngle(e){e!==this.angle&&(super.setAngle(e),this._renderer.updateAngle(),this.invalidateHitboxes())}setRotationCenter(e,t){this._customCenter||(this._customCenter=[0,0]),this._customCenter[0]=e,this._customCenter[1]=t,this._renderer.updateRotationCenter()}getRotationCenterX(){return this._customCenter?this._customCenter[0]:this._renderer.getUnscaledWidth()/2-this._renderer.getFrameRelativeOriginX()}getRotationCenterY(){return this._customCenter?this._customCenter[1]:this._renderer.getUnscaledHeight()/2-this._renderer.getFrameRelativeOriginY()}getCenterX(){return this._customCenter?this._customCenter[0]*Math.abs(this._scaleX)+this.getX()-this.getDrawableX():super.getCenterX()}getCenterY(){return this._customCenter?this._customCenter[1]*Math.abs(this._scaleY)+this.getY()-this.getDrawableY():super.getCenterY()}setWidth(e){const t=this._renderer.getUnscaledWidth();t!==0&&this.setScaleX(e/t)}setHeight(e){const t=this._renderer.getUnscaledHeight();t!==0&&this.setScaleY(e/t)}setSize(e,t){this.setWidth(e),this.setHeight(t)}setScale(e){this.setScaleX(e),this.setScaleY(e)}setScaleX(e){e<0&&(e=0),e!==Math.abs(this._scaleX)&&(this._scaleX=e*(this._flippedX?-1:1),this._renderer.updateScaleX(),this.invalidateHitboxes())}setScaleY(e){e<0&&(e=0),e!==Math.abs(this._scaleY)&&(this._scaleY=e*(this._flippedY?-1:1),this._renderer.updateScaleY(),this.invalidateHitboxes())}flipX(e){e!==this._flippedX&&(this._scaleX*=-1,this._flippedX=e,this._renderer.updateScaleX(),this.invalidateHitboxes())}flipY(e){e!==this._flippedY&&(this._scaleY*=-1,this._flippedY=e,this._renderer.updateScaleY(),this.invalidateHitboxes())}isFlippedX(){return this._flippedX}isFlippedY(){return this._flippedY}getScale(){const e=Math.abs(this._scaleX),t=Math.abs(this._scaleY);return e===t?e:Math.sqrt(e*t)}getScaleY(){return Math.abs(this._scaleY)}getScaleX(){return Math.abs(this._scaleX)}invalidateBounds(){this.invalidateHitboxes()}getDrawableX(){return this._renderer.getDrawableX()}getDrawableY(){return this._renderer.getDrawableY()}getWidth(){return this._renderer.getWidth()}getHeight(){return this._renderer.getHeight()}updatePreRender(e){this._renderer.updatePreRender()}transformToDrawing(e,t){const i=n._pointForTransformation;return i[0]=e,i[1]=t,this._renderer.transformToDrawing(i)}transformToScene(e,t){const i=n._pointForTransformation;return i[0]=e,i[1]=t,this._renderer.transformToScene(i)}transformToDrawingX(e,t){return this.transformToDrawing(e,t)[0]}transformToDrawingY(e,t){return this.transformToDrawing(e,t)[1]}transformToSceneX(e,t){return this.transformToScene(e,t)[0]}transformToSceneY(e,t){return this.transformToScene(e,t)[1]}setRectangularCollisionMask(e,t,i,o){if(!this._customCollisionMask){const l=new s.Polygon;l.vertices.push([0,0]),l.vertices.push([0,0]),l.vertices.push([0,0]),l.vertices.push([0,0]),this._customCollisionMask=[l]}const r=this._customCollisionMask[0].vertices;r[0][0]=e,r[0][1]=t,r[1][0]=i,r[1][1]=t,r[2][0]=i,r[2][1]=o,r[3][0]=e,r[3][1]=o,this.invalidateHitboxes()}updateHitBoxes(){this.hitBoxes=this._defaultHitBoxes;const e=this.getWidth(),t=this.getHeight(),i=this.getCenterX(),o=this.getCenterY(),r=this.hitBoxes[0].vertices;if(this._customCollisionMask){const l=this._customCollisionMask[0].vertices;for(let a=0;a<4;a++){const h=this.transformToScene(l[a][0],l[a][1]);r[a][0]=h[0],r[a][1]=h[1]}}else i===e/2&&o===t/2?(r[0][0]=-i,r[0][1]=-o,r[1][0]=+i,r[1][1]=-o,r[2][0]=+i,r[2][1]=+o,r[3][0]=-i,r[3][1]=+o):(r[0][0]=0-i,r[0][1]=0-o,r[1][0]=e-i,r[1][1]=0-o,r[2][0]=e-i,r[2][1]=t-o,r[3][0]=0-i,r[3][1]=t-o),this._useAbsoluteCoordinates||this.hitBoxes[0].rotate(s.toRad(this.getAngle())),this.hitBoxes[0].move(this.getDrawableX()+i,this.getDrawableY()+o)}};let f=n;f._pointForTransformation=[0,0],s.ShapePainterRuntimeObject=f,s.registerObject("PrimitiveDrawing::Drawer",s.ShapePainterRuntimeObject),f.supportsReinitialization=!1})(gdjs||(gdjs={}));
//# sourceMappingURL=shapepainterruntimeobject.js.map