-
Notifications
You must be signed in to change notification settings - Fork 1
/
show.min.js
1 lines (1 loc) · 3.41 KB
/
show.min.js
1
const s=t=>{let e,s,i,h,_,l,n,o,a=new Array(4*numpoints),g=abs_s[abs_s.length-3]-abs_s[2],b=abs_t[abs_t.length-3]-abs_t[2];function r(t,e,s,i){let h=t-s,_=e-i;return h*h+_*_}t.setup=function(){t.createCanvas(coffh,coffh),e=.13*t.width,s=.13*t.height,i=.75*t.width,h=.75*t.height,n=(l=h/16)/2,o=(_=i/16)/2,t.noLoop()},t.draw=function(){t.background(240,240,240),t.strokeWeight(2);let n=0;for(let _=0;_<s_points_dy.length;++_){let l=t.height-(s+(abs_t[_+2]-abs_t[2])/b*h),o=l;for(let s=0;s<s_points_dy[_].length-1;++s)if(s_points_dy[_][s]){let h=e+(abs_s[s_tmesh[_+2][s+2]]-abs_s[2])/g*i,b=e+(abs_s[s_tmesh[_+2][s+3]]-abs_s[2])/g*i;t.line(h,l,b,o),a[n]=h,a[n+1]=l,a[n+2]=_,a[n+3]=10*s,n+=4}let r=s_points_dy[_].length-1;a[n]=e+(abs_s[s_tmesh[_+2][r+2]]-abs_s[2])/g*i,a[n+1]=l,a[n+2]=_,a[n+3]=10*r,n+=4}t.fill(100,225,100);for(let _=0;_<t_points_dy.length;++_){let l=e+(abs_s[_+2]-abs_s[2])/g*i,n=l;for(let e=0;e<t_points_dy[_].length-1;++e)if(t_points_dy[_][e]){let i=t.height-(s+(abs_t[t_tmesh[_+2][e+2]]-abs_t[2])/b*h),o=t.height-(s+(abs_t[t_tmesh[_+2][e+3]]-abs_t[2])/b*h);t.line(l,i,n,o),t.circle(l,i,16),t.circle(n,o,16)}}let o=e,r=o-_;for(let e=0;e<t_points_dy[0].length;++e){let i=t.height-(s+(abs_t[t_tmesh[2][e+2]]-abs_t[2])/b*h),_=i;t.line(o,i,r,_),t.circle(o,i,16)}let d=t_points_dy.length-1;r=(o=e+(abs_s[d+2]-abs_s[2])/g*i)+_;for(let e=0;e<t_points_dy[d].length;++e){let i=t.height-(s+(abs_t[t_tmesh[d+2][e+2]]-abs_t[2])/b*h),_=i;t.line(o,i,r,_),t.circle(o,i,16)}let c=t.height-s,f=c+l;for(let s=0;s<s_points_dy[0].length;++s){let h=e+(abs_s[s_tmesh[2][s+2]]-abs_s[2])/g*i,_=h;t.line(h,c,_,f),t.circle(h,c,16)}d=s_points_dy.length-1,f=(c=t.height-(s+(abs_t[d+2]-abs_t[2])/b*h))-l;for(let s=0;s<s_points_dy[d].length;++s){let h=e+(abs_s[s_tmesh[d+2][s+2]]-abs_s[2])/g*i,_=h;t.line(h,c,_,f),t.circle(h,c,16)}t.fill(0),t.textSize(.04*t.width),t.textAlign(t.CENTER,t.CENTER);let w=.05,k=.95,p=.015*t.width;t.stroke(0),t.line(t.width*w,t.height*k,t.width*w,t.height*w),t.noStroke(),t.triangle(t.width*w-p,t.height*w,t.width*w+p,t.height*w,t.width*w,t.height*w-2*p),t.text("t",.025*t.width,t.height/2),t.stroke(0),t.line(t.width*w,t.height*k,t.width*k,t.height*k),t.noStroke(),t.triangle(t.width*k,t.height*k-p,t.width*k,t.height*k+p,t.width*k+2*p,t.height*k),t.text("s",t.width/2,.975*t.height),t.textSize(.03*t.width),t.text("View knot vectors: move the mouse above the selected point",t.width/2,.025*t.height)};let d=!1;t.mouseMoved=function(){let _=!1;for(var l=0;l<a.length;l+=4)if(r(a[l],a[l+1],t.mouseX,t.mouseY)<=64){if(!d){t.strokeWeight(4),t.stroke(50,50,255);let _=e+(knot_vecs[a[l+2]][a[l+3]]-abs_s[2])/g*i;t.line(a[l],a[l+1],_,a[l+1]),t.line(_,a[l+1]-n,_,a[l+1]+n),_=e+(knot_vecs[a[l+2]][a[l+3]+1]-abs_s[2])/g*i,t.line(_,a[l+1]-n,_,a[l+1]+n),_=e+(knot_vecs[a[l+2]][a[l+3]+3]-abs_s[2])/g*i,t.line(_,a[l+1]-n,_,a[l+1]+n),_=e+(knot_vecs[a[l+2]][a[l+3]+4]-abs_s[2])/g*i,t.line(_,a[l+1]-n,_,a[l+1]+n),t.line(a[l],a[l+1],_,a[l+1]),t.stroke(206,42,42),_=t.height-(s+(knot_vecs[a[l+2]][a[l+3]+5]-abs_t[2])/b*h),t.line(a[l],a[l+1],a[l],_),t.line(a[l]-o,_,a[l]+o,_),_=t.height-(s+(knot_vecs[a[l+2]][a[l+3]+6]-abs_t[2])/b*h),t.line(a[l]-o,_,a[l]+o,_),_=t.height-(s+(knot_vecs[a[l+2]][a[l+3]+8]-abs_t[2])/b*h),t.line(a[l]-o,_,a[l]+o,_),_=t.height-(s+(knot_vecs[a[l+2]][a[l+3]+9]-abs_t[2])/b*h),t.line(a[l]-o,_,a[l]+o,_),t.line(a[l],a[l+1],a[l],_),t.fill(255,0,255),t.circle(a[l],a[l+1],16),d=!0}_=!0;break}d&&!_&&(t.strokeWeight(2),t.stroke(0),t.redraw(),d=!1)}};let myp5=new p5(s,"mesh");