Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #37943 > unrolled thread
| Started by | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| First post | 2019-12-07 10:44 -0800 |
| Last post | 2019-12-09 04:12 -0800 |
| Articles | 10 — 1 participant |
Back to article view | Back to comp.lang.javascript
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
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2019-12-07 10:44 -0800 |
| Subject | My flaky math |
| Message-ID | <5753bf40-6ff1-4609-802c-5036f9a93d64@googlegroups.com> |
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();
}
[toc] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2019-12-07 11:24 -0800 |
| Message-ID | <e50d4107-e331-4b9e-80ee-f56edec61173@googlegroups.com> |
| In reply to | #37943 |
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.
[toc] | [prev] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2019-12-07 11:43 -0800 |
| Message-ID | <ad89089e-519e-4b05-9a3b-b3f36cad7f49@googlegroups.com> |
| In reply to | #37943 |
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();
> }
ehrm no still there, but now one can see it seem to use same original value each time, because the difference for some reason is the one bar that is removed.
[toc] | [prev] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2019-12-09 00:26 -0800 |
| Message-ID | <15419caa-ae4e-4912-baf8-cbe68ed7fc77@googlegroups.com> |
| In reply to | #37945 |
Den lördag 7 december 2019 kl. 20:43:23 UTC+1 skrev Jonas Thörnvall:
> 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();
> > }
>
> ehrm no still there, but now one can see it seem to use same original value each time, because the difference for some reason is the one bar that is removed.
Well if someone can't show what goes wrong, "i have a sneaky suspiscion" that righttime and lefttime somehow fractions dependent on timetotal. But i will just start add the missing lengths. Because for some reason it seem to be one.
[toc] | [prev] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2019-12-09 00:33 -0800 |
| Message-ID | <b128b7c2-c052-4f92-a6a9-4c355446dc83@googlegroups.com> |
| In reply to | #37946 |
Den måndag 9 december 2019 kl. 09:26:46 UTC+1 skrev Jonas Thörnvall:
> Den lördag 7 december 2019 kl. 20:43:23 UTC+1 skrev Jonas Thörnvall:
> > 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();
> > > }
> >
> > ehrm no still there, but now one can see it seem to use same original value each time, because the difference for some reason is the one bar that is removed.
>
> Well if someone can't show what goes wrong, "i have a sneaky suspiscion" that righttime and lefttime somehow fractions dependent on timetotal. But i will just start add the missing lengths. Because for some reason it seem to be one.
Ok fixed but someone could show me the correct math?
function calcMarking(){
var STARTBAR=document.getElementById("SB").value;
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;
//Do calculation
distanceTotal=Mwidth-50;
TimeTotal=TimeEPos-TimeSPos;
RightPerc=RightTime/TimeTotal;
LeftPerc=LeftTime/TimeTotal;
zz=50+(RightPerc*distanceTotal)-(barlength*STARTBAR);
yy=50+(LeftPerc*distanceTotal)-(barlength*STARTBAR);
}
[toc] | [prev] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2019-12-09 00:35 -0800 |
| Message-ID | <a7516615-1fa2-4af3-a2ff-054825b7356c@googlegroups.com> |
| In reply to | #37947 |
Den måndag 9 december 2019 kl. 09:33:31 UTC+1 skrev Jonas Thörnvall:
> Den måndag 9 december 2019 kl. 09:26:46 UTC+1 skrev Jonas Thörnvall:
> > Den lördag 7 december 2019 kl. 20:43:23 UTC+1 skrev Jonas Thörnvall:
> > > 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();
> > > > }
> > >
> > > ehrm no still there, but now one can see it seem to use same original value each time, because the difference for some reason is the one bar that is removed.
> >
> > Well if someone can't show what goes wrong, "i have a sneaky suspiscion" that righttime and lefttime somehow fractions dependent on timetotal. But i will just start add the missing lengths. Because for some reason it seem to be one.
>
> Ok fixed but someone could show me the correct math?
>
> function calcMarking(){
> var STARTBAR=document.getElementById("SB").value;
> 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;
> //Do calculation
> distanceTotal=Mwidth-50;
>
> TimeTotal=TimeEPos-TimeSPos;
> RightPerc=RightTime/TimeTotal;
> LeftPerc=LeftTime/TimeTotal;
> zz=50+(RightPerc*distanceTotal)-(barlength*STARTBAR);
> yy=50+(LeftPerc*distanceTotal)-(barlength*STARTBAR);
> }
Would be nice using fractions of bars instead of time, but for me it was easier to think along timebase.
[toc] | [prev] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2019-12-09 00:51 -0800 |
| Message-ID | <67478597-1d96-4ff6-9da5-c99446684435@googlegroups.com> |
| In reply to | #37943 |
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();
> }
I think the correct math involve transforming right and left "selected markers" into fractions relative the length of FRACTION=(righttime-lefttime)/totaltime
And then newleftime=leftime*FRACTION and newrighttime=rightime*fraction.
And then take the fraction of Rightperc=newrighttime/totaltime
And then Rightperc*totaltime
But i am not in the mood to fiddle with it.
There is other things to fix like the trackeditor.
I would say it work now, for the use intended "yeah i can see it drift a little" when the startbar run high.
[toc] | [prev] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2019-12-09 00:59 -0800 |
| Message-ID | <cb509c2a-12ba-434b-a6cc-66782a7c3dd3@googlegroups.com> |
| In reply to | #37949 |
Den måndag 9 december 2019 kl. 09:51:42 UTC+1 skrev Jonas Thörnvall:
> 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();
> > }
>
> I think the correct math involve transforming right and left "selected markers" into fractions relative the length of FRACTION=(righttime-lefttime)/totaltime
> And then newleftime=leftime*FRACTION and newrighttime=rightime*fraction.
>
> And then take the fraction of Rightperc=newrighttime/totaltime
> And then Rightperc*totaltime
>
> But i am not in the mood to fiddle with it.
> There is other things to fix like the trackeditor.
>
> I would say it work now, for the use intended "yeah i can see it drift a little" when the startbar run high.
At bar 450 or so it have drifted a full bar...
[toc] | [prev] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2019-12-09 03:03 -0800 |
| Message-ID | <e9c28d17-7dfb-46ee-b236-d040cf2fe523@googlegroups.com> |
| In reply to | #37950 |
Den måndag 9 december 2019 kl. 09:59:51 UTC+1 skrev Jonas Thörnvall:
> Den måndag 9 december 2019 kl. 09:51:42 UTC+1 skrev Jonas Thörnvall:
> > 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();
> > > }
> >
> > I think the correct math involve transforming right and left "selected markers" into fractions relative the length of FRACTION=(righttime-lefttime)/totaltime
> > And then newleftime=leftime*FRACTION and newrighttime=rightime*fraction.
> >
> > And then take the fraction of Rightperc=newrighttime/totaltime
> > And then Rightperc*totaltime
> >
> > But i am not in the mood to fiddle with it.
> > There is other things to fix like the trackeditor.
> >
> > I would say it work now, for the use intended "yeah i can see it drift a little" when the startbar run high.
>
> At bar 450 or so it have drifted a full bar...
Well now i think you will find the accuracy good enough for some hundred million of bars, but what is the math really?
function calcMarking(){
var STARTBAR=document.getElementById("SB").value;
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;
//Do calculation
distanceTotal=Mwidth-50;
TimeTotal=TimeEPos-TimeSPos;
RightPerc=RightTime/TimeTotal;
LeftPerc=LeftTime/TimeTotal;
zz=50+(RightPerc*distanceTotal)-(barlength*STARTBAR)*0.99771462;
yy=50+(LeftPerc*distanceTotal)-(barlength*STARTBAR)*0.99771462;
}
[toc] | [prev] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2019-12-09 04:12 -0800 |
| Message-ID | <ecf898c5-6c6d-4688-8d81-d2b9bb8b957f@googlegroups.com> |
| In reply to | #37951 |
Den måndag 9 december 2019 kl. 12:03:17 UTC+1 skrev Jonas Thörnvall:
> Den måndag 9 december 2019 kl. 09:59:51 UTC+1 skrev Jonas Thörnvall:
> > Den måndag 9 december 2019 kl. 09:51:42 UTC+1 skrev Jonas Thörnvall:
> > > 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();
> > > > }
> > >
> > > I think the correct math involve transforming right and left "selected markers" into fractions relative the length of FRACTION=(righttime-lefttime)/totaltime
> > > And then newleftime=leftime*FRACTION and newrighttime=rightime*fraction.
> > >
> > > And then take the fraction of Rightperc=newrighttime/totaltime
> > > And then Rightperc*totaltime
> > >
> > > But i am not in the mood to fiddle with it.
> > > There is other things to fix like the trackeditor.
> > >
> > > I would say it work now, for the use intended "yeah i can see it drift a little" when the startbar run high.
> >
> > At bar 450 or so it have drifted a full bar...
>
> Well now i think you will find the accuracy good enough for some hundred million of bars, but what is the math really?
>
> function calcMarking(){
> var STARTBAR=document.getElementById("SB").value;
> 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;
> //Do calculation
> distanceTotal=Mwidth-50;
> TimeTotal=TimeEPos-TimeSPos;
> RightPerc=RightTime/TimeTotal;
> LeftPerc=LeftTime/TimeTotal;
> zz=50+(RightPerc*distanceTotal)-(barlength*STARTBAR)*0.99771462;
> yy=50+(LeftPerc*distanceTotal)-(barlength*STARTBAR)*0.99771462;
> }
On the other hand one could do it like this.
So i wonder what i was thinking doing it like that?
Calculation independent of barlength, maybe was thinking moving target?
Well have no idea it is lost now. And i do not use it for scroll so maybe it was a moving scrollbar who knows.
function calcMarking(){
var recSPos = document.getElementById("startbar").value;
var recEPos = document.getElementById("endbar").value;
var editSPos=document.getElementById("SB").value;
var editEPos=document.getElementById("EB").value;
var left=recSPos-editSPos;
var right=recEPos-editSPos;
zz=50+(left*barlength);
yy=50+(right*barlength);
}
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.javascript
csiph-web