Task2:
Composition of Lines |
Code #include "Canvas.as"
var C = new Canvas();
//set initial properties
C.setBackgroundColor(1, 1, .5);
//draw orange lines from top to bottom on the full page
var x = .05;
var y = 0;
while (x<=1) {
C.setPenColor(1, .56, .28);
C.setPenWeight(.05);
C.drawLine(x, y, x, 1-y);
x += .05;
}
//draw red diagonal lines on the right bottom half of the page
var x = 0;
var y = 1;
C.setPenColor(1, 0, 0);
C.setPenWeight(.05);
while (x<y) {
C.drawLine(x, y, y, x);
x += .06;
}
//draw red diagonal lines on the left top half of the page
var x = 1;
var y = 0;
C.setPenColor(1, 0, 0);
C.setPenWeight(.05);
while (x>y) {
C.drawLine(x, y, y, x);
x -= .06;
}
//draw the Chinese character
//use the same color with the background
C.setPenColor(1, 1, .5);
C.setPenWeight(.15);
//draw the left part
C.drawLine(.3, .1, .3, .15); //the dot on the top of the left part
C.drawLine(.4, .2, .2, .2); //the horizontal line of the left part
C.drawLine(.4, .2, .15, .6); //the diagonal line of the left part
C.drawLine(.3, .4, .3, .9); //the vertical line of the left part
C.drawLine(.4, .5, .3, .4); //the dot connected to the joint of diagonal line and vertical line
//draw the right part
C.drawLine(.8, .125, .5, .125); //the first line on the top of the right part
//the box in the middle of the right part
var top = .25;
var left = .55;
var bottom = .4;
var right = .75;
C.drawLine(left, top, right, top); // -
C.drawLine(right, top, right, bottom); // |
C.drawLine(right, bottom, left, bottom); // -
C.drawLine(left, bottom, left, top); // |
//the box with a cross in it
//at the bottom of the right part
var top = .55;
var left = .5;
var bottom = .9;
var right = .8;
C.drawLine(left, top, right, top); // -
C.drawLine(right, top, right, bottom); //|
C.drawLine(right, bottom, left, bottom); // -
C.drawLine(left, bottom, left, top); // |
//the cross in the box
C.drawLine(right, .725, left, .725); //-
C.drawLine(.65, top, .65, bottom); // |