Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #37944

Re: My flaky math

Newsgroups comp.lang.javascript
Date 2019-12-07 11:24 -0800
References <5753bf40-6ff1-4609-802c-5036f9a93d64@googlegroups.com>
Message-ID <e50d4107-e331-4b9e-80ee-f56edec61173@googlegroups.com> (permalink)
Subject Re: My flaky math
From Jonas Thörnvall <jonas.thornvall@gmail.com>

Show all headers | View raw


Den lördag 7 december 2019 kl. 19:44:08 UTC+1 skrev Jonas Thörnvall:
> When i move selection to middle and then move the start point the selection start to drift within timeframe, should i calcMarking another way?
> 
> There must be a logical error because as i see it left and right are percentages of the total time that is the length of the bar so i do not think i move it relative a static target just timespann. And the marking shrink and expand with the timetotal, but it drifts? "When you change startpoint relative the marking".
> 
> https://midisequenser.000webhostapp.com/
> 
> function calcMarking(){
> 	//Do calculation
> 	var LeftTime=parseInt(document.getElementById("recstart").value);
> 	var RightTime=parseInt(document.getElementById("recend").value);
> 	var TimeSPos=document.getElementById("EditStart").value;
> 	var TimeEPos=document.getElementById("EditEnd").value;
> 	var distanceTotal=Mwidth-50;
> 	var TimeTotal=TimeEPos-TimeSPos;
> 	console.log("TimeEPos="+TimeEPos+" TimeSPos="+TimeSPos+" Timetotal="+TimeTotal);
> 	var RightPercent=RightTime/TimeTotal;
> 	var LeftPercent=LeftTime/TimeTotal;
> 	zz=50+(RightPercent*distanceTotal);
> 	yy=50+(LeftPercent*distanceTotal);
> }
> 
> 
> // This below is just the drawout and i don't think it is anything there
> // I think there is flaky math or flaky logic above.
> // It has no real importance for the functionality, but should look nice i guess
> 
> function drawMarked() {
> var LeftTime=parseInt(document.getElementById("recstart").value);
> var RightTime=parseInt(document.getElementById("recend").value);	
> var TimeSPos=document.getElementById("EditStart").value;
> var TimeEPos=document.getElementById("EditEnd").value;
> if(LeftTime>=TimeSPos && RightTime<=TimeEPos && mode=="Listen")  {
> 	calcMarking();
> 	drawOutMark();
> 	leftMarker();
> 	rightMarker();
>  }  
> }
> 
> 
> 
> function drawOutMark(){
> 	ctm.fillStyle ="#661313";
> 	ctm.fillRect(yy, 25,zz-yy,Mheight);
> }
> 
> function leftMarker(){
>     ctm.fillStyle = "orange";
>     ctm.beginPath();
>     ctm.moveTo(yy-10, 15);
>     ctm.lineTo(yy+10, 15);
>     ctm.lineTo(yy, 25);
>     ctm.fill();
> }
> 
> function rightMarker(){
>     ctm.fillStyle = "orange";
>     ctm.beginPath();
>     ctm.moveTo(zz-10, 15);
>     ctm.lineTo(zz+10, 15);
>     ctm.lineTo(zz, 25);
> 	ctm.lineWidth = 2;
>     ctm.fill();
> }

Sorry turned out the math passable, it was a truncation error elsewhere.

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

My flaky math Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-12-07 10:44 -0800
  Re: My flaky math Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-12-07 11:24 -0800
  Re: My flaky math Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-12-07 11:43 -0800
    Re: My flaky math Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-12-09 00:26 -0800
      Re: My flaky math Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-12-09 00:33 -0800
        Re: My flaky math Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-12-09 00:35 -0800
  Re: My flaky math Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-12-09 00:51 -0800
    Re: My flaky math Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-12-09 00:59 -0800
      Re: My flaky math Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-12-09 03:03 -0800
        Re: My flaky math Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-12-09 04:12 -0800

csiph-web