|
5 | 5 | <title>Elliptic Curve screenshot (ℤ/k)</title> |
6 | 6 | <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> |
7 | 7 | <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/flot/0.8.3/jquery.flot.js"></script> |
| 8 | + <script type="text/javascript" src="https://github.com/niklasvh/html2canvas/releases/download/0.4.1/html2canvas.js"></script> |
8 | 9 | <script type="text/javascript" src="../interactive/ec.js"></script> |
9 | 10 | <link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro%3A400%2C700%2C900%2C400italic%2C700italic%2C900italic&subset=latin%2Clatin-ext"> |
10 | 11 | <link rel="stylesheet" type="text/css" href="../interactive/ec.css"> |
|
24 | 25 | <div class="parameter curve-coefficient"><label for="coefficient-k">k</label><input id="coefficient-k" name="k" value="11" type="number" step="1"></div> |
25 | 26 | <div class="placeholder"></div> |
26 | 27 | </div> |
| 28 | + <div id="axes-step" class="parameters"> |
| 29 | + <p>Step:</p> |
| 30 | + <div class="parameter"><label for="step">s</label><input id="step" name="step" value="2" type="number" step="1"></div> |
| 31 | + <div class="placeholder"></div> |
| 32 | + </div> |
27 | 33 | </div> |
28 | 34 | </div> |
29 | 35 | </main> |
30 | 36 | <a href="#">take screenshot</a> |
31 | 37 | <script type="text/javascript"> |
32 | 38 | $(function() { |
33 | 39 | $.ec.curve = new $.ec.modk.Base(); |
34 | | - $.ec.curve.hideGrid(); |
| 40 | + |
| 41 | + $( "#step" ).change(function() { |
| 42 | + var step = $( this ).val(); |
| 43 | + var axes = $.ec.curve.plot.getAxes(); |
| 44 | + |
| 45 | + axes.xaxis.options.tickSize = +step; |
| 46 | + axes.xaxis.options.tickDecimals = 0; |
| 47 | + axes.yaxis.options.tickSize = +step; |
| 48 | + axes.yaxis.options.tickDecimals = 0; |
| 49 | + |
| 50 | + $.ec.curve.update(); |
| 51 | + }); |
| 52 | + |
| 53 | + $.ec.curve.getPlotRange = function( points ) { |
| 54 | + return { |
| 55 | + xMin: 0, xMax: this.k - 1, |
| 56 | + yMin: 0, yMax: this.k - 1 |
| 57 | + }; |
| 58 | + }; |
35 | 59 |
|
36 | 60 | $( "a" ).click(function() { |
37 | | - var png = $( "canvas" )[ 0 ].toDataURL( "image/png" ); |
38 | | - $( "<img/>" ).attr( "src", png ).appendTo( "main" ); |
| 61 | + html2canvas($(" #plot" ), { |
| 62 | + onrendered: function( canvas ) { |
| 63 | + var png = canvas.toDataURL( "image/png" ); |
| 64 | + $( "<img/>" ).attr( "src", png ).appendTo( "main" ); |
| 65 | + } |
| 66 | + }); |
| 67 | + |
39 | 68 | return false; |
40 | 69 | }); |
41 | 70 | }); |
|
0 commit comments