[20498] | 1 | Index: ../trunk-jpl/src/m/plot/applyoptions.js
|
---|
| 2 | ===================================================================
|
---|
| 3 | --- ../trunk-jpl/src/m/plot/applyoptions.js (revision 19871)
|
---|
| 4 | +++ ../trunk-jpl/src/m/plot/applyoptions.js (revision 19872)
|
---|
| 5 | @@ -203,7 +203,6 @@
|
---|
| 6 | ccontext.beginPath();
|
---|
| 7 | }
|
---|
| 8 | var cgradient = ccontext.createLinearGradient(0,cheightoffset/2,0,cheight);
|
---|
| 9 | - var tgradient = ccontext.createLinearGradient(0,0,0,256);
|
---|
| 10 |
|
---|
| 11 | var cmap = options.getfieldvalue('cmap','jet');
|
---|
| 12 | var colorbar = colorbars[cmap];
|
---|
| 13 | @@ -211,12 +210,10 @@
|
---|
| 14 | color = colorbar[colorbar.length-i-1];
|
---|
| 15 | color = [Math.round(color[0]*255),Math.round(color[1]*255),Math.round(color[2]*255)];
|
---|
| 16 | cgradient.addColorStop(i/colorbar.length,'rgba('+color.toString()+',1.0)');
|
---|
| 17 | - tgradient.addColorStop(i/colorbar.length,'rgba('+color.toString()+',1.0)');
|
---|
| 18 | }
|
---|
| 19 | ccontext.fillStyle=cgradient;
|
---|
| 20 | ccontext.fillRect(0,cheightoffset/2,cwidth,cheight);
|
---|
| 21 |
|
---|
| 22 | -
|
---|
| 23 | //Draw colorbar border
|
---|
| 24 | ccontext.beginPath();
|
---|
| 25 | ccontext.lineWidth='1';
|
---|
| 26 | @@ -272,21 +269,17 @@
|
---|
| 27 | ccontext.beginPath();
|
---|
| 28 | }
|
---|
| 29 | var cgradient = ccontext.createLinearGradient(cwidth+cwidthoffset,0,cwidthoffset,0);
|
---|
| 30 | - var tgradient = ccontext.createLinearGradient(cwidthoffset,0,0,256);
|
---|
| 31 |
|
---|
| 32 | var cmap = options.getfieldvalue('cmap','jet');
|
---|
| 33 | var colorbar = colorbars[cmap];
|
---|
| 34 | - console.log(cmap, colorbar);
|
---|
| 35 | for (var i = 0; i < colorbar.length; i++) {
|
---|
| 36 | color = colorbar[colorbar.length-i-1];
|
---|
| 37 | color = [Math.round(color[0]*255),Math.round(color[1]*255),Math.round(color[2]*255)];
|
---|
| 38 | cgradient.addColorStop(i/colorbar.length,'rgba('+color.toString()+',1.0)');
|
---|
| 39 | - tgradient.addColorStop(i/colorbar.length,'rgba('+color.toString()+',1.0)');
|
---|
| 40 | }
|
---|
| 41 | ccontext.fillStyle=cgradient;
|
---|
| 42 | ccontext.fillRect(cwidthoffset,0,cwidth,cheight);
|
---|
| 43 |
|
---|
| 44 | -
|
---|
| 45 | //Draw colorbar border
|
---|
| 46 | ccontext.beginPath();
|
---|
| 47 | ccontext.lineWidth='1';
|
---|
| 48 | @@ -309,25 +302,6 @@
|
---|
| 49 | ccontext.fillText(labels[cdivisions-i],x+cwidthoffset,cheight+cheightoffset);
|
---|
| 50 | }
|
---|
| 51 | }
|
---|
| 52 | -
|
---|
| 53 | - //Make texture canvas
|
---|
| 54 | - var tcontext,tcanvas,tcanvasid,tcanvashtml,tURL;
|
---|
| 55 | - tcanvasid = 'texturecanvas';
|
---|
| 56 | - var tcanvashtml = document.getElementById(tcanvasid);
|
---|
| 57 | - if (tcanvashtml == null) {
|
---|
| 58 | - tcanvas = $('<canvas id="texturecanvas" width="256" height="256"></canvas>').insertAfter(ccanvas);
|
---|
| 59 | - tcanvas.css({'display':'none'});
|
---|
| 60 | - tcanvashtml = document.getElementById(tcanvasid);
|
---|
| 61 | - }
|
---|
| 62 | - else {
|
---|
| 63 | - tcanvas = $('#' + tcanvasid);
|
---|
| 64 | - }
|
---|
| 65 | - tcontext = tcanvashtml.getContext('2d');
|
---|
| 66 | - tcontext.fillStyle = tgradient;
|
---|
| 67 | - tcontext.fillRect(0,0,256,256);
|
---|
| 68 | - tURL = tcanvashtml.toDataURL();
|
---|
| 69 | - node["texture"] = initTexture(gl,tURL);
|
---|
| 70 | - console.log(node["texture"]);
|
---|
| 71 | /* //{{{
|
---|
| 72 | if exist(options,'wrapping')
|
---|
| 73 | lim=get(c,'Ylim');
|
---|
| 74 | @@ -399,6 +373,34 @@
|
---|
| 75 | //do nothing
|
---|
| 76 |
|
---|
| 77 | }
|
---|
| 78 | + //Make texture canvas
|
---|
| 79 | +
|
---|
| 80 | + var tcontext,tcanvas,tcanvasid,tcanvashtml,tURL,tgradient;
|
---|
| 81 | + tcanvasid = 'texturecanvas';
|
---|
| 82 | + var tcanvashtml = document.getElementById(tcanvasid);
|
---|
| 83 | + if (tcanvashtml == null) {
|
---|
| 84 | + tcanvas = $('<canvas id="texturecanvas" width="256" height="256"></canvas>').insertAfter('#'+String(options.getfieldvalue('canvasid')));
|
---|
| 85 | + tcanvas.css({'display':'none'});
|
---|
| 86 | + tcanvashtml = document.getElementById(tcanvasid);
|
---|
| 87 | + }
|
---|
| 88 | + else {
|
---|
| 89 | + tcanvas = $('#' + tcanvasid);
|
---|
| 90 | + }
|
---|
| 91 | + tcontext = tcanvashtml.getContext('2d');
|
---|
| 92 | + tgradient = tcontext.createLinearGradient(0,0,0,256);
|
---|
| 93 | +
|
---|
| 94 | + var cmap = options.getfieldvalue('cmap','jet');
|
---|
| 95 | + var colorbar = colorbars[cmap];
|
---|
| 96 | + for (var i = 0; i < colorbar.length; i++) {
|
---|
| 97 | + color = colorbar[colorbar.length-i-1];
|
---|
| 98 | + color = [Math.round(color[0]*255),Math.round(color[1]*255),Math.round(color[2]*255)];
|
---|
| 99 | + tgradient.addColorStop(i/colorbar.length,'rgba('+color.toString()+',1.0)');
|
---|
| 100 | + }
|
---|
| 101 | +
|
---|
| 102 | + tcontext.fillStyle = tgradient;
|
---|
| 103 | + tcontext.fillRect(0,0,256,256);
|
---|
| 104 | + tURL = tcanvashtml.toDataURL();
|
---|
| 105 | + node["texture"] = initTexture(gl,tURL);
|
---|
| 106 | /* //{{{
|
---|
| 107 | //area
|
---|
| 108 | if exist(options,'area'),
|
---|
| 109 | Index: ../trunk-jpl/src/m/plot/plot_unit.js
|
---|
| 110 | ===================================================================
|
---|
| 111 | --- ../trunk-jpl/src/m/plot/plot_unit.js (revision 19871)
|
---|
| 112 | +++ ../trunk-jpl/src/m/plot/plot_unit.js (revision 19872)
|
---|
| 113 | @@ -49,12 +49,10 @@
|
---|
| 114 | var scale = 1 / (xmax - xmin);
|
---|
| 115 | node["shaderName"] = "unlit_textured";
|
---|
| 116 | node["shader"] = gl["shaders"][node["shaderName"]]["program"];
|
---|
| 117 | - console.log(gl["shaders"]);
|
---|
| 118 | node["scale"] = [scale, scale, scale];
|
---|
| 119 | node["rotation"] = options.getfieldvalue('view',[0,0,0]);
|
---|
| 120 | node["translation"] = [(xmin + xmax) / (-2 / scale), (ymin + ymax) / (-2 / scale), (zmin + zmax) / (-2 / scale)];
|
---|
| 121 | node["modelMatrix"] = recalculateModelMatrix(node);
|
---|
| 122 | - console.log(node);
|
---|
| 123 | //some defaults:
|
---|
| 124 | texcoords.itemSize = 2;
|
---|
| 125 |
|
---|
| 126 | @@ -109,8 +107,7 @@
|
---|
| 127 | else{ //triangular elements
|
---|
| 128 |
|
---|
| 129 | vertices.itemSize = 3;
|
---|
| 130 | - var cmap=options.getfieldvalue('cmap','jet');
|
---|
| 131 | - console.log(datamin,datamax,data);
|
---|
| 132 | + var cmap=options.getfieldvalue('cmap','jet');
|
---|
| 133 | for(var i = 0; i < x.length; i++){
|
---|
| 134 | vertices[vertices.length] = x[i];
|
---|
| 135 | vertices[vertices.length] = y[i];
|
---|