MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / make4Graph

Function make4Graph

lib/web/drags.js:766–820  ·  view source on GitHub ↗
(rrRaph, w, h, get, setAndConstrain)

Source from the content-addressed store, hash-verified

764});
765
766var make4Graph = function (rrRaph, w, h, get, setAndConstrain) {
767 var vz = get();
768
769 console.log(" initial value for 4 graph is " + stringify(vz));
770
771 var curve = rrRaph.path().attr({"stroke-width": 4, "stroke": "#000"});
772
773 var updatePath = function () {
774 console.log(" path geometry will be " + stringify(vz));
775
776 var z = "M" + (vz[0][0] * (w - insetW * 2) + insetW) + "," + (vz[0][1] * (h - insetW * 2) + insetW);
777 z += "T" + (vz[1][0] * (w - insetW * 2) + insetW) + "," + (vz[1][1] * (h - insetW * 2) + insetW);
778 z += "T" + (vz[2][0] * (w - insetW * 2) + insetW) + "," + (vz[2][1] * (h - insetW * 2) + insetW);
779 z += "T" + (vz[3][0] * (w - insetW * 2) + insetW) + "," + (vz[3][1] * (h - insetW * 2) + insetW);
780 console.log(" path geometry is " + stringify(vz));
781 curve.attr({path: z})
782 };
783 var s0 = makeXYSlider(rrRaph, w, h, function () {
784 vz = get();
785 return vz[0]
786 }, function (o, p, n) {
787 vz[0] = n;
788 updatePath();
789 q = setAndConstrain(vz, vz, vz);
790 return q[0];
791 }, true, false);
792 var s1 = makeXYSlider(rrRaph, w, h, function () {
793 vz = get();
794 return vz[1]
795 }, function (o, p, n) {
796 vz[1] = n;
797 updatePath();
798 return setAndConstrain(vz, vz, vz)[1];
799 }, false, false);
800 var s2 = makeXYSlider(rrRaph, w, h, function () {
801 vz = get();
802 return vz[2]
803 }, function (o, p, n) {
804 vz[2] = n;
805 updatePath();
806 return setAndConstrain(vz, vz, vz)[2];
807 }, false, false);
808 var s3 = makeXYSlider(rrRaph, w, h, function () {
809 vz = get();
810 return vz[3]
811 }, function (o, p, n) {
812 vz[3] = n;
813 updatePath();
814 return setAndConstrain(vz, vz, vz)[3];
815 }, false, false);
816
817 return function () {
818 return vz;
819 }
820};
821
822//g = make4Graph(rrRaph, w, h, function(){return [[0.0,0.5],[0.25,0.5],[0.75,0.5],[1.0,0.5]]}, function(o,p,n){return n}, true)
823

Callers 1

insert4GraphSliderFunction · 0.85

Calls 7

makeXYSliderFunction · 0.85
updatePathFunction · 0.85
logMethod · 0.80
pathMethod · 0.80
getFunction · 0.70
stringifyFunction · 0.70
attrMethod · 0.45

Tested by

no test coverage detected