File: /home/mmtprep/public_html/mathzen.mmtprep.com/assets/GraduatedLine-4V6s1FdM.js
import{E as u,r as n,d as c}from"./main-tV-pceYo.js";class b extends u{constructor(t,{addLeft:h=0,addRight:e=0,labelInterval:r,max:a=6,min:s=-6,step:i=1,stepBis:o,thick:l=.2,yLabel:d=-.5}={}){super(t,{}),this._labelSize="0.8em",this.addInPixels=5,this.labels=[],this.points=[],this.addLeft=h,this.addRight=e,this.labelInterval=r??i,this.min=s,this.max=a,this.step=i,this.stepBis=o,this.thick=l,this.yLabel=d}draw(){this.svgLine=document.createElementNS("http://www.w3.org/2000/svg","line"),this.groupSvg.appendChild(this.svgLine),this.setVisibilityColorThicknessAndDashed(),this.drawLine(),this.drawThicks(),this.drawThicksBis(),this.drawLabels()}drawLabels(){const t=n(Math.ceil(this.min/this.labelInterval)*this.labelInterval),h=n(Math.floor(this.max/this.labelInterval)*this.labelInterval);for(let e=t;e<=h;){const r=`$${c(e)}$`;this.labels.push(this.figure.create("TextByPosition",{anchor:"topCenter",dxInPixels:0,dyInPixels:0,isChild:!0,text:r,x:e,y:this.yLabel})),e=n(e+this.labelInterval)}}drawLine(){const t=this.figure.xToSx(this.min-this.addLeft),h=this.figure.xToSx(this.max+this.addRight),e=this.figure.yToSy(0),r=this.figure.yToSy(0);this.svgLine.setAttribute("x1",`${t-this.addInPixels}`),this.svgLine.setAttribute("y1",`${e}`),this.svgLine.setAttribute("x2",`${h+this.addInPixels}`),this.svgLine.setAttribute("y2",`${r}`);const a=document.createElementNS("http://www.w3.org/2000/svg","defs");this.figure.svg.appendChild(a);const s=document.createElementNS("http://www.w3.org/2000/svg","marker");s.setAttribute("id","arrow"),s.setAttribute("markerWidth","10"),s.setAttribute("markerHeight","10"),s.setAttribute("refX","0"),s.setAttribute("refY","3"),s.setAttribute("orient","auto"),s.setAttribute("markerUnits","strokeWidth");const i=document.createElementNS("http://www.w3.org/2000/svg","path");i.setAttribute("d","M0,0 L0,6 L9,3 z"),i.setAttribute("fill","currentColor"),s.appendChild(i),a.appendChild(s),this.svgLine.setAttribute("marker-end","url(#arrow)")}drawThicks(){const t=n(Math.ceil(this.min/this.step)*this.step),h=n(Math.floor(this.max/this.step)*this.step);for(let e=t;e<=h;){const r=this.figure.xToSx(e),a=this.figure.yToSy(-this.thick),s=this.figure.yToSy(this.thick),i=document.createElementNS("http://www.w3.org/2000/svg","line");i.setAttribute("x1",`${r}`),i.setAttribute("y1",`${a}`),i.setAttribute("x2",`${r}`),i.setAttribute("y2",`${s}`),i.setAttribute("stroke","currentColor"),i.setAttribute("stroke-width","1"),this.groupSvg.appendChild(i),e=n(e+this.step)}}drawThicksBis(){if(this.stepBis===void 0)return;const t=n(Math.ceil(this.min/this.stepBis)*this.stepBis),h=n(Math.floor(this.max/this.stepBis)*this.stepBis);let e=0;for(let r=t;r<=h&&e<1e3;){const a=this.figure.xToSx(r),s=this.figure.yToSy(-this.thick/2),i=this.figure.yToSy(this.thick/2),o=document.createElementNS("http://www.w3.org/2000/svg","line");o.setAttribute("x1",`${a}`),o.setAttribute("y1",`${s}`),o.setAttribute("x2",`${a}`),o.setAttribute("y2",`${i}`),o.setAttribute("stroke","black"),o.setAttribute("stroke-width","1"),this.groupSvg.appendChild(o),r=n(r+this.stepBis),e++}}get labelSize(){return this._labelSize}set labelSize(t){this._labelSize=t;for(const h of this.labels)h.fontSize=t}get latex(){let t=`
\\tkzInit[xmin=${this.min}, xmax=${this.max}, xstep=${this.step}]`;return t+=`
\\tkzDrawX[label={}, tickup=3pt, tickdn=3pt]`,this.stepBis!==void 0&&(t+=`\\foreach \\i in {${this.min},${n(this.min+this.stepBis,6)},...,${this.max}} {`,t+=`
\\tkzHTick[mark=|,mark size=2pt]{\\i}
}`),t}}export{b as G};
//# sourceMappingURL=GraduatedLine-4V6s1FdM.js.map