// RAC - ruler-and-compass - minified - 1.3.0 1375-a1012dd 2023-10-18T20:11:17.183Z
!function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var p="function"==typeof require&&require;if(!f&&p)return p(i,!0);if(u)return u(i,!0);throw(p=new Error("Cannot find module '"+i+"'")).code="MODULE_NOT_FOUND",p}p=n[i]={exports:{}},e[i][0].call(p.exports,function(r){return o(e[i][1][r]||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}({1:[function(require,module,exports){module.exports={version:"1.3.0",build:"1375-a1012dd",dated:"2023-10-18T20:11:17.183Z"}},{}],2:[function(require,module,exports){"use strict";var versioning=require("../built/versioning");const version=versioning.version,build=versioning.build,dated=versioning.dated;class Rac{constructor(){utils.addConstantTo(this,"version",version),utils.addConstantTo(this,"build",build),utils.addConstantTo(this,"dated",dated),this.equalityThreshold=.001,this.unitaryEqualityThreshold=3e-7,this.utils=utils,this.stack=[],this.shapeStack=[],this.compositeStack=[],this.textFormatDefaults={font:null,size:15},this.drawer=null,require("./attachInstanceFunctions")(this),require("./style/instance.Color")(this),require("./style/instance.Stroke")(this),require("./style/instance.Fill")(this),require("./drawable/instance.Angle")(this),require("./drawable/instance.Point")(this),require("./drawable/instance.Ray")(this),require("./drawable/instance.Segment")(this),require("./drawable/instance.Arc")(this),require("./drawable/instance.Bezier")(this),require("./drawable/instance.Text.Format")(this),require("./drawable/instance.Text")(this),this.controller=new Rac.Controller(this)}setupDrawer(p5Instance){this.drawer=new Rac.P5Drawer(this,p5Instance)}equals(a,b){return null!==a&&null!==b&&Math.abs(a-b)<this.equalityThreshold}unitaryEquals(a,b){return null!==a&&null!==b&&Math.abs(a-b)<this.unitaryEqualityThreshold}pushStack(obj){this.stack.push(obj)}peekStack(){return this.stack.length<=0?null:this.stack[this.stack.length-1]}popStack(){return this.stack.length<=0?null:this.stack.pop()}pushShape(shape=null){return shape=shape??new Rac.Shape(this),this.shapeStack.push(shape),shape}peekShape(){return this.shapeStack.length<=0?null:this.shapeStack[this.shapeStack.length-1]}popShape(){return this.shapeStack.length<=0?null:this.shapeStack.pop()}pushComposite(composite){return composite=composite??new Rac.Composite(this),this.compositeStack.push(composite),composite}peekComposite(){return this.compositeStack.length<=0?null:this.compositeStack[this.compositeStack.length-1]}popComposite(){return this.compositeStack.length<=0?null:this.compositeStack.pop()}}module.exports=Rac;const utils=require("./util/utils");Rac.utils=utils,utils.addConstantTo(Rac,"version",version),utils.addConstantTo(Rac,"build",build),utils.addConstantTo(Rac,"dated",dated),utils.addConstantTo(Rac,"TAU",2*Math.PI),Rac.Exception=require("./util/Exception"),require("./attachProtoFunctions")(Rac),Rac.P5Drawer=require("./p5Drawer/P5Drawer"),Rac.Color=require("./style/Color"),Rac.Stroke=require("./style/Stroke"),Rac.setupStyleProtoFunctions(Rac.Stroke),Rac.Fill=require("./style/Fill"),Rac.setupStyleProtoFunctions(Rac.Fill),Rac.StyleContainer=require("./style/StyleContainer"),Rac.setupStyleProtoFunctions(Rac.StyleContainer),Rac.Angle=require("./drawable/Angle"),Rac.Angle.prototype.log=Rac.drawableProtoFunctions.log,Rac.Point=require("./drawable/Point"),Rac.setupDrawableProtoFunctions(Rac.Point),Rac.Ray=require("./drawable/Ray"),Rac.setupDrawableProtoFunctions(Rac.Ray),Rac.Segment=require("./drawable/Segment"),Rac.setupDrawableProtoFunctions(Rac.Segment),Rac.Arc=require("./drawable/Arc"),Rac.setupDrawableProtoFunctions(Rac.Arc),Rac.Text=require("./drawable/Text"),Rac.setupDrawableProtoFunctions(Rac.Text),Rac.Bezier=require("./drawable/Bezier"),Rac.setupDrawableProtoFunctions(Rac.Bezier),Rac.Composite=require("./drawable/Composite"),Rac.setupDrawableProtoFunctions(Rac.Composite),Rac.Shape=require("./drawable/Shape"),Rac.setupDrawableProtoFunctions(Rac.Shape),Rac.EaseFunction=require("./util/EaseFunction"),Rac.Controller=require("./control/Controller"),Rac.Control=require("./control/Control"),Rac.RayControl=require("./control/RayControl"),Rac.ArcControl=require("./control/ArcControl")},{"../built/versioning":1,"./attachInstanceFunctions":3,"./attachProtoFunctions":4,"./control/ArcControl":5,"./control/Control":6,"./control/Controller":7,"./control/RayControl":8,"./drawable/Angle":9,"./drawable/Arc":10,"./drawable/Bezier":11,"./drawable/Composite":12,"./drawable/Point":13,"./drawable/Ray":14,"./drawable/Segment":15,"./drawable/Shape":16,"./drawable/Text":18,"./drawable/instance.Angle":19,"./drawable/instance.Arc":20,"./drawable/instance.Bezier":21,"./drawable/instance.Point":22,"./drawable/instance.Ray":23,"./drawable/instance.Segment":24,"./drawable/instance.Text":26,"./drawable/instance.Text.Format":25,"./p5Drawer/P5Drawer":28,"./style/Color":34,"./style/Fill":35,"./style/Stroke":36,"./style/StyleContainer":37,"./style/instance.Color":38,"./style/instance.Fill":39,"./style/instance.Stroke":40,"./util/EaseFunction":41,"./util/Exception":42,"./util/utils":43}],3:[function(require,module,exports){"use strict";const Rac=require("./Rac");module.exports=function(rac){rac.Color=function(r,g,b,a=1){return new Rac.Color(this,r,g,b,a)},rac.Stroke=function(weight,color=null){return new Rac.Stroke(this,weight,color)},rac.Fill=function(color=null){return new Rac.Fill(this,color)},rac.Style=function(stroke=null,fill=null){return new Rac.Style(this,stroke,fill)},rac.Angle=function(turn){return new Rac.Angle(this,turn)},rac.Point=function(x,y){return new Rac.Point(this,x,y)},rac.Ray=function(x,start,angle){start=new Rac.Point(this,x,start);return angle=Rac.Angle.from(this,angle),new Rac.Ray(this,start,angle)},rac.Segment=function(x,start,ray,length){start=new Rac.Point(this,x,start);ray=Rac.Angle.from(this,ray);ray=new Rac.Ray(this,start,ray);return new Rac.Segment(this,ray,length)},rac.Arc=function(x,center,radius,start=this.Angle.zero,end=null,clockwise=!0){center=new Rac.Point(this,x,center);return start=Rac.Angle.from(this,start),end=null===end?start:Rac.Angle.from(this,end),new Rac.Arc(this,center,radius,start,end,clockwise)},rac.Text=function(x,point,string,format=this.Text.Format.topLeft){point=new Rac.Point(this,x,point);return new Rac.Text(this,point,string,format)},rac.TextFormat=function(hAlign,vAlign,angle=rac.Angle.zero,font=null,size=null,hPadding=0,vPadding=0){return angle=Rac.Angle.from(rac,angle),new Rac.Text.Format(rac,hAlign,vAlign,angle,font,size,hPadding,vPadding)},rac.Text.Format=rac.TextFormat,rac.Bezier=function(startX,start,startAnchorX,startAnchor,endAnchorX,endAnchor,endX,end){start=new Rac.Point(this,startX,start),startAnchor=new Rac.Point(this,startAnchorX,startAnchor),endAnchor=new Rac.Point(this,endAnchorX,endAnchor),end=new Rac.Point(this,endX,end);return new Rac.Bezier(this,start,startAnchor,endAnchor,end)},rac.Composite=function(sequence=[]){return new Rac.Composite(this,sequence)}}},{"./Rac":2}],4:[function(require,module,exports){"use strict";const utils=require("./util/utils");module.exports=function(Rac){function assertDrawer(drawable){if(null==drawable.rac||null==drawable.rac.drawer)throw Rac.Exception.drawerNotSetup(`drawable-type:${utils.typeName(drawable)}`)}Rac.drawableProtoFunctions={},Rac.setupDrawableProtoFunctions=function(drawableClass){Object.keys(Rac.drawableProtoFunctions).forEach(name=>{drawableClass.prototype[name]=Rac.drawableProtoFunctions[name]})},Rac.drawableProtoFunctions.draw=function(style=null){return assertDrawer(this),this.rac.drawer.drawObject(this,style),this},Rac.drawableProtoFunctions.debug=function(drawsText=!1){return assertDrawer(this),this.rac.drawer.debugObject(this,drawsText),this},Rac.drawableProtoFunctions.log=function(message=null){return console.log(message??"%o",this),this},Rac.drawableProtoFunctions.push=function(){return this.rac.pushStack(this),this},Rac.drawableProtoFunctions.pop=function(){return this.rac.popStack()},Rac.drawableProtoFunctions.peek=function(){return this.rac.peekStack()},Rac.drawableProtoFunctions.attachToShape=function(){return this.rac.peekShape().addOutline(this),this},Rac.drawableProtoFunctions.popShape=function(){return this.rac.popShape()},Rac.drawableProtoFunctions.popShapeToComposite=function(){var shape=this.rac.popShape();return this.rac.peekComposite().add(shape),this},Rac.drawableProtoFunctions.attachToComposite=function(){return this.rac.peekComposite().add(this),this},Rac.drawableProtoFunctions.popComposite=function(){return this.rac.popComposite()},Rac.drawableProtoFunctions.attachTo=function(someComposite){if(someComposite instanceof Rac.Composite)return someComposite.add(this),this;if(someComposite instanceof Rac.Shape)return someComposite.addOutline(this),this;throw Rac.Exception.invalidObjectType(`Cannot attachTo composite - someComposite-type:${utils.typeName(someComposite)}`)},Rac.styleProtoFunctions={},Rac.setupStyleProtoFunctions=function(classObj){Object.keys(Rac.styleProtoFunctions).forEach(name=>{classObj.prototype[name]=Rac.styleProtoFunctions[name]})},Rac.styleProtoFunctions.apply=function(){assertDrawer(this),this.rac.drawer.applyObject(this)},Rac.styleProtoFunctions.log=Rac.drawableProtoFunctions.log,Rac.styleProtoFunctions.applyToClass=function(classObj){assertDrawer(this),this.rac.drawer.setClassDrawStyle(classObj,this)}}},{"./util/utils":43}],5:[function(require,module,exports){"use strict";let Rac=require("../Rac"),utils=require("../util/utils");class ArcControl extends Rac.Control{constructor(rac,value,angleDistance){utils.assertExists(rac),utils.assertNumber(value),utils.assertType(Rac.Angle,angleDistance),super(rac,value),this.angleDistance=Rac.Angle.from(rac,angleDistance),this.anchor=null,rac.controller.autoAddControls&&rac.controller.add(this)}setValueWithAngleDistance(distanceRatio){distanceRatio=(distanceRatio=Rac.Angle.from(this.rac,distanceRatio)).turn/this.angleDistance.turnOne();this.value=distanceRatio}setLimitsWithAngleDistanceInsets(startInset,endInset){startInset=Rac.Angle.from(this.rac,startInset),endInset=Rac.Angle.from(this.rac,endInset),this.startLimit=startInset.turn/this.angleDistance.turnOne(),this.endLimit=(this.angleDistance.turnOne()-endInset.turn)/this.angleDistance.turnOne()}distance(){return this.angleDistance.multOne(this.value)}knob(){return null===this.anchor?null:this.anchor.pointAtAngleDistance(this.distance())}affixAnchor(){if(null===this.anchor)throw Rac.Exception.invalidObjectConfiguration("Expected anchor to be set, null found instead");return this.anchor.withAngleDistance(this.angleDistance)}draw(){if(null!==this.anchor){let fixedAnchor=this.affixAnchor(),controllerStyle=this.rac.controller.controlStyle,controlStyle=null!==controllerStyle?controllerStyle.appendStyle(this.style):this.style;var negAngle=null!==controlStyle?controlStyle.appendStyle(this.rac.Fill.none):this.rac.Fill.none;fixedAnchor.draw(negAngle);let knob=this.knob(),angle=fixedAnchor.center.angleToPoint(knob);this.rac.pushComposite(),this.markers.forEach(point=>{if(!(point<0||1<point)){point=this.angleDistance.multOne(point);let markerAngle=fixedAnchor.shiftAngle(point);point=fixedAnchor.pointAtAngle(markerAngle);Rac.Control.makeValueMarker(this.rac,point,markerAngle.perpendicular(!fixedAnchor.clockwise)).attachToComposite()}},this),knob.arc(this.rac.controller.knobRadius).attachToComposite();var pointerStyle,hasPositiveRange=this.angleDistance.equals(this.rac.Angle.zero)&&0==this.startLimit&&1==this.endLimit,negAngle=hasPositiveRange||this.value>=this.startLimit+this.rac.unitaryEqualityThreshold,hasPositiveRange=hasPositiveRange||this.value<=this.endLimit-this.rac.unitaryEqualityThreshold;negAngle&&(negAngle=angle.perpendicular(fixedAnchor.clockwise).inverse(),Rac.Control.makeArrowShape(this.rac,knob,negAngle).attachToComposite()),hasPositiveRange&&(pointerStyle=angle.perpendicular(fixedAnchor.clockwise),Rac.Control.makeArrowShape(this.rac,knob,pointerStyle).attachToComposite()),this.rac.popComposite().draw(controlStyle),!this.isSelected()||null!==(pointerStyle=this.rac.controller.pointerStyle)&&knob.arc(1.5*this.rac.controller.knobRadius).draw(pointerStyle)}}updateWithPointer(distanceRatio,fixedAnchor){let angleDistance=fixedAnchor.angleDistance();var startInset=angleDistance.multOne(this.startLimit),endInset=angleDistance.multOne(1-this.endLimit),distanceRatio=fixedAnchor.center.angleToPoint(distanceRatio),distanceRatio=fixedAnchor.clampToAngles(distanceRatio,startInset,endInset),distanceRatio=fixedAnchor.distanceFromStart(distanceRatio).turn/this.angleDistance.turnOne();this.value=distanceRatio}drawSelection(pointerCenter,fixedAnchor,pointerToKnobOffset){let pointerStyle=this.rac.controller.pointerStyle;if(null!==pointerStyle){var markerAngle=pointerStyle.appendStyle(this.rac.Fill.none);fixedAnchor.draw(markerAngle);let angleDistance=fixedAnchor.angleDistance();if(this.rac.pushComposite(),this.markers.forEach(markerPoint=>{if(!(markerPoint<0||1<markerPoint)){let markerAngle=fixedAnchor.shiftAngle(angleDistance.multOne(markerPoint));markerPoint=fixedAnchor.pointAtAngle(markerAngle);Rac.Control.makeValueMarker(this.rac,markerPoint,markerAngle.perpendicular(!fixedAnchor.clockwise)).attachToComposite()}}),0<this.startLimit){let minAngle=fixedAnchor.shiftAngle(angleDistance.multOne(this.startLimit));var maxPoint=fixedAnchor.pointAtAngle(minAngle),markerAngle=minAngle.perpendicular(fixedAnchor.clockwise);Rac.Control.makeLimitMarker(this.rac,maxPoint,markerAngle).attachToComposite()}if(this.endLimit<1){let maxAngle=fixedAnchor.shiftAngle(angleDistance.multOne(this.endLimit));maxPoint=fixedAnchor.pointAtAngle(maxAngle),markerAngle=maxAngle.perpendicular(!fixedAnchor.clockwise);Rac.Control.makeLimitMarker(this.rac,maxPoint,markerAngle).attachToComposite()}let draggedCenter=pointerToKnobOffset.withStartPoint(pointerCenter).endPoint();draggedCenter.arc(2).attachToComposite(),this.rac.popComposite().draw(pointerStyle)}}}module.exports=ArcControl},{"../Rac":2,"../util/utils":43}],6:[function(require,module,exports){"use strict";let Rac=require("../Rac"),utils=require("../util/utils");class Control{constructor(rac,value){utils.assertExists(rac),utils.assertNumber(value),this.rac=rac,this.value=value,this.projectionStart=0,this.projectionEnd=1,this.startLimit=0,this.endLimit=1,this.markers=[],this.style=null}projectedValue(){var projectionRange=this.projectionEnd-this.projectionStart;return this.value*projectionRange+this.projectionStart}setProjectionRange(start,end){this.projectionStart=start,this.projectionEnd=end}setLimitsWithInsets(startInset,endInset){this.startLimit=startInset,this.endLimit=1-endInset}addMarkerAtCurrentValue(){this.markers.push(this.value)}isSelected(){return null!==this.rac.controller.selection&&this.rac.controller.selection.control===this}knob(){throw Rac.Exception.abstractFunctionCalled(`this-type:${utils.typeName(this)}`)}affixAnchor(){throw Rac.Exception.abstractFunctionCalled(`this-type:${utils.typeName(this)}`)}draw(){throw Rac.Exception.abstractFunctionCalled(`this-type:${utils.typeName(this)}`)}updateWithPointer(pointerKnobCenter,fixedAnchor){throw Rac.Exception.abstractFunctionCalled(`this-type:${utils.typeName(this)}`)}drawSelection(pointerCenter,fixedAnchor,pointerToKnobOffset){throw Rac.Exception.abstractFunctionCalled(`this-type:${utils.typeName(this)}`)}}(module.exports=Control).makeArrowShape=function(rac,center,angle){var leftWall=rac.Angle.from(1/22);let arc=center.arc(1.5*rac.controller.knobRadius,angle.subtract(leftWall),angle.add(leftWall));leftWall=rac.Angle.from(1/8);let rightWall=arc.startPoint().ray(angle.add(leftWall));leftWall=arc.endPoint().ray(angle.subtract(leftWall));let point=rightWall.pointAtIntersection(leftWall);return rac.pushShape(),point.segmentToPoint(arc.startPoint()).attachToShape(),arc.attachToShape(),arc.endPoint().segmentToPoint(point).attachToShape(),rac.popShape()},Control.makeLimitMarker=function(composite,point,perpendicular){perpendicular=(perpendicular=composite.Angle.from(perpendicular)).perpendicular(!1),composite=new Rac.Composite(composite);return point.segmentToAngle(perpendicular,4).withStartExtension(4).attachTo(composite),point.pointToAngle(perpendicular,8).arc(3).attachTo(composite),composite},Control.makeValueMarker=function(rac,point,angle){return angle=rac.Angle.from(angle),point.segmentToAngle(angle.perpendicular(),3).withStartExtension(3)}},{"../Rac":2,"../util/utils":43}],7:[function(require,module,exports){"use strict";let Rac=require("../Rac");require("../util/utils");class Controller{static Selection=class{constructor(control,pointerCenter){this.control=control,this.fixedAnchor=control.affixAnchor(),this.pointerToKnobOffset=pointerCenter.segmentToPoint(control.knob())}drawSelection(pointerCenter){this.control.drawSelection(pointerCenter,this.fixedAnchor,this.pointerToKnobOffset)}};constructor(rac){this.rac=rac,this.knobRadius=22,this.controls=[],this.autoAddControls=!0,this.lastPointer=null,this.pointerStyle=rac.Fill.none,this.controlStyle=null,this.selection=null}add(control){this.controls.push(control)}pointerPressed(pointerCenter){this.lastPointer=null;var selected=this.controls.find(item=>{const controlKnob=item.knob();return null!==controlKnob&&controlKnob.distanceToPoint(pointerCenter)<=this.knobRadius});void 0!==selected&&(this.selection=new Controller.Selection(selected,pointerCenter))}pointerDragged(pointerKnobCenter){if(null!==this.selection){let control=this.selection.control;var fixedAnchor=this.selection.fixedAnchor,pointerKnobCenter=this.selection.pointerToKnobOffset.withStartPoint(pointerKnobCenter).endPoint();control.updateWithPointer(pointerKnobCenter,fixedAnchor)}}pointerReleased(pointerCenter){null!==this.selection?(this.lastPointer=this.selection.control,this.selection=null):this.lastPointer=pointerCenter}drawControls(){var pointerCenter=this.rac.Point.pointer();this.drawPointer(pointerCenter),this.controls.forEach(item=>item.draw()),null!==this.selection&&this.selection.drawSelection(pointerCenter)}drawPointer(pointerCenter){var pointerStyle=this.pointerStyle;null!==pointerStyle&&(this.lastPointer instanceof Rac.Point&&this.lastPointer.arc(12).draw(pointerStyle),this.lastPointer,Rac.Control,this.rac.drawer.p5.mouseIsPressed&&(null===this.selection?pointerCenter.arc(10):pointerCenter.arc(5)).draw(pointerStyle))}}module.exports=Controller},{"../Rac":2,"../util/utils":43}],8:[function(require,module,exports){"use strict";let Rac=require("../Rac"),utils=require("../util/utils");class RayControl extends Rac.Control{constructor(rac,value,length){utils.assertExists(rac,value,length),utils.assertNumber(value,length),super(rac,value),this.length=length,this.anchor=null,rac.controller.autoAddControls&&rac.controller.add(this)}startLimitLength(){return this.startLimit*this.length}endLimitLength(){return this.endLimit*this.length}setValueWithLength(lengthRatio){lengthRatio/=this.length;this.value=lengthRatio}setLimitsWithLengthInsets(startInset,endInset){this.startLimit=startInset/this.length,this.endLimit=(this.length-endInset)/this.length}distance(){return this.length*this.value}knob(){return null===this.anchor?null:this.anchor.pointAtDistance(this.distance())}affixAnchor(){if(null===this.anchor)throw Rac.Exception.invalidObjectConfiguration("Expected anchor to be set, null found instead");return this.anchor.segment(this.length)}draw(){if(null!==this.anchor){let fixedAnchor=this.affixAnchor(),controllerStyle=this.rac.controller.controlStyle;var pointerStyle=null!==controllerStyle?controllerStyle.appendStyle(this.style):this.style;fixedAnchor.draw(pointerStyle);let knob=this.knob(),angle=fixedAnchor.angle();this.rac.pushComposite(),this.markers.forEach(point=>{point<0||1<point||(point=fixedAnchor.startPoint().pointToAngle(angle,this.length*point),Rac.Control.makeValueMarker(this.rac,point,angle).attachToComposite())},this),knob.arc(this.rac.controller.knobRadius).attachToComposite(),this.value>=this.startLimit+this.rac.unitaryEqualityThreshold&&Rac.Control.makeArrowShape(this.rac,knob,angle.inverse()).attachToComposite(),this.value<=this.endLimit-this.rac.unitaryEqualityThreshold&&Rac.Control.makeArrowShape(this.rac,knob,angle).attachToComposite(),this.rac.popComposite().draw(pointerStyle),!this.isSelected()||null!==(pointerStyle=this.rac.controller.pointerStyle)&&knob.arc(1.5*this.rac.controller.knobRadius).draw(pointerStyle)}}updateWithPointer(newDistance,fixedAnchor){var length=fixedAnchor.length,startInset=length*this.startLimit,endInset=length*(1-this.endLimit),newDistance=fixedAnchor.ray.distanceToProjectedPoint(newDistance),newDistance=fixedAnchor.clampToLength(newDistance,startInset,endInset);this.value=newDistance/length}drawSelection(endInset,fixedAnchor,startInset){var minPoint,pointerStyle=this.rac.controller.pointerStyle;if(null!==pointerStyle){this.rac.pushComposite(),fixedAnchor.attachToComposite();let angle=fixedAnchor.angle(),length=fixedAnchor.length;this.markers.forEach(markerPoint=>{markerPoint<0||1<markerPoint||(markerPoint=fixedAnchor.startPoint().pointToAngle(angle,length*markerPoint),Rac.Control.makeValueMarker(this.rac,markerPoint,angle).attachToComposite())}),0<this.startLimit&&(minPoint=fixedAnchor.startPoint().pointToAngle(angle,length*this.startLimit),Rac.Control.makeLimitMarker(this.rac,minPoint,angle).attachToComposite()),this.endLimit<1&&(easedLength=fixedAnchor.startPoint().pointToAngle(angle,length*this.endLimit),Rac.Control.makeLimitMarker(this.rac,easedLength,angle.inverse()).attachToComposite());let draggedCenter=startInset.withStartPoint(endInset).endPoint();draggedCenter.arc(2).attachToComposite();var easedLength=fixedAnchor.ray.distanceToProjectedPoint(draggedCenter),startInset=length*this.startLimit,endInset=length*(1-this.endLimit),easedLength=fixedAnchor.clampToLength(easedLength,startInset,endInset);let constrainedAnchorCenter=fixedAnchor.withLength(easedLength).endPoint();constrainedAnchorCenter.arc(this.rac.controller.knobRadius).attachToComposite();let draggedShadowCenter=draggedCenter.segmentToProjectionInRay(fixedAnchor.ray).reverse().withStartPoint(constrainedAnchorCenter).attachToComposite().endPoint();draggedShadowCenter.arc(this.rac.controller.knobRadius/2).attachToComposite();let easeOut=Rac.EaseFunction.makeEaseOut();easeOut.postBehavior=Rac.EaseFunction.Behavior.clamp;easedLength=5*this.rac.controller.knobRadius;easeOut.inRange=2*easedLength,easeOut.outRange=easedLength;let draggedTail=draggedShadowCenter.segmentToPoint(draggedCenter);easedLength=easeOut.easeValue(draggedTail.length);draggedTail.withLength(easedLength).attachToComposite(),this.rac.popComposite().draw(pointerStyle)}}}module.exports=RayControl},{"../Rac":2,"../util/utils":43}],9:[function(require,module,exports){"use strict";const Rac=require("../Rac"),utils=require("../util/utils");class Angle{constructor(rac,turn){utils.assertType(Rac,rac),utils.assertNumber(turn),this.rac=rac,this.turn=turn=(turn%=1)<0?(turn+1)%1:turn}toString(digits=null){return`Angle(${utils.cutDigits(this.turn,digits)})`}equals(diff){if(!(diff instanceof Rac.Angle)){if("number"!=typeof diff)return!1;diff=Angle.from(this.rac,diff)}diff=Math.abs(this.turn-diff.turn);return diff<this.rac.unitaryEqualityThreshold||1-diff<this.rac.unitaryEqualityThreshold}static from(rac,something){if(something instanceof Rac.Angle)return something;if("number"==typeof something)return new Angle(rac,something);if(something instanceof Rac.Ray)return something.angle;if(something instanceof Rac.Segment)return something.ray.angle;throw Rac.Exception.invalidObjectType(`Cannot derive Rac.Angle - something-type:${utils.typeName(something)}`)}static fromRadians(rac,radians){return new Angle(rac,radians/Rac.TAU)}static fromDegrees(rac,degrees){return new Angle(rac,degrees/360)}inverse(){return this.add(this.rac.Angle.inverse)}negative(){return new Angle(this.rac,-this.turn)}perpendicular(clockwise=!0){return this.shift(this.rac.Angle.square,clockwise)}radians(){return this.turn*Rac.TAU}degrees(){return 360*this.turn}sin(){return Math.sin(this.radians())}cos(){return Math.cos(this.radians())}tan(){return Math.tan(this.radians())}turnOne(){return 0===this.turn?1:this.turn}add(angle){return angle=this.rac.Angle.from(angle),new Angle(this.rac,this.turn+angle.turn)}subtract(angle){return angle=this.rac.Angle.from(angle),new Angle(this.rac,this.turn-angle.turn)}mult(factor){return new Angle(this.rac,this.turn*factor)}multOne(factor){return new Angle(this.rac,this.turnOne()*factor)}distance(angle,clockwise=!0){const distance=(angle=this.rac.Angle.from(angle)).subtract(this);return clockwise?distance:distance.negative()}shift(angle,clockwise=!0){return angle=this.rac.Angle.from(angle),clockwise?this.add(angle):this.subtract(angle)}shiftToOrigin(origin,clockwise){return(origin=this.rac.Angle.from(origin)).shift(this,clockwise)}}module.exports=Angle},{"../Rac":2,"../util/utils":43}],10:[function(require,module,exports){"use strict";const Rac=require("../Rac"),utils=require("../util/utils");module.exports=class Arc{constructor(rac,center,radius,start,end,clockwise){utils.assertExists(rac,center,radius,start,end,clockwise),utils.assertType(Rac.Point,center),utils.assertNumber(radius),utils.assertType(Rac.Angle,start,end),utils.assertBoolean(clockwise),this.rac=rac,this.center=center,this.radius=radius,this.start=start,this.end=end,this.clockwise=clockwise}toString(digits=null){return`Arc((${utils.cutDigits(this.center.x,digits)},${utils.cutDigits(this.center.y,digits)}) r:${utils.cutDigits(this.radius,digits)} s:${utils.cutDigits(this.start.turn,digits)} e:${utils.cutDigits(this.end.turn,digits)} c:${this.clockwise})`}equals(otherArc){return otherArc instanceof Arc&&this.rac.equals(this.radius,otherArc.radius)&&this.clockwise===otherArc.clockwise&&this.center.equals(otherArc.center)&&this.start.equals(otherArc.start)&&this.end.equals(otherArc.end)}length(){return this.angleDistance().turnOne()*this.radius*Rac.TAU}circumference(){return this.radius*Rac.TAU}angleDistance(){return this.start.distance(this.end,this.clockwise)}startPoint(){return this.pointAtAngle(this.start)}endPoint(){return this.pointAtAngle(this.end)}startRay(){return new Rac.Ray(this.rac,this.center,this.start)}endRay(){return new Rac.Ray(this.rac,this.center,this.end)}startTangentRay(){var tangentAngle=this.start.perpendicular(this.clockwise);return this.startPoint().ray(tangentAngle)}endTangentRay(){var tangentAngle=this.end.perpendicular(!this.clockwise);return this.endPoint().ray(tangentAngle)}startRadiusSegment(){return new Rac.Segment(this.rac,this.startRay(),this.radius)}startSegment(){return this.startRadiusSegment()}endRadiusSegment(){return new Rac.Segment(this.rac,this.endRay(),this.radius)}endSegment(){return this.endRadiusSegment()}chordSegment(){var perpendicular=this.start.perpendicular(this.clockwise);return this.startPoint().segmentToPoint(this.endPoint(),perpendicular)}isCircle(){return this.start.equals(this.end)}withCenter(newCenter){return new Arc(this.rac,newCenter,this.radius,this.start,this.end,this.clockwise)}withStart(newStartAngle){return newStartAngle=Rac.Angle.from(this.rac,newStartAngle),new Arc(this.rac,this.center,this.radius,newStartAngle,this.end,this.clockwise)}withEnd(newEndAngle){return newEndAngle=Rac.Angle.from(this.rac,newEndAngle),new Arc(this.rac,this.center,this.radius,this.start,newEndAngle,this.clockwise)}withRadius(newRadius){return new Arc(this.rac,this.center,newRadius,this.start,this.end,this.clockwise)}withClockwise(newClockwise){return new Arc(this.rac,this.center,this.radius,this.start,this.end,newClockwise)}withAngleDistance(newEnd){return newEnd=this.shiftAngle(newEnd),new Arc(this.rac,this.center,this.radius,this.start,newEnd,this.clockwise)}withLength(newAngleDistance){return newAngleDistance/=this.circumference(),this.withAngleDistance(newAngleDistance)}withLengthAdd(newAngleDistance){return newAngleDistance=(this.length()+newAngleDistance)/this.circumference(),this.withAngleDistance(newAngleDistance)}withLengthRatio(newLength){return newLength=this.length()*newLength,this.withLength(newLength)}withStartPoint(newRadius){var newStart=this.center.angleToPoint(newRadius,this.start),newRadius=this.center.distanceToPoint(newRadius);return new Arc(this.rac,this.center,newRadius,newStart,this.end,this.clockwise)}withEndPoint(newRadius){var newEnd=this.center.angleToPoint(newRadius,this.end),newRadius=this.center.distanceToPoint(newRadius);return new Arc(this.rac,this.center,newRadius,this.start,newEnd,this.clockwise)}withStartTowardsPoint(newStart){return newStart=this.center.angleToPoint(newStart,this.start),new Arc(this.rac,this.center,this.radius,newStart,this.end,this.clockwise)}withEndTowardsPoint(newEnd){return newEnd=this.center.angleToPoint(newEnd,this.end),new Arc(this.rac,this.center,this.radius,this.start,newEnd,this.clockwise)}withAnglesTowardsPoint(newStart,newEnd=null){return newStart=this.center.angleToPoint(newStart,this.start),newEnd=null===newEnd?newStart:this.center.angleToPoint(newEnd,this.end),new Arc(this.rac,this.center,this.radius,newStart,newEnd,this.clockwise)}withStartExtension(newStart){return newStart=this.start.shift(newStart,!this.clockwise),new Arc(this.rac,this.center,this.radius,newStart,this.end,this.clockwise)}withEndExtension(newEnd){return newEnd=this.end.shift(newEnd,this.clockwise),new Arc(this.rac,this.center,this.radius,this.start,newEnd,this.clockwise)}reverse(){return new Arc(this.rac,this.center,this.radius,this.end,this.start,!this.clockwise)}clampToAngles(distanceToStartClamp,startInset=this.rac.Angle.zero,endInset=this.rac.Angle.zero){if(distanceToStartClamp=Rac.Angle.from(this.rac,distanceToStartClamp),startInset=Rac.Angle.from(this.rac,startInset),endInset=Rac.Angle.from(this.rac,endInset),this.isCircle()&&0==startInset.turn&&0==endInset.turn)return distanceToStartClamp;var distanceToEndClamp=this.distanceFromStart(distanceToStartClamp);const angleDistance=this.angleDistance(),shiftedStartClamp=startInset,shiftedEndClamp=angleDistance.subtract(endInset);var middle=startInset.turn+endInset.turn;if(middle>=angleDistance.turnOne()){const rangeDistance=shiftedEndClamp.distance(shiftedStartClamp);let halfRange;return halfRange=!this.isCircle()&&1<=middle?rangeDistance.multOne(.5):rangeDistance.mult(.5),middle=shiftedEndClamp.add(halfRange),middle=this.start.shift(middle,this.clockwise),this.clampToAngles(middle)}return distanceToEndClamp.turn>=shiftedStartClamp.turn&&distanceToEndClamp.turn<=shiftedEndClamp.turn?distanceToStartClamp:(distanceToStartClamp=shiftedStartClamp.distance(distanceToEndClamp,!1),distanceToEndClamp=shiftedEndClamp.distance(distanceToEndClamp),distanceToStartClamp.turn<=distanceToEndClamp.turn?this.start.shift(startInset,this.clockwise):this.end.shift(endInset,!this.clockwise))}containsAngle(startOffset){if(startOffset=Rac.Angle.from(this.rac,startOffset),this.isCircle())return!0;if(this.clockwise){var offset=startOffset.subtract(this.start),endOffset=this.end.subtract(this.start);return offset.turn<=endOffset.turn}var offset=startOffset.subtract(this.end),startOffset=this.start.subtract(this.end);return offset.turn<=startOffset.turn}containsProjectedPoint(point){return!!this.isCircle()||this.containsAngle(this.center.angleToPoint(point))}shift(newEnd){var newStart=this.start.shift(newEnd,this.clockwise),newEnd=this.end.shift(newEnd,this.clockwise);return new Arc(this.rac,this.center,this.radius,newStart,newEnd,this.clockwise)}shiftAngle(angle){return angle=Rac.Angle.from(this.rac,angle),this.start.shift(angle,this.clockwise)}distanceFromStart(angle){return angle=Rac.Angle.from(this.rac,angle),this.start.distance(angle,this.clockwise)}pointAtAngle(angle){return angle=Rac.Angle.from(this.rac,angle),this.center.pointToAngle(angle,this.radius)}pointAtAngleDistance(shiftedAngle){return shiftedAngle=this.shiftAngle(shiftedAngle),this.pointAtAngle(shiftedAngle)}pointAtLength(angleDistance){return angleDistance/=this.circumference(),this.pointAtAngleDistance(angleDistance)}pointAtLengthRatio(shiftedAngle){return shiftedAngle=this.angleDistance().multOne(shiftedAngle),shiftedAngle=this.shiftAngle(shiftedAngle),this.pointAtAngle(shiftedAngle)}radiusSegmentAtAngle(newRay){return newRay=Rac.Angle.from(this.rac,newRay),newRay=new Rac.Ray(this.rac,this.center,newRay),new Rac.Segment(this.rac,newRay,this.radius)}radiusSegmentTowardsPoint(newRay){return newRay=this.center.angleToPoint(newRay),newRay=new Rac.Ray(this.rac,this.center,newRay),new Rac.Segment(this.rac,newRay,this.radius)}intersectionChord(otherArc){if(this.center.equals(otherArc.center))return null;var chordLength=this.center.distanceToPoint(otherArc.center);if(chordLength>this.radius+otherArc.radius)return null;var distanceToChord=(Math.pow(chordLength,2)-Math.pow(otherArc.radius,2)+Math.pow(this.radius,2))/(2*chordLength),chordLength=1/chordLength*Math.sqrt((-chordLength+otherArc.radius-this.radius)*(-chordLength-otherArc.radius+this.radius)*(-chordLength+otherArc.radius+this.radius)*(chordLength+otherArc.radius+this.radius));const segmentToChord=this.center.rayToPoint(otherArc.center).segment(distanceToChord);return segmentToChord.nextSegmentPerpendicular(this.clockwise,chordLength/2).reverse().withLengthRatio(2)}intersectionChordWithRay(ray){const bisector=this.center.segmentToProjectionInRay(ray);var angle=bisector.length;if(this.rac.equals(0,angle)){const start=this.pointAtAngle(ray.angle.inverse());var newRay=new Rac.Ray(this.rac,start,ray.angle);return new Rac.Segment(this.rac,newRay,2*this.radius)}if(this.rac.equals(angle,this.radius)){const start=this.pointAtAngle(bisector.ray.angle);var end=new Rac.Ray(this.rac,start,ray.angle);return new Rac.Segment(this.rac,end,0)}if(angle>this.radius)return null;end=Math.acos(angle/this.radius),angle=Rac.Angle.fromRadians(this.rac,end),end=ray.pointOrientation(this.center);const start=this.pointAtAngle(bisector.angle().shift(angle,!end));return end=this.pointAtAngle(bisector.angle().shift(angle,end)),start.segmentToPoint(end,ray.angle)}intersectionChordEndWithRay(ray,perpendicular=!1){const chord=this.intersectionChordWithRay(ray);return null!==chord?chord.endPoint():perpendicular?(perpendicular=ray.pointOrientation(this.center),perpendicular=ray.angle.perpendicular(!perpendicular),this.pointAtAngle(perpendicular)):null}intersectionArc(otherArc){const chord=this.intersectionChord(otherArc);return null===chord?null:this.withAnglesTowardsPoint(chord.startPoint(),chord.endPoint())}tangentSegment(end,defaultAngle=!0,endClockwise=!0){if(this.center.equals(end.center))return null;const hypSegment=this.center.segmentToPoint(end.center);var adjOrientation=defaultAngle===endClockwise?end.radius-this.radius:end.radius+this.radius,opsAngle=this.rac.equals(Math.abs(adjOrientation),hypSegment.length)?0<adjOrientation?1:-1:adjOrientation/hypSegment.length;if(1<Math.abs(opsAngle))return null;adjOrientation=Math.asin(opsAngle),opsAngle=Rac.Angle.fromRadians(this.rac,adjOrientation),adjOrientation=defaultAngle===endClockwise?defaultAngle:!defaultAngle;const shiftedOpsAngle=hypSegment.ray.angle.shift(opsAngle,adjOrientation),shiftedAdjAngle=shiftedOpsAngle.perpendicular(adjOrientation),startAngle=defaultAngle===endClockwise?shiftedAdjAngle:shiftedAdjAngle.inverse(),start=this.pointAtAngle(startAngle);return end=end.pointAtAngle(shiftedAdjAngle),defaultAngle=startAngle.perpendicular(!defaultAngle),start.segmentToPoint(end,defaultAngle)}divideToArcs(count){if(count<=0)return[];const angleDistance=this.angleDistance();var partTurn=angleDistance.turnOne()/count;const arcs=[];for(let index=0;index<count;index+=1){var start=this.start.shift(partTurn*index,this.clockwise),arc=this.start.shift(partTurn*(index+1),this.clockwise),arc=new Arc(this.rac,this.center,this.radius,start,arc,this.clockwise);arcs.push(arc)}return arcs}divideToSegments(count){if(count<=0)return[];const angleDistance=this.angleDistance();var partTurn=angleDistance.turnOne()/count;const segments=[];for(let index=0;index<count;index+=1){var startAngle=this.start.shift(partTurn*index,this.clockwise),segment=this.start.shift(partTurn*(index+1),this.clockwise);const startPoint=this.pointAtAngle(startAngle);segment=this.pointAtAngle(segment),segment=startPoint.segmentToPoint(segment),segments.push(segment)}return segments}divideToBeziers(count){if(count<=0)return new Rac.Composite(this.rac,[]);const angleDistance=this.angleDistance();var parsPerTurn=1/(angleDistance.turnOne()/count);const tangent=this.radius*(4/3)*Math.tan(Rac.TAU/(4*parsPerTurn)),beziers=[],segments=this.divideToSegments(count);return segments.forEach(newBezier=>{const startArcRadius=this.center.segmentToPoint(newBezier.startPoint()),endArcRadius=this.center.segmentToPoint(newBezier.endPoint());var startAnchor=startArcRadius.nextSegmentToAngleDistance(this.rac.Angle.square,!this.clockwise,tangent).endPoint(),newBezier=endArcRadius.nextSegmentToAngleDistance(this.rac.Angle.square,this.clockwise,tangent).endPoint(),newBezier=new Rac.Bezier(this.rac,startArcRadius.endPoint(),startAnchor,newBezier,endArcRadius.endPoint());beziers.push(newBezier)}),new Rac.Composite(this.rac,beziers)}text(string,format=null){return null===format&&(format=this.clockwise?this.rac.Text.Format.bottomLeft:this.rac.Text.Format.topLeft),this.startTangentRay().text(string,format)}}},{"../Rac":2,"../util/utils":43}],11:[function(require,module,exports){"use strict";const Rac=require("../Rac"),utils=require("../util/utils");class Bezier{constructor(rac,start,startAnchor,endAnchor,end){utils.assertExists(rac,start,startAnchor,endAnchor,end),utils.assertType(Rac.Point,start,startAnchor,endAnchor,end),this.rac=rac,this.start=start,this.startAnchor=startAnchor,this.endAnchor=endAnchor,this.end=end}toString(digits=null){return`Bezier(s:(${utils.cutDigits(this.start.x,digits)},${utils.cutDigits(this.start.y,digits)}) sa:(${utils.cutDigits(this.startAnchor.x,digits)},${utils.cutDigits(this.startAnchor.y,digits)}) ea:(${utils.cutDigits(this.endAnchor.x,digits)},${utils.cutDigits(this.endAnchor.y,digits)}) e:(${utils.cutDigits(this.end.x,digits)},${utils.cutDigits(this.end.y,digits)}))`}equals(otherBezier){return otherBezier instanceof Bezier&&this.start.equals(otherBezier.start)&&this.startAnchor.equals(otherBezier.startAnchor)&&this.endAnchor.equals(otherBezier.endAnchor)&&this.end.equals(otherBezier.end)}}(module.exports=Bezier).prototype.drawAnchors=function(style=void 0){push(),void 0!==style&&style.apply(),this.start.segmentToPoint(this.startAnchor).draw(),this.end.segmentToPoint(this.endAnchor).draw(),pop()},Bezier.prototype.reverse=function(){return new Bezier(this.rac,this.end,this.endAnchor,this.startAnchor,this.start)}},{"../Rac":2,"../util/utils":43}],12:[function(require,module,exports){"use strict";require("../Rac");const utils=require("../util/utils");class Composite{constructor(rac,sequence=[]){utils.assertExists(rac,sequence),this.rac=rac,this.sequence=sequence}}(module.exports=Composite).prototype.isNotEmpty=function(){return 0!=this.sequence.length},Composite.prototype.add=function(element){element instanceof Array?element.forEach(item=>this.sequence.push(item)):this.sequence.push(element)},Composite.prototype.reverse=function(){var reversed=this.sequence.map(item=>item.reverse()).reverse();return new Composite(this.rac,reversed)}},{"../Rac":2,"../util/utils":43}],13:[function(require,module,exports){"use strict";const Rac=require("../Rac"),utils=require("../util/utils");module.exports=class Point{constructor(rac,x,y){utils.assertExists(rac,x,y),utils.assertNumber(x,y),this.rac=rac,this.x=x,this.y=y}toString(digits=null){return`Point(${utils.cutDigits(this.x,digits)},${utils.cutDigits(this.y,digits)})`}equals(otherPoint){return otherPoint instanceof Point&&this.rac.equals(this.x,otherPoint.x)&&this.rac.equals(this.y,otherPoint.y)}withX(newX){return new Point(this.rac,newX,this.y)}withY(newY){return new Point(this.rac,this.x,newY)}addX(x){return new Point(this.rac,this.x+x,this.y)}addY(y){return new Point(this.rac,this.x,this.y+y)}addPoint(point){return new Point(this.rac,this.x+point.x,this.y+point.y)}add(x,y){return new Point(this.rac,this.x+x,this.y+y)}subtractPoint(point){return new Point(this.rac,this.x-point.x,this.y-point.y)}subtract(x,y){return new Point(this.rac,this.x-x,this.y-y)}negative(){return new Point(this.rac,-this.x,-this.y)}distanceToPoint(y){if(this.equals(y))return 0;var x=Math.pow(y.x-this.x,2),y=Math.pow(y.y-this.y,2);return Math.sqrt(x+y)}angleToPoint(radians,defaultAngle=this.rac.Angle.zero){return this.equals(radians)?defaultAngle=this.rac.Angle.from(defaultAngle):(radians=radians.subtractPoint(this),radians=Math.atan2(radians.y,radians.x),Rac.Angle.fromRadians(this.rac,radians))}pointToAngle(distanceY,distance){distanceY=this.rac.Angle.from(distanceY);var distanceX=distance*Math.cos(distanceY.radians()),distanceY=distance*Math.sin(distanceY.radians());return new Point(this.rac,this.x+distanceX,this.y+distanceY)}pointAtBisector(yOffset){var xOffset=(yOffset.x-this.x)/2,yOffset=(yOffset.y-this.y)/2;return new Point(this.rac,this.x+xOffset,this.y+yOffset)}ray(angle){return angle=this.rac.Angle.from(angle),new Rac.Ray(this.rac,this,angle)}rayToPoint(point,defaultAngle=this.rac.Angle.zero){return defaultAngle=this.angleToPoint(point,defaultAngle),new Rac.Ray(this.rac,this,defaultAngle)}rayToProjectionInRay(perpendicular){var projected=perpendicular.pointProjection(this),perpendicular=perpendicular.angle.perpendicular();return this.rayToPoint(projected,perpendicular)}rayTangentToArc(perpendicular,shiftedOpsAngle=!0){let hypotenuse=this.segmentToPoint(perpendicular.center,perpendicular.start.inverse());var opsAngle=perpendicular.radius;return this.rac.equals(hypotenuse.length,perpendicular.radius)?(perpendicular=hypotenuse.ray.angle.perpendicular(shiftedOpsAngle),new Rac.Ray(this.rac,this,perpendicular)):this.rac.equals(hypotenuse.length,0)||1<(opsAngle/=hypotenuse.length)?null:(opsAngle=Math.asin(opsAngle),opsAngle=Rac.Angle.fromRadians(this.rac,opsAngle),shiftedOpsAngle=hypotenuse.angle().shift(opsAngle,shiftedOpsAngle),new Rac.Ray(this.rac,this,shiftedOpsAngle))}segmentToAngle(ray,length){return ray=this.rac.Angle.from(ray),ray=new Rac.Ray(this.rac,this,ray),new Rac.Segment(this.rac,ray,length)}segmentToPoint(length,ray=this.rac.Angle.zero){return ray=this.angleToPoint(length,ray),length=this.distanceToPoint(length),ray=new Rac.Ray(this.rac,this,ray),new Rac.Segment(this.rac,ray,length)}segmentToProjectionInRay(perpendicular){var projected=perpendicular.pointProjection(this),perpendicular=perpendicular.angle.perpendicular();return this.segmentToPoint(projected,perpendicular)}segmentTangentToArc(arc,radiusRay=!0){const tangentRay=this.rayTangentToArc(arc,radiusRay);return null===tangentRay?null:(radiusRay=tangentRay.angle.perpendicular(radiusRay),radiusRay=arc.center.ray(radiusRay),tangentRay.segmentToIntersection(radiusRay))}arc(radius,start=this.rac.Angle.zero,end=null,clockwise=!0){return start=this.rac.Angle.from(start),end=null===end?start:this.rac.Angle.from(end),new Rac.Arc(this.rac,this,radius,start,end,clockwise)}text(string,format=this.rac.Text.Format.topLeft){return new Rac.Text(this.rac,this,string,format)}}},{"../Rac":2,"../util/utils":43}],14:[function(require,module,exports){"use strict";const Rac=require("../Rac"),utils=require("../util/utils");module.exports=class Ray{constructor(rac,start,angle){utils.assertExists(rac,start,angle),utils.assertType(Rac.Point,start),utils.assertType(Rac.Angle,angle),this.rac=rac,this.start=start,this.angle=angle}toString(digits=null){return`Ray((${utils.cutDigits(this.start.x,digits)},${utils.cutDigits(this.start.y,digits)}) a:${utils.cutDigits(this.angle.turn,digits)})`}equals(otherRay){return otherRay instanceof Ray&&this.start.equals(otherRay.start)&&this.angle.equals(otherRay.angle)}slope(){return this.rac.unitaryEquals(this.angle.turn,this.rac.Angle.down.turn)||this.rac.unitaryEquals(this.angle.turn,this.rac.Angle.up.turn)?null:Math.tan(this.angle.radians())}yIntercept(){var slope=this.slope();return null===slope?null:this.start.y-slope*this.start.x}withStart(newStart){return new Ray(this.rac,newStart,this.angle)}withX(newX){return new Ray(this.rac,this.start.withX(newX),this.angle)}withY(newY){return new Ray(this.rac,this.start.withY(newY),this.angle)}withAngle(newAngle){return newAngle=this.rac.Angle.from(newAngle),new Ray(this.rac,this.start,newAngle)}withAngleAdd(newAngle){return newAngle=this.angle.add(newAngle),new Ray(this.rac,this.start,newAngle)}withAngleShift(angle,newAngle=!0){return newAngle=this.angle.shift(angle,newAngle),new Ray(this.rac,this.start,newAngle)}inverse(){var inverseAngle=this.angle.inverse();return new Ray(this.rac,this.start,inverseAngle)}perpendicular(perpendicular=!0){return perpendicular=this.angle.perpendicular(perpendicular),new Ray(this.rac,this.start,perpendicular)}translateToDistance(newStart){return newStart=this.start.pointToAngle(this.angle,newStart),new Ray(this.rac,newStart,this.angle)}translateToAngle(angle,newStart){return newStart=this.start.pointToAngle(angle,newStart),new Ray(this.rac,newStart,this.angle)}translatePerpendicular(distance,perpendicular=!0){return perpendicular=this.angle.perpendicular(perpendicular),this.translateToAngle(perpendicular,distance)}angleToPoint(point){return this.start.angleToPoint(point,this.angle)}pointAtX(x){var y=this.slope();return null===y?null:this.rac.unitaryEquals(y,0)?this.start.withX(x):(y=y*x+this.yIntercept(),new Rac.Point(this.rac,x,y))}pointAtY(y){var x=this.slope();return null===x?this.start.withY(y):this.rac.unitaryEquals(x,0)?null:(x=(y-this.yIntercept())/x,new Rac.Point(this.rac,x,y))}pointAtDistance(distance){return this.start.pointToAngle(this.angle,distance)}pointAtIntersection(otherRay){var a=this.slope(),x=otherRay.slope();if(null===a&&null===x)return null;if(this.rac.unitaryEquals(a,x))return null;if(null===a)return otherRay.pointAtX(this.start.x);if(null===x)return this.pointAtX(otherRay.start.x);var y=this.yIntercept(),x=(otherRay.yIntercept()-y)/(a-x),y=a*x+y;return new Rac.Point(this.rac,x,y)}pointProjection(point){var perpendicular=this.angle.perpendicular();return point.ray(perpendicular).pointAtIntersection(this)}distanceToProjectedPoint(distance){var angleDiff=this.pointProjection(distance),distance=this.start.distanceToPoint(angleDiff);return this.rac.equals(distance,0)?0:(angleDiff=this.start.angleToPoint(angleDiff),(angleDiff=this.angle.subtract(angleDiff)).turn<=.25||.75<angleDiff.turn?distance:-distance)}pointOrientation(point){const pointAngle=this.start.angleToPoint(point,this.angle);return!!this.angle.equals(pointAngle)||pointAngle.subtract(this.angle).turn<.5}rayToPoint(newAngle){return newAngle=this.start.angleToPoint(newAngle,this.angle),new Ray(this.rac,this.start,newAngle)}segment(length){return new Rac.Segment(this.rac,this,length)}segmentToPoint(point){return this.start.segmentToPoint(point,this.angle)}segmentToIntersection(intersection){return null===(intersection=this.pointAtIntersection(intersection))?null:this.segmentToPoint(intersection)}arc(radius,endAngle=null,clockwise=!0){return endAngle=null===endAngle?this.angle:this.rac.Angle.from(endAngle),new Rac.Arc(this.rac,this.start,radius,this.angle,endAngle,clockwise)}arcToAngleDistance(radius,endAngle,clockwise=!0){return endAngle=this.angle.shift(endAngle,clockwise),new Rac.Arc(this.rac,this.start,radius,this.angle,endAngle,clockwise)}bezierArc(otherRay){if(this.start.equals(otherRay.start))return new Rac.Bezier(this.rac,this.start,this.start,this.start,this.start);let intersection=this.perpendicular().pointAtIntersection(otherRay.perpendicular()),orientation=null,radiusA=null,radiusB=null;if(null!==intersection)orientation=this.pointOrientation(intersection),radiusA=intersection.segmentToPoint(this.start),radiusB=intersection.segmentToPoint(otherRay.start);else{var anchorA=this.perpendicular().pointAtIntersection(otherRay);if(null===anchorA||this.start.equals(anchorA))return new Rac.Bezier(this.rac,this.start,this.start,otherRay.start,otherRay.start);intersection=this.start.pointAtBisector(anchorA),orientation=this.pointOrientation(intersection),radiusA=intersection.segmentToPoint(this.start),radiusB=radiusA.inverse()}const angleDistance=radiusA.angle().distance(radiusB.angle(),orientation),quarterAngle=angleDistance.mult(.25);var anchorB=quarterAngle.tan(),anchorA=anchorB*radiusA.length*4/3,anchorA=this.pointAtDistance(anchorA),anchorB=anchorB*radiusB.length*4/3,anchorB=otherRay.pointAtDistance(anchorB);return new Rac.Bezier(this.rac,this.start,anchorA,anchorB,otherRay.start)}text(string,format=this.rac.Text.Format.topLeft){return format=format.withAngle(this.angle),new Rac.Text(this.rac,this.start,string,format)}}},{"../Rac":2,"../util/utils":43}],15:[function(require,module,exports){"use strict";const Rac=require("../Rac"),utils=require("../util/utils");module.exports=class Segment{constructor(rac,ray,length){utils.assertExists(rac,ray,length),utils.assertType(Rac.Ray,ray),utils.assertNumber(length),this.rac=rac,this.ray=ray,this.length=length}toString(digits=null){return`Segment((${utils.cutDigits(this.ray.start.x,digits)},${utils.cutDigits(this.ray.start.y,digits)}) a:${utils.cutDigits(this.ray.angle.turn,digits)} l:${utils.cutDigits(this.length,digits)})`}equals(otherSegment){return otherSegment instanceof Segment&&this.ray.equals(otherSegment.ray)&&this.rac.equals(this.length,otherSegment.length)}angle(){return this.ray.angle}startPoint(){return this.ray.start}endPoint(){return this.ray.pointAtDistance(this.length)}withAngle(newRay){return newRay=Rac.Angle.from(this.rac,newRay),newRay=new Rac.Ray(this.rac,this.ray.start,newRay),new Segment(this.rac,newRay,this.length)}withRay(newRay){return new Segment(this.rac,newRay,this.length)}withStartPoint(newRay){return newRay=this.ray.withStart(newRay),new Segment(this.rac,newRay,this.length)}withLength(newLength){return new Segment(this.rac,this.ray,newLength)}withLengthAdd(increment){return new Segment(this.rac,this.ray,this.length+increment)}withLengthRatio(ratio){return new Segment(this.rac,this.ray,this.length*ratio)}withAngleAdd(newRay){return newRay=this.ray.withAngleAdd(newRay),new Segment(this.rac,newRay,this.length)}withAngleShift(angle,newRay=!0){return newRay=this.ray.withAngleShift(angle,newRay),new Segment(this.rac,newRay,this.length)}withStartExtension(distance){var newRay=this.ray.translateToDistance(-distance);return new Segment(this.rac,newRay,this.length+distance)}withEndExtension(distance){return this.withLengthAdd(distance)}inverse(){var newRay=this.ray.inverse();return new Segment(this.rac,newRay,this.length)}perpendicular(newRay=!0){return newRay=this.ray.perpendicular(newRay),new Segment(this.rac,newRay,this.length)}reverse(){var inverseRay=this.endPoint(),inverseRay=new Rac.Ray(this.rac,inverseRay,this.ray.angle.inverse());return new Segment(this.rac,inverseRay,this.length)}translateToAngle(angle,newRay){return newRay=this.ray.translateToAngle(angle,newRay),new Segment(this.rac,newRay,this.length)}translateToLength(newRay){return newRay=this.ray.translateToDistance(newRay),new Segment(this.rac,newRay,this.length)}translateToLengthRatio(newRay){return newRay=this.ray.translateToDistance(this.length*newRay),new Segment(this.rac,newRay,this.length)}translatePerpendicular(distance,newRay=!0){return newRay=this.ray.translatePerpendicular(distance,newRay),new Segment(this.rac,newRay,this.length)}clampToLength(clamped,startInset=0,endInset=0){var endLimit=this.length-endInset;if(endLimit<=startInset){let clamped=startInset-(startInset-endLimit)/2;return clamped=Math.min(clamped,this.length),clamped=Math.max(clamped,0),clamped}return clamped=Math.min(clamped,this.length-endInset),clamped=Math.max(clamped,startInset)}pointAtLength(distance){return this.ray.pointAtDistance(distance)}pointAtLengthRatio(ratio){return this.ray.pointAtDistance(this.length*ratio)}pointAtBisector(){return this.ray.pointAtDistance(this.length/2)}moveStartPoint(newStartPoint){var endPoint=this.endPoint();return newStartPoint.segmentToPoint(endPoint,this.ray.angle)}moveEndPoint(newEndPoint){return this.ray.segmentToPoint(newEndPoint)}segmentToBisector(){return new Segment(this.rac,this.ray,this.length/2)}segmentBisector(newLength=null,newRay=!0){var newStart=this.pointAtBisector(),newRay=this.ray.angle.perpendicular(newRay),newRay=new Rac.Ray(this.rac,newStart,newRay);return newLength=null===newLength?this.length:newLength,new Segment(this.rac,newRay,newLength)}nextSegmentWithLength(newLength){var newRay=this.endPoint(),newRay=this.ray.withStart(newRay);return new Segment(this.rac,newRay,newLength)}nextSegmentToPoint(nextEndPoint){const newStart=this.endPoint();return newStart.segmentToPoint(nextEndPoint,this.ray.angle)}nextSegmentToAngle(newRay,newLength=null){newRay=Rac.Angle.from(this.rac,newRay),newLength=null===newLength?this.length:newLength;var newStart=this.endPoint(),newRay=new Rac.Ray(this.rac,newStart,newRay);return new Segment(this.rac,newRay,newLength)}nextSegmentToAngleDistance(angleDistance,newRay=!0,newLength=null){return angleDistance=this.rac.Angle.from(angleDistance),newLength=null===newLength?this.length:newLength,newRay=this.ray.translateToDistance(this.length).inverse().withAngleShift(angleDistance,newRay),new Segment(this.rac,newRay,newLength)}nextSegmentPerpendicular(newRay=!0,newLength=null){return newLength=null===newLength?this.length:newLength,newRay=this.ray.translateToDistance(this.length).perpendicular(!newRay),new Segment(this.rac,newRay,newLength)}nextSegmentLegWithHyp(ops,clockwise=!0){return ops<this.length?null:(ops=Math.acos(this.length/ops),ops=Math.tan(ops)*this.length,this.nextSegmentPerpendicular(clockwise,ops))}arc(endAngle=null,clockwise=!0){return endAngle=null===endAngle?this.ray.angle:Rac.Angle.from(this.rac,endAngle),new Rac.Arc(this.rac,this.ray.start,this.length,this.ray.angle,endAngle,clockwise)}arcWithAngleDistance(endAngle,clockwise=!0){endAngle=this.rac.Angle.from(endAngle);const stargAngle=this.ray.angle;return endAngle=stargAngle.shift(endAngle,clockwise),new Rac.Arc(this.rac,this.ray.start,this.length,stargAngle,endAngle,clockwise)}text(string,format=this.rac.Text.Format.topLeft){return format=format.withAngle(this.ray.angle),new Rac.Text(this.rac,this.ray.start,string,format)}}},{"../Rac":2,"../util/utils":43}],16:[function(require,module,exports){"use strict";const Rac=require("../Rac"),utils=require("../util/utils");function Shape(rac){utils.assertExists(rac),this.rac=rac,this.outline=new Rac.Composite(rac),this.contour=new Rac.Composite(rac)}(module.exports=Shape).prototype.addOutline=function(element){this.outline.add(element)},Shape.prototype.addContour=function(element){this.contour.add(element)}},{"../Rac":2,"../util/utils":43}],17:[function(require,module,exports){"use strict";const Rac=require("../Rac"),utils=require("../util/utils");module.exports=class TextFormat{static horizontalAlign={left:"left",center:"horizontalCenter",right:"right"};static verticalAlign={top:"top",center:"verticalCenter",baseline:"baseline",bottom:"bottom"};constructor(rac,hAlign,vAlign,angle=rac.Angle.zero,font=null,size=null,hPadding=0,vPadding=0){utils.assertType(Rac,rac),utils.assertString(hAlign,vAlign),utils.assertType(Rac.Angle,angle),null!==font&&utils.assertString(font),null!==size&&utils.assertNumber(size),utils.assertNumber(hPadding,vPadding),this.rac=rac,this.hAlign=hAlign,this.vAlign=vAlign,this.angle=angle,this.font=font,this.size=size,this.hPadding=hPadding,this.vPadding=vPadding}toString(vPaddingStr=null){var angleStr=utils.cutDigits(this.angle.turn,vPaddingStr),sizeStr=null===this.size?"null":utils.cutDigits(this.size,vPaddingStr),fontStr=null===this.font?"null":`"${this.font}"`,hPaddingStr=utils.cutDigits(this.hPadding,vPaddingStr),vPaddingStr=utils.cutDigits(this.vPadding,vPaddingStr);return`Text.Format(ha:${this.hAlign} va:${this.vAlign} a:${angleStr} f:${fontStr} s:${sizeStr} p:(${`${hPaddingStr},${vPaddingStr}`}))`}equals(otherFormat){return otherFormat instanceof TextFormat&&this.hAlign===otherFormat.hAlign&&this.vAlign===otherFormat.vAlign&&this.font===otherFormat.font&&this.size===otherFormat.size&&this.hPadding===otherFormat.hPadding&&this.vPadding===otherFormat.vPadding&&this.angle.equals(otherFormat.angle)}withAngle(newAngle){return newAngle=Rac.Angle.from(this.rac,newAngle),new TextFormat(this.rac,this.hAlign,this.vAlign,newAngle,this.font,this.size,this.hPadding,this.vPadding)}withFont(newFont){return new TextFormat(this.rac,this.hAlign,this.vAlign,this.angle,newFont,this.size,this.hPadding,this.vPadding)}withSize(newSize){return new TextFormat(this.rac,this.hAlign,this.vAlign,this.angle,this.font,newSize,this.hPadding,this.vPadding)}withPaddings(hPadding,vPadding=null){return null===vPadding&&(vPadding=hPadding),new TextFormat(this.rac,this.hAlign,this.vAlign,this.angle,this.font,this.size,hPadding,vPadding)}reverse(){var hEnum=TextFormat.horizontalAlign,vEnum=TextFormat.verticalAlign;let hAlign,vAlign;switch(this.hAlign){case hEnum.left:hAlign=hEnum.right;break;case hEnum.right:hAlign=hEnum.left;break;default:hAlign=this.hAlign}switch(this.vAlign){case vEnum.top:vAlign=vEnum.bottom;break;case vEnum.bottom:vAlign=vEnum.top;break;default:vAlign=this.vAlign}return new TextFormat(this.rac,hAlign,vAlign,this.angle.inverse(),this.font,this.size,this.hPadding,this.vPadding)}}},{"../Rac":2,"../util/utils":43}],18:[function(TextFormat,module,exports){"use strict";const Rac=TextFormat("../Rac"),utils=TextFormat("../util/utils");TextFormat=TextFormat("./Text.Format");module.exports=class Text{static Format=TextFormat;constructor(rac,point,string,format){utils.assertType(Rac,rac),utils.assertType(Rac.Point,point),utils.assertString(string),utils.assertType(Text.Format,format),this.rac=rac,this.point=point,this.string=string,this.format=format}toString(digits=null){return`Text((${utils.cutDigits(this.point.x,digits)},${utils.cutDigits(this.point.y,digits)}) "${this.string}")`}equals(otherText){return otherText instanceof Text&&this.string===otherText.string&&this.point.equals(otherText.point)}withAngle(newFormat){return newFormat=this.format.withAngle(newFormat),new Text(this.rac,this.point,this.string,newFormat)}withFont(newFormat){return newFormat=this.format.withFont(newFormat),new Text(this.rac,this.point,this.string,newFormat)}withSize(newFormat){return newFormat=this.format.withSize(newFormat),new Text(this.rac,this.point,this.string,newFormat)}withPaddings(hPadding,newFormat=null){return newFormat=this.format.withPaddings(hPadding,newFormat),new Text(this.rac,this.point,this.string,newFormat)}reverse(){var reverseFormat=this.format.reverse();return new Text(this.rac,this.point,this.string,reverseFormat)}upright(){return utils.isUprightText(this.format.angle.turn)?this:this.reverse()}}},{"../Rac":2,"../util/utils":43,"./Text.Format":17}],19:[function(require,module,exports){"use strict";const Rac=require("../Rac");module.exports=function(rac){rac.Angle.from=function(something){return Rac.Angle.from(rac,something)},rac.Angle.fromRadians=function(radians){return Rac.Angle.fromRadians(rac,radians)},rac.Angle.fromDegrees=function(degrees){return Rac.Angle.fromDegrees(rac,degrees)},rac.Angle.zero=rac.Angle(0),rac.Angle.half=rac.Angle(.5),rac.Angle.inverse=rac.Angle.half,rac.Angle.quarter=rac.Angle(.25),rac.Angle.square=rac.Angle.quarter,rac.Angle.eighth=rac.Angle(1/8),rac.Angle.neighth=rac.Angle(-1/8),rac.Angle.sixteenth=rac.Angle(1/16),rac.Angle.tenth=rac.Angle(.1),rac.Angle.north=rac.Angle(.75),rac.Angle.east=rac.Angle(0),rac.Angle.south=rac.Angle(.25),rac.Angle.west=rac.Angle(.5),rac.Angle.e=rac.Angle.east,rac.Angle.s=rac.Angle.south,rac.Angle.w=rac.Angle.west,rac.Angle.n=rac.Angle.north,rac.Angle.ne=rac.Angle.n.add(1/8),rac.Angle.se=rac.Angle.e.add(1/8),rac.Angle.sw=rac.Angle.s.add(1/8),rac.Angle.nw=rac.Angle.w.add(1/8),rac.Angle.nne=rac.Angle.ne.add(-1/16),rac.Angle.ene=rac.Angle.ne.add(1/16),rac.Angle.nen=rac.Angle.nne,rac.Angle.nee=rac.Angle.ene,rac.Angle.ese=rac.Angle.se.add(-1/16),rac.Angle.sse=rac.Angle.se.add(1/16),rac.Angle.see=rac.Angle.ese,rac.Angle.ses=rac.Angle.sse,rac.Angle.ssw=rac.Angle.sw.add(-1/16),rac.Angle.wsw=rac.Angle.sw.add(1/16),rac.Angle.sws=rac.Angle.ssw,rac.Angle.sww=rac.Angle.wsw,rac.Angle.wnw=rac.Angle.nw.add(-1/16),rac.Angle.nnw=rac.Angle.nw.add(1/16),rac.Angle.nww=rac.Angle.wnw,rac.Angle.nwn=rac.Angle.nnw,rac.Angle.right=rac.Angle.e,rac.Angle.down=rac.Angle.s,rac.Angle.left=rac.Angle.w,rac.Angle.up=rac.Angle.n,rac.Angle.r=rac.Angle.right,rac.Angle.d=rac.Angle.down,rac.Angle.l=rac.Angle.left,rac.Angle.u=rac.Angle.up,rac.Angle.top=rac.Angle.up,rac.Angle.bottom=rac.Angle.down,rac.Angle.t=rac.Angle.top,rac.Angle.b=rac.Angle.bottom,rac.Angle.topRight=rac.Angle.ne,rac.Angle.tr=rac.Angle.ne,rac.Angle.topLeft=rac.Angle.nw,rac.Angle.tl=rac.Angle.nw,rac.Angle.bottomRight=rac.Angle.se,rac.Angle.br=rac.Angle.se,rac.Angle.bottomLeft=rac.Angle.sw,rac.Angle.bl=rac.Angle.sw}},{"../Rac":2}],20:[function(require,module,exports){"use strict";module.exports=function(rac){rac.Arc.zero=rac.Arc(0,0,0,0,0,!0)}},{}],21:[function(require,module,exports){"use strict";module.exports=function(rac){rac.Bezier.zero=rac.Bezier(0,0,0,0,0,0,0,0)}},{}],22:[function(require,module,exports){"use strict";module.exports=function(rac){rac.Point.zero=rac.Point(0,0),rac.Point.origin=rac.Point.zero}},{}],23:[function(require,module,exports){"use strict";module.exports=function(rac){rac.Ray.zero=rac.Ray(0,0,rac.Angle.zero),rac.Ray.xAxis=rac.Ray.zero,rac.Ray.yAxis=rac.Ray(0,0,rac.Angle.quarter)}},{}],24:[function(require,module,exports){"use strict";module.exports=function(rac){rac.Segment.zero=rac.Segment(0,0,0,0)}},{}],25:[function(require,module,exports){"use strict";const Rac=require("../Rac");module.exports=function(rac){rac.Text.Format.topLeft=rac.Text.Format(Rac.Text.Format.horizontalAlign.left,Rac.Text.Format.verticalAlign.top),rac.Text.Format.tl=rac.Text.Format.topLeft,rac.Text.Format.topCenter=rac.Text.Format(Rac.Text.Format.horizontalAlign.center,Rac.Text.Format.verticalAlign.top),rac.Text.Format.tc=rac.Text.Format.topCenter,rac.Text.Format.topRight=rac.Text.Format(Rac.Text.Format.horizontalAlign.right,Rac.Text.Format.verticalAlign.top),rac.Text.Format.tr=rac.Text.Format.topRight,rac.Text.Format.centerLeft=rac.Text.Format(Rac.Text.Format.horizontalAlign.left,Rac.Text.Format.verticalAlign.center),rac.Text.Format.cl=rac.Text.Format.centerLeft,rac.Text.Format.centerCenter=rac.Text.Format(Rac.Text.Format.horizontalAlign.center,Rac.Text.Format.verticalAlign.center),rac.Text.Format.centered=rac.Text.Format.centerCenter,rac.Text.Format.cc=rac.Text.Format.centerCenter,rac.Text.Format.centerRight=rac.Text.Format(Rac.Text.Format.horizontalAlign.right,Rac.Text.Format.verticalAlign.center),rac.Text.Format.cr=rac.Text.Format.centerRight,rac.Text.Format.bottomLeft=rac.Text.Format(Rac.Text.Format.horizontalAlign.left,Rac.Text.Format.verticalAlign.bottom),rac.Text.Format.bl=rac.Text.Format.bottomLeft,rac.Text.Format.bottomCenter=rac.Text.Format(Rac.Text.Format.horizontalAlign.center,Rac.Text.Format.verticalAlign.bottom),rac.Text.Format.bc=rac.Text.Format.bottomCenter,rac.Text.Format.bottomRight=rac.Text.Format(Rac.Text.Format.horizontalAlign.right,Rac.Text.Format.verticalAlign.bottom),rac.Text.Format.br=rac.Text.Format.bottomRight,rac.Text.Format.baselineLeft=rac.Text.Format(Rac.Text.Format.horizontalAlign.left,Rac.Text.Format.verticalAlign.baseline),rac.Text.Format.bll=rac.Text.Format.baselineLeft,rac.Text.Format.baselineCenter=rac.Text.Format(Rac.Text.Format.horizontalAlign.center,Rac.Text.Format.verticalAlign.baseline),rac.Text.Format.blc=rac.Text.Format.baselineCenter,rac.Text.Format.baselineRight=rac.Text.Format(Rac.Text.Format.horizontalAlign.right,Rac.Text.Format.verticalAlign.baseline),rac.Text.Format.blr=rac.Text.Format.baselineRight}},{"../Rac":2}],26:[function(require,module,exports){"use strict";require("../Rac");module.exports=function(rac){rac.Text.hello=rac.Text(0,0,"hello world!"),rac.Text.sphinx=rac.Text(0,0,"sphinx of black quartz, judge my vow")}},{"../Rac":2}],27:[function(require,module,exports){var root,factory;root="undefined"!=typeof self?self:this,factory=function(){return require("./Rac")},"function"==typeof define&&define.amd?define([],factory):"object"==typeof module&&module.exports?module.exports=factory():root.Rac=factory()},{"./Rac":2}],28:[function(require,module,exports){"use strict";const Rac=require("../Rac"),utils=require("../util/utils");module.exports=class{constructor(rac,p5){this.rac=rac,this.p5=p5,this.drawRoutines=[],this.debugRoutines=[],this.applyRoutines=[],this.debugStyle=null,this.debugTextStyle=null,this.debugTextOptions={font:"monospace",size:rac.textFormatDefaults.size,fixedDigits:2},this.debugPointRadius=5,this.debugMarkerRadius=22,this.strokeWeightFactor=1,this.setupAllDrawFunctions(),this.setupAllDebugFunctions(),this.setupAllApplyFunctions()}setDrawFunction(drawableClass,drawFunction){var index=this.drawRoutines.findIndex(routine=>routine.classObj===drawableClass);let routine;-1===index?routine=new DrawRoutine(drawableClass,drawFunction):(routine=this.drawRoutines[index],routine.drawFunction=drawFunction,this.drawRoutines.splice(index,1)),this.drawRoutines.push(routine)}setDrawOptions(classObj,options){let routine=this.drawRoutines.find(routine=>routine.classObj===classObj);if(void 0===routine)throw console.log(`Cannot find routine for class - className:${classObj.name}`),Rac.Error.invalidObjectConfiguration;void 0!==options.requiresPushPop&&(routine.requiresPushPop=options.requiresPushPop)}setClassDrawStyle(classObj,style){let routine=this.drawRoutines.find(routine=>routine.classObj===classObj);if(void 0===routine)throw console.log(`Cannot find routine for class - className:${classObj.name}`),Rac.Error.invalidObjectConfiguration;routine.style=style}setDebugFunction(drawableClass,debugFunction){var index=this.debugRoutines.findIndex(routine=>routine.classObj===drawableClass);let routine;-1===index?routine=new DebugRoutine(drawableClass,debugFunction):(routine=this.debugRoutines[index],routine.debugFunction=debugFunction,this.debugRoutines.splice(index,1)),this.debugRoutines.push(routine)}setApplyFunction(classObj,applyFunction){var index=this.applyRoutines.findIndex(routine=>routine.classObj===classObj);let routine;-1===index?routine=new ApplyRoutine(classObj,applyFunction):(routine=this.applyRoutines[index],routine.drawFunction=drawFunction,this.applyRoutines.splice(index,1)),this.applyRoutines.push(routine)}drawObject(object,style=null){let routine=this.drawRoutines.find(routine=>object instanceof routine.classObj);if(void 0===routine)throw console.trace(`Cannot draw object - object-type:${utils.typeName(object)}`),Rac.Error.invalidObjectToDraw;!0===routine.requiresPushPop||null!==style||null!==routine.style?(this.p5.push(),null!==routine.style&&routine.style.apply(),null!==style&&style.apply(),routine.drawFunction(this,object),this.p5.pop()):routine.drawFunction(this,object)}debugObject(object,drawsText){let routine=this.debugRoutines.find(routine=>object instanceof routine.classObj);void 0!==routine?null!==this.debugStyle?(this.p5.push(),this.debugStyle.apply(),routine.debugFunction(this,object,drawsText),this.p5.pop()):routine.debugFunction(this,object,drawsText):this.drawObject(object,this.debugStyle)}applyObject(object){let routine=this.applyRoutines.find(routine=>object instanceof routine.classObj);if(void 0===routine)throw console.trace(`Cannot apply object - object-type:${utils.typeName(object)}`),Rac.Error.invalidObjectToApply;routine.applyFunction(this,object)}setupAllDrawFunctions(){var functions=require("./draw.functions");this.setDrawFunction(Rac.Point,functions.drawPoint),require("./Point.functions")(this.rac),this.setDrawFunction(Rac.Ray,functions.drawRay),require("./Ray.functions")(this.rac),this.setDrawFunction(Rac.Segment,functions.drawSegment),require("./Segment.functions")(this.rac),this.setDrawFunction(Rac.Arc,functions.drawArc),Rac.Arc.prototype.vertex=function(){let angleDistance=this.angleDistance();var divisions=Math.ceil(5*angleDistance.turnOne());this.divideToBeziers(divisions).vertex()},this.setDrawFunction(Rac.Text,functions.drawText),this.setDrawOptions(Rac.Text,{requiresPushPop:!0}),this.setDrawFunction(Rac.Bezier,(drawer,bezier)=>{drawer.p5.bezier(bezier.start.x,bezier.start.y,bezier.startAnchor.x,bezier.startAnchor.y,bezier.endAnchor.x,bezier.endAnchor.y,bezier.end.x,bezier.end.y)}),Rac.Bezier.prototype.vertex=function(){this.start.vertex(),this.rac.drawer.p5.bezierVertex(this.startAnchor.x,this.startAnchor.y,this.endAnchor.x,this.endAnchor.y,this.end.x,this.end.y)},this.setDrawFunction(Rac.Composite,(drawer,composite)=>{composite.sequence.forEach(item=>item.draw())}),Rac.Composite.prototype.vertex=function(){this.sequence.forEach(item=>item.vertex())},this.setDrawFunction(Rac.Shape,(drawer,shape)=>{drawer.p5.beginShape(),shape.outline.vertex(),shape.contour.isNotEmpty()&&(drawer.p5.beginContour(),shape.contour.vertex(),drawer.p5.endContour()),drawer.p5.endShape()}),Rac.Shape.prototype.vertex=function(){this.outline.vertex(),this.contour.vertex()}}setupAllDebugFunctions(){let functions=require("./debug.functions");this.setDebugFunction(Rac.Point,functions.debugPoint),this.setDebugFunction(Rac.Ray,functions.debugRay),this.setDebugFunction(Rac.Segment,functions.debugSegment),this.setDebugFunction(Rac.Arc,functions.debugArc),this.setDebugFunction(Rac.Text,functions.debugText),Rac.Angle.prototype.debug=function(point,drawsText=!1){const drawer=this.rac.drawer;return null!==drawer.debugStyle?(drawer.p5.push(),drawer.debugStyle.apply(),functions.debugAngle(drawer,this,point,drawsText),drawer.p5.pop()):functions.debugAngle(drawer,this,point,drawsText),this},Rac.Point.prototype.debugAngle=function(angle,drawsText=!1){return(angle=this.rac.Angle.from(angle)).debug(this,drawsText),this}}setupAllApplyFunctions(){Rac.Color.prototype.applyBackground=function(){this.rac.drawer.p5.background(255*this.r,255*this.g,255*this.b)},Rac.Color.prototype.applyFill=function(){this.rac.drawer.p5.fill(255*this.r,255*this.g,255*this.b,255*this.a)},Rac.Color.prototype.applyStroke=function(){this.rac.drawer.p5.stroke(255*this.r,255*this.g,255*this.b,255*this.a)},this.setApplyFunction(Rac.Stroke,(drawer,stroke)=>{null!==stroke.weight||null!==stroke.color?(null!==stroke.color&&stroke.color.applyStroke(),null!==stroke.weight&&drawer.p5.strokeWeight(stroke.weight*drawer.strokeWeightFactor)):drawer.p5.noStroke()}),this.setApplyFunction(Rac.Fill,(drawer,fill)=>{null!==fill.color?fill.color.applyFill():drawer.p5.noFill()}),this.setApplyFunction(Rac.StyleContainer,(drawer,container)=>{container.styles.forEach(item=>{item.apply()})}),Rac.Text.Format.prototype.apply=function(point){let hAlign;var hEnum=Rac.Text.Format.horizontalAlign;switch(this.hAlign){case hEnum.left:hAlign=this.rac.drawer.p5.LEFT;break;case hEnum.center:hAlign=this.rac.drawer.p5.CENTER;break;case hEnum.right:hAlign=this.rac.drawer.p5.RIGHT;break;default:throw console.trace(`Invalid hAlign configuration - hAlign:${this.hAlign}`),Rac.Error.invalidObjectConfiguration}let vAlign;var vEnum=Rac.Text.Format.verticalAlign;switch(this.vAlign){case vEnum.top:vAlign=this.rac.drawer.p5.TOP;break;case vEnum.bottom:vAlign=this.rac.drawer.p5.BOTTOM;break;case vEnum.center:vAlign=this.rac.drawer.p5.CENTER;break;case vEnum.baseline:vAlign=this.rac.drawer.p5.BASELINE;break;default:throw console.trace(`Invalid vAlign configuration - vAlign:${this.vAlign}`),Rac.Error.invalidObjectConfiguration}this.rac.drawer.p5.textAlign(hAlign,vAlign);var textFont=this.size??this.rac.textFormatDefaults.size;this.rac.drawer.p5.textSize(textFont);textFont=this.font??this.rac.textFormatDefaults.font;null!==textFont&&this.rac.drawer.p5.textFont(textFont),this.rac.drawer.p5.translate(point.x,point.y),0!==this.angle.turn&&this.rac.drawer.p5.rotate(this.angle.radians());let xPad=0,yPad=0;switch(this.hAlign){case hEnum.left:case hEnum.center:xPad+=this.hPadding;break;case hEnum.right:xPad-=this.hPadding}switch(this.vAlign){case vEnum.top:case vEnum.center:case vEnum.baseline:yPad+=this.vPadding;break;case vEnum.bottom:yPad-=this.vPadding}0===xPad&&0===yPad||this.rac.drawer.p5.translate(xPad,yPad)}}};class DrawRoutine{constructor(classObj,drawFunction){this.classObj=classObj,this.drawFunction=drawFunction,this.style=null,this.requiresPushPop=!1}}class DebugRoutine{constructor(classObj,debugFunction){this.classObj=classObj,this.debugFunction=debugFunction}}class ApplyRoutine{constructor(classObj,applyFunction){this.classObj=classObj,this.applyFunction=applyFunction}}},{"../Rac":2,"../util/utils":43,"./Point.functions":29,"./Ray.functions":30,"./Segment.functions":31,"./debug.functions":32,"./draw.functions":33}],29:[function(require,module,exports){"use strict";const Rac=require("../Rac");require("../util/utils");module.exports=function(rac){Rac.Point.prototype.vertex=function(){this.rac.drawer.p5.vertex(this.x,this.y)},rac.Point.pointer=function(){return rac.Point(rac.drawer.p5.mouseX,rac.drawer.p5.mouseY)},rac.Point.canvasCenter=function(){return rac.Point(rac.drawer.p5.width/2,rac.drawer.p5.height/2)},rac.Point.canvasEnd=function(){return rac.Point(rac.drawer.p5.width,rac.drawer.p5.height)}}},{"../Rac":2,"../util/utils":43}],30:[function(require,module,exports){"use strict";const Rac=require("../Rac");require("../util/utils");module.exports=function(rac){Rac.Ray.prototype.pointAtCanvasEdge=function(edgeRay=0){edgeRay=this.rayAtCanvasEdge(edgeRay);return null==edgeRay?null:edgeRay.start},Rac.Ray.prototype.rayAtCanvasEdge=function(rightEdge=0){var turn=this.angle.turn,p5=this.rac.drawer.p5,downEdge=p5.height-rightEdge,leftEdge=rightEdge,upEdge=rightEdge,rightEdge=p5.width-rightEdge;if(1/8<=turn&&turn<3/8){let edgeRay=null;return this.start.y<downEdge&&(edgeRay=this.pointAtY(downEdge).ray(this.rac.Angle.up),edgeRay.start.x>rightEdge?edgeRay=this.pointAtX(rightEdge).ray(this.rac.Angle.left):edgeRay.start.x<leftEdge&&(edgeRay=this.pointAtX(leftEdge).ray(this.rac.Angle.right))),edgeRay}if(3/8<=turn&&turn<5/8){let edgeRay=null;return this.start.x>=leftEdge&&(edgeRay=this.pointAtX(leftEdge).ray(this.rac.Angle.right),edgeRay.start.y>downEdge?edgeRay=this.pointAtY(downEdge).ray(this.rac.Angle.up):edgeRay.start.y<upEdge&&(edgeRay=this.pointAtY(upEdge).ray(this.rac.Angle.down))),edgeRay}if(5/8<=turn&&turn<7/8){let edgeRay=null;return this.start.y>=upEdge&&(edgeRay=this.pointAtY(upEdge).ray(this.rac.Angle.down),edgeRay.start.x>rightEdge?edgeRay=this.pointAtX(rightEdge).ray(this.rac.Angle.left):edgeRay.start.x<leftEdge&&(edgeRay=this.pointAtX(leftEdge).ray(this.rac.Angle.right))),edgeRay}let edgeRay=null;return this.start.x<rightEdge&&(edgeRay=this.pointAtX(rightEdge).ray(this.rac.Angle.left),edgeRay.start.y>downEdge?edgeRay=this.pointAtY(downEdge).ray(this.rac.Angle.up):edgeRay.start.y<upEdge&&(edgeRay=this.pointAtY(upEdge).ray(this.rac.Angle.down))),edgeRay}}},{"../Rac":2,"../util/utils":43}],31:[function(require,module,exports){"use strict";const Rac=require("../Rac");require("../util/utils");module.exports=function(rac){Rac.Segment.prototype.vertex=function(){this.startPoint().vertex(),this.endPoint().vertex()},rac.Segment.canvasTop=function(){return rac.Point.zero.segmentToAngle(rac.Angle.right,rac.drawer.p5.width)},rac.Segment.canvasLeft=function(){return rac.Point.zero.segmentToAngle(rac.Angle.down,rac.drawer.p5.height)},rac.Segment.canvasRight=function(){const topRight=rac.Point(rac.drawer.p5.width,0);return topRight.segmentToAngle(rac.Angle.down,rac.drawer.p5.height)},rac.Segment.canvasBottom=function(){let bottomLeft=rac.Point(0,rac.drawer.p5.height);return bottomLeft.segmentToAngle(rac.Angle.right,rac.drawer.p5.width)}}},{"../Rac":2,"../util/utils":43}],32:[function(require,module,exports){"use strict";const Rac=require("../Rac");function dashedDraw(drawer,segment,closure){const context=drawer.p5.drawingContext;context.save(),context.lineCap="butt",context.setLineDash(segment),closure(),context.restore()}function drawRayTexts(drawer,ray,topString,bottomString){var hEnum=Rac.Text.Format.horizontalAlign,vEnum=Rac.Text.Format.verticalAlign,font=drawer.debugTextOptions.font,size=drawer.debugTextOptions.size,bottomFormat=drawer.debugPointRadius,topFormat=new Rac.Text.Format(drawer.rac,hEnum.left,vEnum.bottom,ray.angle,font,size,bottomFormat,bottomFormat),bottomFormat=new Rac.Text.Format(drawer.rac,hEnum.left,vEnum.top,ray.angle,font,size,bottomFormat,bottomFormat);ray.text(topString,topFormat).upright().draw(drawer.debugTextStyle),ray.text(bottomString,bottomFormat).upright().draw(drawer.debugTextStyle)}exports.debugAngle=function(drawer,angle,point,drawsText){var rac=drawer.rac,pointRadius=drawer.debugPointRadius,format=drawer.debugMarkerRadius,turnString=drawer.debugTextOptions.fixedDigits;point.segmentToAngle(rac.Angle.zero,format).draw();let angleSegment=point.segmentToAngle(angle,1.5*format);angleSegment.endPoint().arc(pointRadius,angle,angle.inverse(),!1).draw(),angleSegment.withLengthAdd(pointRadius).draw();let angleArc=point.arc(format,rac.Angle.zero,angle);if(dashedDraw(drawer,[6,4],()=>{angleArc.draw()}),!angleArc.isCircle()){let outsideAngleArc=angleArc.withRadius(3*format/4).withClockwise(!1);dashedDraw(drawer,[2,4],()=>{outsideAngleArc.draw()})}!0===drawsText&&(format=new Rac.Text.Format(rac,Rac.Text.Format.horizontalAlign.left,Rac.Text.Format.verticalAlign.center,angle,drawer.debugTextOptions.font,drawer.debugTextOptions.size,2*format,0),turnString=`turn:${angle.turn.toFixed(turnString)}`,point.text(turnString,format).upright().draw(drawer.debugTextStyle))},exports.debugPoint=function(drawer,point,drawsText){var rac=drawer.rac,format=drawer.debugPointRadius,markerRadius=drawer.debugMarkerRadius,string=drawer.debugTextOptions.fixedDigits;point.draw(),point.arc(format).draw();let arc=point.arc(markerRadius,rac.Angle.s,rac.Angle.e).draw();arc.startSegment().reverse().withLengthRatio(.5).draw(),arc.endSegment().reverse().withLengthRatio(.5).draw(),!0===drawsText&&(format=new Rac.Text.Format(rac,Rac.Text.Format.horizontalAlign.left,Rac.Text.Format.verticalAlign.top,rac.Angle.e,drawer.debugTextOptions.font,drawer.debugTextOptions.size,format,format),string=`x:${point.x.toFixed(string)}\ny:${point.y.toFixed(string)}`,point.text(string,format).draw(drawer.debugTextStyle))},exports.debugRay=function(drawer,ray,startString){drawer.rac;var angleString=drawer.debugPointRadius,markerRadius=drawer.debugMarkerRadius;ray.draw(),ray.start.arc(angleString).draw();const perpAngle=ray.angle.perpendicular(),startArc=ray.start.arc(markerRadius,perpAngle,perpAngle.inverse()).draw();startArc.startSegment().reverse().withLengthRatio(.5).draw(),startArc.endSegment().reverse().withLengthRatio(.5).draw();const edgeRay=ray.rayAtCanvasEdge();if(null!=edgeRay){const edgeArc=edgeRay.translateToDistance(angleString).perpendicular(!1).arcToAngleDistance(markerRadius/2,.5).draw();edgeArc.startSegment().reverse().withLength(angleString).draw(),edgeArc.endSegment().reverse().withLength(angleString).draw(),edgeArc.radiusSegmentAtAngle(edgeRay.angle).reverse().withLength(angleString).draw()}!0===startString&&(angleString=drawer.debugTextOptions.fixedDigits,startString=`start:(${ray.start.x.toFixed(angleString)},${ray.start.y.toFixed(angleString)})`,angleString=`angle:${ray.angle.turn.toFixed(angleString)}`,drawRayTexts(drawer,ray,startString,angleString))},exports.debugSegment=function(drawer,segment,lengthString){const rac=drawer.rac;var angleString=drawer.debugPointRadius,markerRadius=drawer.debugMarkerRadius;segment.draw(),segment.withLength(angleString).arc().draw();let perpAngle=segment.angle().perpendicular(),arc=segment.startPoint().arc(markerRadius,perpAngle,perpAngle.inverse()).draw();arc.startSegment().reverse().withLengthRatio(.5).draw(),arc.endSegment().reverse().withLengthRatio(.5).draw();let endMarkerStart=segment.nextSegmentPerpendicular().withLength(markerRadius/2).withStartExtension(-angleString).draw(),endMarkerEnd=segment.nextSegmentPerpendicular(!1).withLength(markerRadius/2).withStartExtension(-angleString).draw();segment.endPoint().arc(angleString,endMarkerStart.angle(),endMarkerEnd.angle()).draw();angleString=rac.Angle.from(1/7);let endArrowStart=endMarkerStart.reverse().ray.withAngleShift(angleString,!1);angleString=endMarkerEnd.reverse().ray.withAngleShift(angleString,!0),angleString=endArrowStart.pointAtIntersection(angleString);endMarkerStart.nextSegmentToPoint(angleString).draw().nextSegmentToPoint(endMarkerEnd.endPoint()).draw(),!0===lengthString&&(angleString=drawer.debugTextOptions.fixedDigits,lengthString=`length:${segment.length.toFixed(angleString)}`,angleString=`angle:${segment.ray.angle.turn.toFixed(angleString)}`,drawRayTexts(drawer,segment.ray,lengthString,angleString))},exports.debugArc=function(drawer,arc,tailFormat){var rac=drawer.rac,bothStrings=drawer.debugPointRadius,radiusString=drawer.debugMarkerRadius;arc.draw();let centerArcRadius=2*radiusString/3;arc.radius>radiusString/3&&arc.radius<radiusString&&(centerArcRadius=arc.radius+radiusString/3);let centerArc=arc.withRadius(centerArcRadius);centerArc.startSegment().draw();var startString=arc.radius-centerArcRadius-radiusString/2-2*bothStrings;if(0<startString&&arc.startSegment().withLength(startString).translateToLength(centerArcRadius+2*bothStrings).draw(),dashedDraw(drawer,[6,4],()=>{centerArc.draw()}),!centerArc.isCircle()){let outsideAngleArc=centerArc.withClockwise(!centerArc.clockwise);dashedDraw(drawer,[2,4],()=>{outsideAngleArc.draw()})}arc.isCircle()||centerArc.endSegment().reverse().withLengthRatio(.5).draw();let startPoint=arc.startPoint();startPoint.arc(bothStrings).draw(),startPoint.segmentToAngle(arc.start,radiusString).withStartExtension(-radiusString/2).draw();var digits=2*radiusString;let orientationArc=arc.startSegment().withLengthAdd(radiusString).arc(null,arc.clockwise).withLength(digits).draw(),arrowCenter=orientationArc.reverse().withLength(radiusString/2).chordSegment();arrowCenter.withAngleShift(-3/32).draw(),arrowCenter.withAngleShift(3/32).draw();let endPoint=arc.endPoint();var headFormat=Math.min(radiusString/2,arc.radius);(headFormat-=bothStrings)>rac.equalityThreshold&&endPoint.segmentToAngle(arc.end.inverse(),headFormat).translateToLength(bothStrings).draw();var textJoinThreshold=3*radiusString,lengthAtOrientationArc=orientationArc.withEnd(arc.end).length();if(endPoint.segmentToAngle(arc.end,textJoinThreshold<lengthAtOrientationArc&&!0===tailFormat?radiusString-bothStrings:radiusString/2-bothStrings).translateToLength(bothStrings).draw(),arc.isCircle()||endPoint.arc(bothStrings,arc.end,arc.end.inverse(),arc.clockwise).draw(),!0===tailFormat){var hEnum=Rac.Text.Format.horizontalAlign,radiusVertical=Rac.Text.Format.verticalAlign,radiusFormat=drawer.debugTextOptions.font,startString=drawer.debugTextOptions.size,digits=drawer.debugTextOptions.fixedDigits,headFormat=arc.clockwise?radiusVertical.top:radiusVertical.bottom,tailFormat=arc.clockwise?radiusVertical.bottom:radiusVertical.top,radiusVertical=arc.clockwise?radiusVertical.bottom:radiusVertical.top,headFormat=new Rac.Text.Format(rac,hEnum.left,headFormat,arc.start,radiusFormat,startString,bothStrings,0),tailFormat=new Rac.Text.Format(rac,hEnum.left,tailFormat,arc.end,radiusFormat,startString,bothStrings,0),radiusFormat=new Rac.Text.Format(rac,hEnum.left,radiusVertical,arc.start,radiusFormat,startString,radiusString,bothStrings),startString=`start:${arc.start.turn.toFixed(digits)}`,radiusString=`radius:${arc.radius.toFixed(digits)}`,bothStrings=`end:${arc.end.turn.toFixed(digits)}`;let angleDistance=arc.angleDistance();bothStrings=`${`distance:${angleDistance.turn.toFixed(digits)}`}\n${bothStrings}`;let headString;(angleDistance.turn<=.75||angleDistance.equals(.75))&&!arc.isCircle()?(headString=startString,arc.center.text(radiusString,radiusFormat).upright().draw(drawer.debugTextStyle)):headString=`${startString}\n${radiusString}`,textJoinThreshold<lengthAtOrientationArc?(orientationArc.startPoint().text(headString,headFormat).upright().draw(drawer.debugTextStyle),orientationArc.pointAtAngle(arc.end).text(bothStrings,tailFormat).upright().draw(drawer.debugTextStyle)):(bothStrings=`${headString}\n${bothStrings}`,orientationArc.startPoint().text(bothStrings,headFormat).upright().draw(drawer.debugTextStyle))}},exports.debugText=function(drawer,text,debugString){const rac=drawer.rac,pointRadius=drawer.debugPointRadius,markerRadius=drawer.debugMarkerRadius,digits=drawer.debugTextOptions.fixedDigits;var debugFormat=Rac.Text.Format.horizontalAlign,vEnum=Rac.Text.Format.verticalAlign;const format=text.format;text.point.arc(pointRadius).draw();function cornerReticule(angle,padding,perpPadding,rotation){rac.Point.zero.segmentToAngle(angle,markerRadius).reverse().withLength(markerRadius-2*pointRadius).draw().nextSegmentPerpendicular(rotation,padding).push().nextSegmentPerpendicular(!rotation,perpPadding).draw().nextSegmentWithLength(4*pointRadius).nextSegmentWithLength(markerRadius-2*pointRadius).draw(),dashedDraw(drawer,[5,2],()=>{rac.popStack().draw()})}function centerReticule(angle,padding,perpPadding,rotation){angle=rac.Angle.from(angle),rac.Point.zero.ray(angle.perpendicular(rotation)).translateToDistance(2*pointRadius).segment(markerRadius-2*pointRadius).draw();let reticuleCenter=rac.Point.zero.segmentToAngle(angle.inverse(),padding).push().nextSegmentPerpendicular(rotation,pointRadius).reverse().draw().nextSegmentPerpendicular(rotation,pointRadius).reverse().draw().nextSegmentPerpendicular(rotation,perpPadding).push().endPoint();dashedDraw(drawer,[5,2],()=>{rac.popStack().draw(),rac.popStack().draw()}),reticuleCenter.ray(angle.inverse()).translateToDistance(2*pointRadius).segment(markerRadius-2*pointRadius).draw(),reticuleCenter.ray(angle.perpendicular(!rotation)).translateToDistance(2*pointRadius).segment(markerRadius-2*pointRadius).draw();let lastCenterLine=reticuleCenter.ray(angle).translateToDistance(2*pointRadius).segment(markerRadius-2*pointRadius).draw();Math.abs(perpPadding)<=2||(lastCenterLine.nextSegmentWithLength(padding-markerRadius).push().nextSegmentPerpendicular(!rotation,format.hPadding).push(),dashedDraw(drawer,[2,3],()=>{rac.popStack().draw(),rac.popStack().draw()}))}switch(drawer.p5.push(),format.apply(text.point),format.hAlign){case debugFormat.left:switch(format.vAlign){case vEnum.top:cornerReticule(0,format.vPadding,format.hPadding,!1),cornerReticule(.25,format.hPadding,format.vPadding,!0);break;case vEnum.center:case vEnum.baseline:centerReticule(0,format.hPadding,format.vPadding,!0);break;case vEnum.bottom:cornerReticule(0,format.vPadding,format.hPadding,!0),cornerReticule(.75,format.hPadding,format.vPadding,!1)}break;case debugFormat.center:switch(format.vAlign){case vEnum.top:case vEnum.center:case vEnum.baseline:centerReticule(.25,format.vPadding,format.hPadding,!1);break;case vEnum.bottom:centerReticule(.75,format.vPadding,format.hPadding,!0)}break;case debugFormat.right:switch(format.vAlign){case vEnum.top:cornerReticule(.5,format.vPadding,format.hPadding,!0),cornerReticule(.25,format.hPadding,format.vPadding,!1);break;case vEnum.center:case vEnum.baseline:centerReticule(.5,format.hPadding,format.vPadding,!1);break;case vEnum.bottom:cornerReticule(.5,format.vPadding,format.hPadding,!1),cornerReticule(.75,format.hPadding,format.vPadding,!0)}}drawer.p5.pop(),text.draw(drawer.debugTextStyle),!0===debugString&&(debugString=`${`p:(${(debugString=function(number){return number.toFixed(digits)})(text.point.x)},${debugString(text.point.y)}) a:${debugString(format.angle.turn)}`}\n${`al:${format.hAlign},${format.vAlign}`}\n${`pa:${debugString(format.hPadding)},${debugString(format.vPadding)}`}`,debugFormat=new Rac.Text.Format(rac,debugFormat.right,vEnum.bottom,rac.Angle.zero,drawer.debugTextOptions.font,drawer.debugTextOptions.size,pointRadius,pointRadius),text.point.text(`${debugString}`,debugFormat).draw(drawer.debugTextStyle))}},{"../Rac":2}],33:[function(require,module,exports){"use strict";const Rac=require("../Rac");exports.drawPoint=function(drawer,point){drawer.p5.point(point.x,point.y)},exports.drawRay=function(drawer,ray){var edgePoint=ray.pointAtCanvasEdge();null!==edgePoint&&drawer.p5.line(ray.start.x,ray.start.y,edgePoint.x,edgePoint.y)},exports.drawSegment=function(drawer,end){var start=end.ray.start,end=end.endPoint();drawer.p5.line(start.x,start.y,end.x,end.y)},exports.drawArc=function(drawer,arc){if(arc.isCircle()){var startRad=arc.start.radians(),endRad=startRad+Rac.TAU;drawer.p5.arc(arc.center.x,arc.center.y,2*arc.radius,2*arc.radius,startRad,endRad)}else{let start=arc.start,end=arc.end;arc.clockwise||(start=arc.end,end=arc.start),drawer.p5.arc(arc.center.x,arc.center.y,2*arc.radius,2*arc.radius,start.radians(),end.radians())}},exports.drawText=function(drawer,text){text.format.apply(text.point),drawer.p5.text(text.string,0,0)}},{"../Rac":2}],34:[function(require,module,exports){"use strict";const Rac=require("../Rac"),utils=require("../util/utils");module.exports=class Color{constructor(rac,r,g,b,a=1){utils.assertExists(rac,r,g,b,a),utils.assertNumber(r,g,b,a),this.rac=rac,this.r=r,this.g=g,this.b=b,this.a=a}toString(digits=null){return`Color(${utils.cutDigits(this.r,digits)},${utils.cutDigits(this.g,digits)},${utils.cutDigits(this.b,digits)},${utils.cutDigits(this.a,digits)})`}equals(otherColor){return otherColor instanceof Color&&this.rac.unitaryEquals(this.r,otherColor.r)&&this.rac.unitaryEquals(this.g,otherColor.g)&&this.rac.unitaryEquals(this.b,otherColor.b)&&this.rac.unitaryEquals(this.a,otherColor.a)}static fromRgba(rac,r,g,b,a=255){return new Color(rac,r/255,g/255,b/255,a/255)}static fromHex(rac,hexString){if("#"==hexString.charAt(0)&&(hexString=hexString.substring(1)),![6,8].includes(hexString.length))throw Rac.Exception.failedAssert(`Unexpected length for hex triplet string: ${hexString}`);var newG=hexString.substring(0,2),newB=hexString.substring(2,4),newA=hexString.substring(4,6);let aStr="ff";8==hexString.length&&(aStr=hexString.substring(6,8));var newR=parseInt(newG,16),newG=parseInt(newB,16),newB=parseInt(newA,16),newA=parseInt(aStr,16);if(isNaN(newR)||isNaN(newG)||isNaN(newB)||isNaN(newA))throw Rac.Exception.failedAssert(`Could not parse hex triplet string: ${hexString}`);return new Color(rac,newR/255,newG/255,newB/255,newA/255)}fill(){return new Rac.Fill(this.rac,this)}stroke(weight=null){return new Rac.Stroke(this.rac,weight,this)}withAlpha(newAlpha){return new Color(this.rac,this.r,this.g,this.b,newAlpha)}withAlphaRatio(ratio){return new Color(this.rac,this.r,this.g,this.b,this.a*ratio)}linearTransition(newA,target){newA=Math.max(newA,0),newA=Math.min(newA,1);var newR=this.r+(target.r-this.r)*newA,newG=this.g+(target.g-this.g)*newA,newB=this.b+(target.b-this.b)*newA,newA=this.a+(target.a-this.a)*newA;return new Color(this.rac,newR,newG,newB,newA)}}},{"../Rac":2,"../util/utils":43}],35:[function(require,module,exports){"use strict";const Rac=require("../Rac"),utils=require("../util/utils");module.exports=class Fill{constructor(rac,color){utils.assertExists(rac),null!==color&&utils.assertType(Rac.Color,color),this.rac=rac,this.color=color}static from(rac,something){if(something instanceof Fill)return something;if(something instanceof Rac.Color)return new Fill(rac,something);if(something instanceof Rac.Stroke)return new Fill(rac,something.color);throw Rac.Exception.invalidObjectType(`Cannot derive Rac.Fill - something-type:${utils.typeName(something)}`)}container(){return new Rac.StyleContainer(this.rac,[this])}appendStyle(style){return null===style?this:new Rac.StyleContainer(this.rac,[this,style])}appendStroke(stroke){return stroke=Rac.Stroke.from(this.rac,stroke),new Rac.StyleContainer(this.rac,[this,stroke])}}},{"../Rac":2,"../util/utils":43}],36:[function(require,module,exports){"use strict";const Rac=require("../Rac"),utils=require("../util/utils");module.exports=class Stroke{constructor(rac,weight,color=null){utils.assertExists(rac),null!==weight&&utils.assertNumber(weight),null!==color&&utils.assertType(Rac.Color,color),this.rac=rac,this.color=color,this.weight=weight}static from(rac,something){if(something instanceof Stroke)return something;if(something instanceof Rac.Color)return new Stroke(rac,null,something);if(something instanceof Rac.Fill)return new Stroke(rac,null,something.color);throw Rac.Exception.invalidObjectType(`Cannot derive Rac.Stroke - something-type:${utils.typeName(something)}`)}withWeight(newWeight){return new Stroke(this.rac,newWeight,this.color)}withAlpha(newColor){return null===this.color?new Stroke(this.rac,this.weight,null):(newColor=this.color.withAlpha(newColor),new Stroke(this.rac,this.weight,newColor))}container(){return new Rac.StyleContainer(this.rac,[this])}appendStyle(style){return null===style?this:new Rac.StyleContainer(this.rac,[this,style])}appendFill(fill){return fill=Rac.Fill.from(this.rac,fill),new Rac.StyleContainer(this.rac,[this,fill])}}},{"../Rac":2,"../util/utils":43}],37:[function(require,module,exports){"use strict";const Rac=require("../Rac"),utils=require("../util/utils");module.exports=class{constructor(rac,styles=[]){utils.assertExists(rac),this.rac=rac,this.styles=styles}toString(){return`StyleContainer(${this.styles.join(" ")})`}container(){return new Rac.StyleContainer(this.rac,this.styles.slice())}appendStyle(style){if(null===style)return this;let stylesCopy=this.styles.slice();return stylesCopy.push(style),new Rac.StyleContainer(this.rac,stylesCopy)}}},{"../Rac":2,"../util/utils":43}],38:[function(require,module,exports){"use strict";const Rac=require("../Rac");module.exports=function(rac){rac.Color.fromRgba=function(r,g,b,a=255){return Rac.Color.fromRgba(rac,r,g,b,a)},rac.Color.fromHex=function(hexString){return Rac.Color.fromHex(rac,hexString)},rac.Color.zero=rac.Color(0,0,0,0),rac.Color.black=rac.Color(0,0,0),rac.Color.white=rac.Color(1,1,1),rac.Color.one=rac.Color.white,rac.Color.red=rac.Color(1,0,0),rac.Color.green=rac.Color(0,1,0),rac.Color.blue=rac.Color(0,0,1),rac.Color.yellow=rac.Color(1,1,0),rac.Color.magenta=rac.Color(1,0,1),rac.Color.cyan=rac.Color(0,1,1)}},{"../Rac":2}],39:[function(require,module,exports){"use strict";module.exports=function(rac){rac.Fill.none=rac.Fill(null)}},{}],40:[function(require,module,exports){"use strict";module.exports=function(rac){rac.Stroke.none=rac.Stroke(null),rac.Stroke.one=rac.Stroke(1)}},{}],41:[function(require,module,exports){"use strict";require("../Rac"),require("../util/utils");module.exports=class EaseFunction{static Behavior={pass:"pass",clamp:"clamp",continue:"continue"};constructor(){this.a=2,this.ratioOffset=0,this.ratioFactor=1,this.easeOffset=0,this.easeFactor=1,this.prefix=0,this.inRange=1,this.outRange=1,this.preBehavior=EaseFunction.Behavior.pass,this.postBehavior=EaseFunction.Behavior.pass,this.preFactor=1,this.postFactor=1}easeUnit(unit){var ra=Math.pow(unit,this.a);return ra/(ra+Math.pow(1-unit,this.a))}easeRatio(adjustedRatio){return adjustedRatio=(adjustedRatio+this.ratioOffset)*this.ratioFactor,(this.easeUnit(adjustedRatio)+this.easeOffset)*this.easeFactor}easeValue(value){var behavior=EaseFunction.Behavior,shiftedPost=value-this.prefix,ratio=shiftedPost/this.inRange;if(value<this.prefix){if(this.preBehavior===behavior.pass){var easedRatio=value-this.prefix;return this.prefix+easedRatio*this.preFactor}if(this.preBehavior===behavior.clamp)return this.prefix;if(this.preBehavior!==behavior.continue)throw console.trace(`Invalid preBehavior configuration - preBehavior:${this.postBehavior}`),rac.Error.invalidObjectConfiguration;var easedRatio=this.easeRatio(ratio);return this.prefix+easedRatio*this.outRange}if(ratio<=1||this.postBehavior===behavior.continue)return easedRatio=this.easeRatio(ratio),this.prefix+easedRatio*this.outRange;if(this.postBehavior===behavior.pass)return shiftedPost-=this.inRange,this.prefix+this.outRange+shiftedPost*this.postFactor;if(this.postBehavior===behavior.clamp)return this.prefix+this.outRange;throw console.trace(`Invalid postBehavior configuration - postBehavior:${this.postBehavior}`),rac.Error.invalidObjectConfiguration}static makeEaseOut(){let easeOut=new EaseFunction;return easeOut.ratioOffset=1,easeOut.ratioFactor=.5,easeOut.easeOffset=-.5,easeOut.easeFactor=2,easeOut}}},{"../Rac":2,"../util/utils":43}],42:[function(require,module,exports){"use strict";class Exception{constructor(name,message){this.name=name,this.message=message}toString(){return`Exception:${this.name} - ${this.message}`}static buildsErrors=!1;static named(name){var func=message=>{if(Exception.buildsErrors){const error=new Error(message);return error.name=name,error}return new Exception(name,message)};return func.exceptionName=name,func}static drawerNotSetup=Exception.named("DrawerNotSetup");static failedAssert=Exception.named("FailedAssert");static invalidObjectType=Exception.named("InvalidObjectType");static abstractFunctionCalled=Exception.named("AbstractFunctionCalled");static invalidObjectConfiguration=Exception.named("InvalidObjectConfiguration")}module.exports=Exception},{}],43:[function(require,module,exports){"use strict";const Rac=require("../Rac");function typeName(obj){return void 0===obj?"undefined":null===obj?"null":"function"==typeof obj&&null!=obj.name?""==obj.name?"function":`function:${obj.name}`:obj.constructor.name??typeof obj}exports.assertExists=function(...parameters){parameters.forEach((item,index)=>{if(null===item)throw Rac.Exception.failedAssert(`Found null, expecting element to exist at index ${index}`);if(void 0===item)throw Rac.Exception.failedAssert(`Found undefined, expecting element to exist at index ${index}`)})},exports.assertType=function(type,...elements){elements.forEach(item=>{if(!(item instanceof type))throw Rac.Exception.failedAssert(`Element is unexpected type - element-type:${typeName(item)} expected-type-name:${type.name} element:${item}`)})},exports.assertNumber=function(...elements){elements.forEach(item=>{if("number"!=typeof item||isNaN(item))throw Rac.Exception.failedAssert(`Element is unexpected type, expecting number primitive - element-type:${typeName(item)} element:${item}`)})},exports.assertString=function(...elements){elements.forEach(item=>{if("string"!=typeof item)throw Rac.Exception.failedAssert(`Element is unexpected type, expecting string primitive - element-type:${typeName(item)} element:${item}`)})},exports.assertBoolean=function(...elements){elements.forEach(item=>{if("boolean"!=typeof item)throw Rac.Exception.failedAssert(`Element is unexpected type, expecting boolean primitive - element-type:${typeName(item)} element:${item}`)})},exports.typeName=typeName,exports.addConstantTo=function(obj,propName,value){Object.defineProperty(obj,propName,{enumerable:!1,configurable:!1,writable:!1,value:value})},exports.cutDigits=function(number,digits=null){return null===digits?number.toString():number.toFixed(digits)},exports.isUprightText=function(angleTurn){return.75<=angleTurn||angleTurn<.25}},{"../Rac":2}]},{},[27]);