Back to index

plt-scheme  4.2.1
draw-multiple-canvas.java
Go to the documentation of this file.
00001 import draw.*;
00002 import colors.*;
00003 import geometry.*;
00004 
00005 class Example {
00006  Canvas create(int w, int h, Color bg) { 
00007    Canvas c = new Canvas(w,h);
00008    boolean tstC = c.show();
00009    boolean tstCDraw = c.drawRect(new Posn(0,0),w,h,bg);
00010    return c; 
00011  }
00012 }
00013 
00014 class Example1 extends Example {
00015  Canvas c = create(100,200,new Black());
00016  Canvas d = create(200,100,new White());
00017  
00018  boolean tst = c.close();
00019 
00020  String result = "the white 200 x 100 canvas is visible; the black one has disappeared";
00021 }
00022 
00023 class Example2 extends Example {
00024  Canvas c = create(100,200,new Blue());
00025  Canvas d = create(200,100,new Red());
00026  
00027  boolean tst = d.close();
00028 
00029  String result = "the blue canvas is visible; the green one has disappeared";
00030 }
00031 
00032 class Example3 extends Example {
00033  Canvas c = create(100,100,new Green());
00034  String sc = "a green 100 x 100 canvas pops up";
00035 
00036  Canvas d = create(200,200,new Black());
00037  String sd = "a black 200 x 200 canvas pops up";
00038  
00039  boolean tst = c.close();
00040  String st = "the green screen has disappeared";
00041  boolean tst2 = c.show();
00042  String result = "the black canvas is visible; a second white one (of 100 x 100) is visible";
00043 }
00044