void cube(double x, double y, double z); void house(void); void tree(void); void road(void); void star(void); void drive(void); void tree2(double x, int l); void penta(void); void chain(void); void kazari(void); void rolltree(void); void treeroll(void); void main() { tg_openwin(640, 400); tg_init(); tg_manual(); star(); house(); road(); drive(); tg_init(); rolltree(); treeroll(); } void cube(double x, double y, double z) { tg_save(); tg_pd(); tg_fd(y); tg_mr(x); tg_bk(y); tg_mu(z); tg_fd(y); tg_ml(x); tg_bk(y); tg_md(z); tg_mr(x); tg_pu(); tg_fd(y); tg_pd(); tg_mu(z); tg_pu(); tg_ml(x); tg_pd(); tg_md(z); tg_pu(); tg_bk(y); tg_mu(z); tg_pd(); tg_mr(x); tg_pu(); tg_restore(); } void house() { int i1; //roof tg_setpc(5); tg_pu(); tg_home(); tg_rt(45.0); cube(200.0, 10.0, 260.0); tg_pu(); tg_home(); tg_lt(45 + 180.0); cube(200.0, 10.0, 260.0); //wall tg_setpc(10); tg_pu(); tg_home(); tg_bk(100.0); tg_ml(100.0); tg_mu(30.0); for(i1 = 0; i1 < 4; i1++){tg_pd(); tg_bk(200.0); tg_mr(200.0); tg_pu(); tg_fd(200.0); tg_rl(90.0); } //entotu tg_pu(); tg_home(); tg_bk(100.0); tg_ml(100.0); tg_mu(50.0); tg_pd(); tg_fd(100.0); tg_mu(30.0); tg_bk(100.0); tg_pu(); tg_fd(100.0); tg_pd(); tg_mr(30.0); tg_bk(70.0); tg_pu(); tg_fd(70.0); tg_pd(); tg_md(30.0); tg_bk(70.0); tg_pu(); tg_fd(70.0); tg_pd(); tg_ml(30.0); //window tg_setpc(6); tg_pu(); tg_home(); tg_bk(250.0); tg_mr(100.0); tg_mu(100.0); tg_pd(); tg_mu(100.0); tg_fd(100.0); tg_md(100.0); tg_bk(100.0); tg_pu(); } void tree() { tg_pu(); tg_save(); tg_pd(); tg_setpc(2); tg_fd(100.0); tg_setpc(12); tg_ml(70.0); tg_rt(30.0); tg_fd(140.0); tg_rt(120.0); tg_fd(140.0); tg_rt(120.0); tg_fd(70.0); tg_pu(); tg_restore(); } void road() { int i1; tg_setpc(1); tg_pu(); tg_home(); tg_mu(5000.0); tg_bk(280.0); tg_mr(500.0); tg_save(); tg_pd(); for(i1 = 0; i1 < 100; i1++){ tg_md(100.0); } tg_restore(); tg_save(); tg_pu(); tg_ml(200.0); tg_pd(); for(i1 = 0; i1 < 100; i1++){ tg_md(100.0); } tg_restore(); tg_save(); tg_pu(); tg_mr(20.0); tg_setpc(15); for(i1 = 0; i1 < 20; i1++){ tg_pu(); tg_md(500.0); tg_pd(); tg_fd(300.0); tg_pu(); tg_bk(300.0); } tg_restore(); tg_pu(); tg_ml(250.0); tg_md(300.0); for(i1 = 0; i1 < 10; i1++){ tg_pu(); tg_md(1000.0); tree(); } } void star() { int i, j, i1; tg_pu(); tg_setpc(7); tg_home(); tg_md(5000.0); tg_ml(5000.0); tg_rt(60.0); tg_pd(); tg_fd(4000.0); tg_rt(90.0); tg_fd(1000.0); tg_lt(90.0); tg_fd(2000.0); tg_rt(60.0); tg_fd(4000.0); //stop tg_pu(); tg_setpc(6); i = 0; j = 0; for(i1 = 0; i1 < 100; i1++){ i = (i * 7 + 13) % 17; j = j + 1; tg_pu(); tg_home(); tg_mu(5000.0); tg_md(j * 100.0); tg_ml(5000.0); tg_mr(i * 600.0); tg_fd(2000.0); tg_pd(); tg_ml(5.0); } } void drive() { int i1; tg_view(); tg_pu(); tg_manual(); tg_home(); tg_mu(5000.0); tg_mr(400.0); tg_bk(260.0); tg_dn(90.0); #if 1 for(i1 = 0; i1 < 220; i1++){ tg_fd(20.0); tg_refresh(); } for(i1 = 0; i1 < 20; i1++){ tg_fd(5.0); tg_refresh(); } #else tg_fd(2 * 20 + 220 * 20.0); #endif for(i1 = 0; i1 < 10; i1++){ tg_lt(5.0); tg_fd(5.0); tg_refresh(); } for(i1 = 0; i1 < 10; i1++){ tg_fd(20.0); tg_refresh(); } for(i1 = 0; i1 < 10; i1++){tg_up(6.0); tg_refresh(); } for(i1 = 0; i1 < 10; i1++){tg_fd(50.0); tg_refresh(); } for(i1 = 0; i1 < 10; i1++){tg_up(3.0); tg_fd(10.0); tg_refresh(); } tg_home(); tg_fd(500.0); tg_ml(85.0); tg_mu(65.0); tg_refresh(); for(i1 = 0; i1 < 10; i1++){tg_dn(18.0); tg_refresh(); } for(i1 = 0; i1 < 20; i1++){tg_fd(30.0); tg_rr(10.0); tg_refresh(); } } void tree2(double x, int l) { if(l > 1){ tg_save(); tg_pd(); tg_fd(x); tg_pu(); tree2(x, l - 1); tg_restore(); tg_rr(120.0); tg_save(); tg_fd(x * 0.3); tg_rt(30.0); tg_pd(); tg_fd(x); tg_pu(); tree2(x * 0.7, l - 1); tg_restore(); tg_rr(120.0); tg_save(); tg_fd(x * 0.6); tg_rt(30.0); tg_pd(); tg_fd(x); tg_pu(); tree2(x * 0.5, l - 1); tg_restore(); tg_rr(120.0); tg_save(); tg_fd(x * 0.9); tg_rt(30.0); tg_pd(); tg_fd(x); tg_pu(); tree2(x * 0.6, l - 1); tg_restore(); tg_rr(120.0); } } void penta() { int i1; tg_save(); tg_setpc(6); tg_pd(); for(i1 = 0; i1 < 5; i1++){ tg_fd(20.0); tg_rt(144.0);} tg_restore(); } void chain() { int c, i1; tg_save(); tg_dn(100.0); c = 0; for(i1 = 0; i1 < 20; i1++){ tg_setpc(c + 1); c = (c + 1) % 7; tg_pd(); tg_fd(20.0); tg_mr(10.0); tg_bk(20.0); tg_ml(10.0); tg_pu(); tg_fd(20.0); tg_rr(90.0); tg_setpc(c + 1); c = (c + 1) % 7; tg_pd(); tg_fd(20.0); tg_mr(10.0); tg_bk(20.0); tg_ml(10.0); tg_pu(); tg_fd(20.0); tg_rl(90.0); tg_up(2.0); } tg_restore(); } void kazari() { int i1; double r; //kazari tg_pu(); tg_home(); tg_fd(200.0); r = 100; for(i1 = 0; i1 < 10; i1++){ tg_pu(); tg_fd(20.0); tg_rr(36.0); tg_mu(r); tg_pd(); penta(); tg_pu(); tg_md(r); r = r - 10; } tg_pu(); tg_home(); tg_fd(200.0); tg_setpc(3); for(i1 = 0; i1 < 5; i1++){ tg_pu(); tg_fd(20.0); tg_rr(50.0); tg_mu(120.0); cube(20.0, 20.0, 20.0); tg_pu(); tg_md(120.0); } tg_pu(); tg_home(); tg_fd(200.0); tg_setpc(7); r = 120; for(i1 = 0; i1 < 10; i1++){ tg_pu(); tg_fd(20.0); tg_rl(35.0); tg_mu(r); tg_pd(); tg_ml(50.0); tg_pu(); tg_mr(50.0); tg_md(r); r = r - 10; } tg_pu(); tg_home(); tg_fd(400.0); for(i1 = 0; i1 < 3; i1++){ tg_rr(120.0); chain(); } } void rolltree() { int i1; tg_view(); tg_pu(); tg_mu(300.0); tg_draw(); //uekibachi tg_setpc(10); tg_pu(); tg_home(); tg_dn(90.0); for(i1 = 0; i1 < 36; i1++){ tg_save(); tg_pd(); tg_fd(25.0); tg_up(80.0); tg_fd(50.0); tg_pu(); tg_restore(); tg_rt(10.0); } //tree tg_pu(); tg_home(); tg_setpc(4); tg_fd(45.0); tg_pd(); tg_fd(60.0); tree2(90.0, 4); kazari(); } void treeroll() { int i1; tg_view(); tg_pu(); tg_manual(); tg_fd(800.0); for(i1 = 0; i1 < 200; i1++){ tg_rt(5.0); tg_bk(800.0); tg_refresh(); tg_fd(800.0); } }