This commit is contained in:
Loic Guegan 2021-10-05 20:12:35 +02:00
parent c7c4048a44
commit c353c87c51
3 changed files with 15 additions and 6 deletions

View file

@ -13,7 +13,7 @@ let projectile= function (p){
p.setup = function() { p.setup = function() {
c=p.createCanvas(Math.min(window.innerWidth,width), height); c=p.createCanvas(Math.min(window.innerWidth,width), height);
v0t=p.createElement('span', ''); v0t=p.createElement('span', '');
katex.render("v_0", v0t.elt); katex.render("v_0", v0t.elt);
@ -55,9 +55,9 @@ let projectile= function (p){
draw_arrow(p,x0,height-y0,x0+v0,height-(y0+v0),v0t,c,skiparrow) draw_arrow(p,x0,height-y0,x0+v0,height-(y0+v0),v0t,c,skiparrow)
p.stroke(121, 199, 107) p.stroke(121, 199, 107)
draw_arrow(p,50,50,50,0,vj,c,skiparrow,true) draw_arrow(p,x0,height-y0,x0,height-y0-50,vj,c,skiparrow,true)
p.stroke(199,119,107) p.stroke(199,119,107)
draw_arrow(p,50,50,100,50,vi,c,skiparrow) draw_arrow(p,x0,height-y0,x0+50,height-y0,vi,c,skiparrow)
p.pop() p.pop()
} }

View file

@ -40,8 +40,15 @@ draw_arrow=function(p,x1,y1,x2,y2,elt=null,canvas,skiparrow=false,flip=false){
yfactor=-yfactor yfactor=-yfactor
} }
cp=canvas.position() cp=canvas.position()
elt.position(cp.x+center.x+justify*xfactor-5,cp.y+center.y-justify*yfactor-elt.elt.offsetHeight/2) elt_x=cp.x+center.x+justify*xfactor-5
elt_y=cp.y+center.y-justify*yfactor-elt.elt.offsetHeight/2
if (elt_x<cp.x || elt_y < cp.y || elt_x>(canvas.width+cp.x) || elt_y>(canvas.height+cp.y)){
elt.elt.style.display="none"
} else {
elt.elt.style.display="block"
}
elt.position(elt_x,elt_y)
} }

View file

@ -47,7 +47,9 @@
<br /> <br />
<div class="row"> <div class="row">
<div class="col" style="padding:0px;"> <div class="col" style="padding:0px;">
<div id="canvas" style="margin-bottom:2em" align="center"></div> <center>
<div id="canvas" class="img-thumbnail" style="margin-bottom:2em;width:fit-content;height:fit-content;"></div>
</center>
</div> </div>
</div> </div>
<div class="row"> <div class="row">