[机器小伟]在[工程师阿伟]的陪同下进入了筑基初期的修炼,
这次要修炼的目标是[平面直角坐标系 小结与复习题]。
正剧开始:
星历2016年03月04日 12:11:27, 银河系厄尔斯星球*江南行省。
[工程师阿伟]正在和[机器小伟]一起研究[平面直角坐标系 小结与复习题]。
本次修炼中的习题解答代码,至少有一半是不需要的,主要是为了方便,就没有删除。
<span style="font-size:18px;">//题1
function myDraw() {
var config = new PlotConfiguration();
config.init();
config.setPreference();
var r = 31;
var image = new Image();
image.src = './1.jpg';
image.onload = function() {
plot.translate(300, 0);
plot.drawImage(image);
config.setSector(1,1,1,1);
config.graphPaper2D(0, 0, r);
config.axis2D(0, 0, 180);
var array = [[2,3],[-2,3],[-2,-3],[2,-3]];
var len = array.length;
if (len > 0) {
var tmp = [].concat(array);
shape.pointDraw(tmp, 'red', r);
tmp = [].concat(array);
//shape.fillDraw(tmp, 'pink', r);
shape.multiLineDraw(tmp, 'blue', r);
var s = '['+array.join('], [')+']';
var measure = plot.measureText(s);
if (measure>600) {
plot.fillText(s, -300, 150, 600);
}
else {
plot.fillText(s, -measure/2, 150, measure);
}
}
}
}
</span>
<span style="font-size:18px;">//题2
function myDraw() {
var config = new PlotConfiguration();
config.init();
config.setPreference();
var r = 27;
var image = new Image();
image.src = './1.jpg';
image.onload = function() {
plot.translate(300-6*r, 0.9*r);
plot.drawImage(image);
config.setSector(1,1,1,1);
config.graphPaper2D(0, 0, r);
config.axis2D(0, 0, 180);
var array = [];
var len = array.length;
if (len > 0) {
var tmp = [].concat(array);
shape.pointDraw(tmp, 'red', r);
tmp = [].concat(array);
//shape.fillDraw(tmp, 'pink', r);
shape.multiLineDraw(tmp, 'blue', r);
var s = '['+array.join('], [')+']';
var measure = plot.measureText(s);
if (measure>600) {
plot.fillText(s, -300, 150, 600);
}
else {
plot.fillText(s, -measure/2, 150, measure);
}
}
}
}</span>
<span style="font-size:18px;">//题3
function myDraw() {
var config = new PlotConfiguration();
config.init();
config.setPreference();
var r = 20;
var image = new Image();
image.src = './1.jpg';
image.onload = function() {
plot.translate(300, 0);
plot.drawImage(image);
config.setSector(1,1,1,1);
config.graphPaper2D(0, 0, r);
config.axis2D(0, 0, 180);
var array = [[2, 0], [4,0],[2,2]];
var array2 = [[0,2],[0,4],[-2,2]];
var array3 = [[-4,0],[-2,-2],[-2,0]];
var array4 = [[0,-2],[2,-2],[0,-4]];
var len = array.length;
if (len > 0) {
var tmp = [].concat(array);
shape.pointDraw(tmp, 'red', r);
tmp = [].concat(array);
shape.strokeDraw(tmp, 'blue', r);
tmp = [].concat(array2);
shape.pointDraw(tmp, 'red', r);
tmp = [].concat(array2);
shape.strokeDraw(tmp, 'blue', r);
tmp = [].concat(array3);
shape.pointDraw(tmp, 'red', r);
tmp = [].concat(array3);
shape.strokeDraw(tmp, 'blue', r);
tmp = [].concat(array4);
shape.pointDraw(tmp, 'red', r);
tmp = [].concat(array4);
shape.strokeDraw(tmp, 'blue', r);
/*
var s = '['+array.join('], [')+']';
var measure = plot.measureText(s);
if (measure>600) {
plot.fillText(s, -300, 150, 600);
}
else {
plot.fillText(s, -measure/2, 150, measure);
}*/
}
}
}
</span>
<span style="font-size:18px;">//题4
function myDraw() {
var config = new PlotConfiguration();
config.init();
config.setPreference();
var r = 35;
var image = new Image();
image.src = './1.jpg';
image.onload = function() {
plot.translate(300-5.2*r, 0.9*r);
plot.drawImage(image);
config.setSector(1,1,1,1);
config.graphPaper2D(0, 0, r);
config.axis2D(0, 0, 180);
var array = [[-100,200],[100,0],[200,100],[200,-200],[-100,-200],[0,-100]];
r/=100;
var len = array.length;
if (len > 0) {
var tmp = [].concat(array);
shape.pointDraw(tmp, 'red', r);
tmp = [].concat(array);
shape.multiLineDraw(tmp, 'blue', r);
var s = '['+array.join('], [')+']';
var measure = plot.measureText(s);
if (measure>600) {
plot.fillText(s, -300, 150, 600);
}
else {
plot.fillText(s, -measure/2, 150, measure);
}
}
}
}
</span>
下面是这个村子的水井位置,中心点是村委会,比例尺是1:250。
<span style="font-size:18px;">//题8
function myDraw() {
var config = new PlotConfiguration();
config.init();
config.setPreference();
var r = 20;
var image = new Image();
image.src = './1.jpg';
image.onload = function() {
plot.translate(300, 0);
plot.drawImage(image);
config.setSector(1,1,1,1);
config.graphPaper2D(0, 0, r);
config.axis2D(0, 0, 180);
var array = [[0, 0],[1000, 1732],[-1500,0],[707,-707],[0,-900]];
r/=250;
var len = array.length;
if (len > 0) {
var tmp = [].concat(array);
shape.pointDraw(tmp, 'red', r);
tmp = [].concat(array);
shape.multiLineDraw(tmp, 'blue', r);
var s = '['+array.join('], [')+']';
var measure = plot.measureText(s);
if (measure>600) {
plot.fillText(s, -300, 150, 600);
}
else {
plot.fillText(s, -measure/2, 150, measure);
}
}
}
}
</span>
<span style="font-size:18px;">//题10
function myDraw() {
var config = new PlotConfiguration();
config.init();
config.setPreference();
var r = 40;
var image = new Image();
image.src = './1.jpg';
image.onload = function() {
plot.translate(300, 0);
plot.drawImage(image);
config.setSector(1,1,1,1);
config.graphPaper2D(0, 0, r);
config.axis2D(0, 0, 180);
var array = [[1,1],[5,1],[3,3],[-3,3],[1,-2],[1,4],[3,2],[3,-2],[-1,-1],[-1,1]];
var lable = 'ABCDEFGHIJ';
var len = array.length;
for (var i = 0; i < len; i++) {
plot.fillText(lable[i], array[i][0]*r, -array[i][1]*r-5, 20);
}
if (len > 0) {
var tmp = [].concat(array);
shape.pointDraw(tmp, 'red', r);
tmp = [].concat(array);
//shape.multiLineDraw(tmp, 'blue', r);
var s = '['+array.join('], [')+']';
var measure = plot.measureText(s);
if (measure>600) {
plot.fillText(s, -300, 150, 600);
}
else {
plot.fillText(s, -measure/2, 150, measure);
}
}
}
}</span>
本节到此结束,欲知后事如何,请看下回分解。