正剧开始:
星历2016年02月05日 15:32:36, 银河系厄尔斯星球中华帝国江南行省。
[工程师阿伟]正在和[机器小伟]一起研究位置。
<span style="font-size:18px;">function myDraw() { var config = new PlotConfiguration(); config.init(); config.setPreference(); //config.setSector(1,1,1,1); //config.axis2D(0, 0, 180); var row = 5, col = 6, x0 = 0, y0 = 0; plot.setStrokeStyle('blue') .setFillStyle('red'); for (var i = 1; i < row+1; i++) { for (var j = 1; j < col+1; j++) { config.setSector(row+1, col+1, i, j+1); if (i ==3 && j==2) { shape.fillRect(0, -20, 40, 20); shape.fillRect(0, 0, 80, 20); } shape.strokeRect(0, -20, 40, 20); shape.strokeRect(0, 0, 80, 20); } } for (var i = 1; i < row+1; i++) { config.setSector(row+1, col+1, i, 0.5); plot.fillText('第'+i.toFixed(0)+'行', 0, 0, 50); } for (var j = 1; j < col+1; j++) { config.setSector(row+1, col+1, row+1, j+0.8); plot.fillText('第'+j.toFixed(0)+'列', 0, 0, 50); } } </span>
<span style="font-size:18px;">function myDraw() { var config = new PlotConfiguration(); config.init(); config.setPreference(); //config.setSector(1,1,1,1); //config.axis2D(0, 0, 180); var row = 6, col = 6, r = 50, x0 = r, y0 = r; plot.setStrokeStyle('blue') .setFillStyle('red'); for (var i = 0; i < row; i++) { for (var j = 0; j < col; j++) { shape.strokeRect(x0+j*r, y0+i*r, r, r); } } pos = [[1,4], [2,2], [3,0], [3,5], [6,4]]; for (var i = 0; i < pos.length; i++) { shape.fillCircle(x0+(pos[i][0]-0.5)*r, y0+(row-pos[i][1]-0.5)*r, 5); } } </span>
<span style="font-size:18px;">function myDraw() { var config = new PlotConfiguration(); config.init(); config.setPreference(); config.setSector(1,1,1,1); config.axis2D(0, 0, 180); var a = [[5, 9], [2,1], [9,6],[1,6],[8,1]]; var scale = 20; //缩放 for (var i = 0; i < a.length; i++) { for (var j = 0; j < a[0].length; j++) { a[i][j] *= scale; } } plot.beginPath() .moveTo(a[0][0], -a[0][1]); for (var i = 1; i < a.length; i++) { //shape.fillCircle(a[i][0], -a[i][1], 5); plot.lineTo(a[i][0], -a[i][1]); } plot.closePath() .stroke(); for (var i = 0; i < a.length; i++) { shape.fillCircle(a[i][0], -a[i][1], 5); } }</span>
<span style="font-size:18px;">>>> 春 的位置是 (1, 2)。 雪 的位置是 (2, 3)。 花 的位置是 (3, 1)。 土 的位置是 (4, 5)。 冬 , 月 def tmp(): s = [['山', '石', '田', '土', '沙'], ['日', '月', '星', '火', '水'],\ ['雨', '雪', '霜', '风', '电'], ['春', '夏', '秋', '冬', '天'],\ ['枝', '叶', '花', '竹', '芽']]; quest1 = ['春', '雪', '花', '土']; for i in range(len(quest1)): for j in range(len(s)): for k in range(len(s[0])): if quest1[i] == s[j][k]: print('{0} 的位置是 ({1}, {2})。'.format(quest1[i], k+1, len(s)-j)); break; print(s[4-1][5-2], ', ', s[2-1][5-4]); return;</span>
<span style="font-size:18px;">function myDraw() { var config = new PlotConfiguration(); config.init(); config.setPreference(); //config.setSector(1,1,1,1); //config.axis2D(0, 0, 180); var a = [[9,8],[6,11],[12,11],[5,10],[13,10],[6,10],[12,10],[7,10], [11,10],[6,9],[12,9],[4,6],[14,6],[4,5],[14,5],[5,4],[13,4], [6,3],[12,3],[7,2],[11,2],[8,1],[9,1],[10,1]]; var x0 = 42, y0 = 339, r = 339-322; //缩放 for (var i = 0; i < a.length; i++) { for (var j = 0; j < a[0].length; j++) { a[i][j] *= r; } } var image = new Image(); image.src = './1.jpg'; image.onload = function() { plot.drawImage(image); for (var i = 0; i < a.length; i++) { shape.fillRect(x0+(a[i][0]-r), y0-(a[i][1]-r), r, r); } } } </span>
小伟想明白了,其实这一节功法就是隐含地在讲坐标。
<span style="font-size:18px;">function myDraw() { var config = new PlotConfiguration(); config.init(); config.setPreference(); config.setSector(1,1,1,1); config.axis2D(0, 0, 180); var a = [[100, 100], [200, 50], [300,100]]; for (var i = 0; i < a.length; i++) { shape.fillCircle(a[i][0], -a[i][1], 5); plot.beginPath() .moveTo(0, 0) .lineTo(a[i][0], -a[i][1]) .closePath() .stroke(); } }</span>