New Facer Editor UI

Amusing … I suppose.

That was someone else’s attempt to adapt the ‘Trig2()’ function (Moon calculator) to use in Facer:


function Trig2(year,month,day) {
	n = Math.floor(12.37 * (year -1900 + ((1.0 * month - 0.5)/12.0)));
	RAD = 3.14159265/180.0;
	t = n / 1236.85;
	t2 = t * t;
	as = 359.2242 + 29.105356 * n;
	am = 306.0253 + 385.816918 * n + 0.010730 * t2;
	xtra = 0.75933 + 1.53058868 * n + ((1.178e-4) - (1.55e-7) * t) * t2;
	xtra += (0.1734 - 3.93e-4 * t) * Math.sin(RAD * as) - 0.4068 * Math.sin(RAD * am);
	i = (xtra > 0.0 ? Math.floor(xtra) :  Math.ceil(xtra - 1.0));
	j1 = julday(year,month,day);
	jd = (2415020 + 28 * n) + i;
	return (j1-jd + 30)%30;
}

function julday(year, month, day) {
	if (year < 0) { year ++; }
	var jy = parseInt(year);
	var jm = parseInt(month) +1;
	if (month <= 2) {jy--;	jm += 12;	} 
	var jul = Math.floor(365.25 *jy) + Math.floor(30.6001 * jm) + parseInt(day) + 1720995;
	if (day+31*(month+12*year) >= (15+31*(10+12*1582))) {
		ja = Math.floor(0.01 * jy);
		jul = jul + 2 - ja + Math.floor(0.25 * ja);
	}
	return jul;
}

Allowing substitutions reduces all that complexity to just:


Lunation : (floor(12.37*(#Dy#-1900+((1.0*#DM#-0.5)/12))))
Tcycle : (&Lunation&/1236.85)
Tcycle2 : (&Tcycle&*&Tcycle&)
AS : (359.2242+&Lunation&*29.105356)
AM : (306.0253+&Lunation&*385.816918+&Tcycle2&*0.010730)

((
(((floor(365.25*(#DM#<2?(#Dy#-#Dy#):#Dy#)))+(floor(30.6001*((#DM#<=2)?((#DM#+1)+12):(#DM#+1))))+#Dd#+1720995)+2-((#Dd#+31*(#DM#+12*#Dy#))>=(15+31*(10+12*1582))?(floor(0.01*((#DM#<=2)?(#Dy#-#Dy#):(#Dy#)))):(#DM#<=2?(#Dy#-#Dy#):(#Dy#)))+floor(0.25*((#Dd#+31*(#DM#+12*#Dy#))>=(15+31*(10+12*1582))?(floor(0.01*((#DM#<=2)?(#Dy#-#Dy#):(#Dy#)))):(#DM#<=2?(#Dy#-#Dy#):(#Dy#)))))-((2415020+28*&Lunation&)+((0.75933+1.53058868*&Lunation&+((1.178e-4)-(1.55e-7)*&Tcycle&)*(&Tcycle2&)+(0.1734-3.93e-4*&Tcycle&)*sin(rad(&AS&))-sin(rad(&AM&))*0.4068)>0.0?(floor((0.75933+1.53058868*&Lunation&+((1.178e-4)-(1.55e-7)*&Tcycle&)*(&Tcycle2&)+(0.1734-3.93e-4*&Tcycle&)*sin(rad(&AS&))-sin(rad(&AM&))*0.4068))):(ceil((0.75933+1.53058868*&Lunation&+((1.178e-4)-(1.55e-7)*&Tcycle&)*(&Tcycle2&)+(0.1734-3.93e-4*&Tcycle&)*sin(0.017453292500000002*(359.2242+29.105356*&Lunation&))-sin(rad(&AM&))*0.4068)-1.0)))
)+30)%30)

The rest of it is a bunch of nested IF statements and date logic that I can’t easily unravel …

I guess my point is … people need to be able to use (and debug) this type of mathematical expression without having to repeat it 20-30 times across the ‘rotation’, ‘transparency’ and ‘text’ fields for a watch design.

And then others can use it … without trying to understand, modify, or re-type it …

1 Like

Okay, starting instead from the original JavaScript source code …

  • MoonAge1, using just 2 substitutions.
  • MoonAge2, using full substitution,
  • Then same code, full expanded (still being tested).

JulianDate : (1721059.5+floor(#Dy#*365.2425)+#DD#+((#DH#*3600+#Dm#*60+#Ds#)/86400))
Lunation : (floor((#Dy#-1900+#DD#/365.2425)*12.3683))

MoonAge1 : ((&JulianDate&-(2415020.0+&Lunation&*28+(0.75933+&Lunation&*1.53058868+(1.178e-4-((#Dy#-1900)/100)*1.55e-7)*(((#Dy#-1900)/100)*((#Dy#-1900)/100))+(0.1734-((#Dy#-1900)/100)*3.93e-4)*sin(rad(359.2242+&Lunation&*29.105356))-sin(rad(306.0253+&Lunation&*385.816918+(((#Dy#-1900)/100)*((#Dy#-1900)/100))*1.073e-2))*0.4068))+29.5306)%29.5306)
(floor(&MoonAge1&*100)/100) days

Tcycle : ((#Dy#-1900)/100)
Tcycle2 : (&Tcycle&*&Tcycle&)
AS : (359.2242+&Lunation&*29.105356)
AM : (306.0253+&Lunation&*385.816918+&Tcycle2&*1.073e-2)
Xtra : (0.75933+&Lunation&*1.53058868+(1.178e-4-&Tcycle&*1.55e-7)*&Tcycle2&+(0.1734-&Tcycle&*3.93e-4)*sin(rad(&AS&))-sin(rad(&AM&))*0.4068)
JulianNewMoon : (2415020.0+&Lunation&*28+&Xtra&)

MoonAge2 : ((&JulianDate&-&JulianNewMoon&+29.5306)%29.5306)
(floor(&MoonAge2&*100)/100) days

(((1721059.5+floor(#Dy#*365.2425)+#DD#+((#DH#*3600+#Dm#*60+#Ds#)/86400))-(2415020.0+(floor((#Dy#-1900+#DD#/365.2425)*12.3683))*28+(0.75933+(floor((#Dy#-1900+#DD#/365.2425)*12.3683))*1.53058868+(1.178e-4-((#Dy#-1900)/100)*1.55e-7)*(((#Dy#-1900)/100)*((#Dy#-1900)/100))+(0.1734-((#Dy#-1900)/100)*3.93e-4)*sin(rad(359.2242+(floor((#Dy#-1900+#DD#/365.2425)*12.3683))*29.105356))-sin(rad(306.0253+(floor((#Dy#-1900+#DD#/365.2425)*12.3683))*385.816918+(((#Dy#-1900)/100)*((#Dy#-1900)/100))*1.073e-2))*0.4068))+29.5306)%29.5306)

(floor((((1721059.5+floor(#Dy#*365.2425)+#DD#+((#DH#*3600+#Dm#*60+#Ds#)/86400))-(2415020.0+(floor((#Dy#-1900+#DD#/365.2425)*12.3683))*28+(0.75933+(floor((#Dy#-1900+#DD#/365.2425)*12.3683))*1.53058868+(1.178e-4-((#Dy#-1900)/100)*1.55e-7)*(((#Dy#-1900)/100)*((#Dy#-1900)/100))+(0.1734-((#Dy#-1900)/100)*3.93e-4)*sin(rad(359.2242+(floor((#Dy#-1900+#DD#/365.2425)*12.3683))*29.105356))-sin(rad(306.0253+(floor((#Dy#-1900+#DD#/365.2425)*12.3683))*385.816918+(((#Dy#-1900)/100)*((#Dy#-1900)/100))*1.073e-2))*0.4068))+29.5306)%29.5306)*100)/100) days

Question:

Would this (‘substitution’) be a useful feature for Facer Editor?

I would definitely move the right panel to the left to tabs or bookmarks. It will get more space on my 14 inch laptop.
Then I would shrink the hint of the selected element, everything is unnecessarily large and everywhere. Then I don’t see what I’m actually editing.