📄 house.java
字号:
/* Display still picture of house and trees.
(3 Feb 00)
*/
import java.awt.*;
public class House {
/** Return picture of house and trees.
Width = 40. Height = 30.
*/
public static Picture houseAndTrees()
{ /* Define the sun. Centre at (0,0).*/
Picture sun =
Picture.circle(Color.yellow).size(2);
/* Define a tree.
Height = 20.
Origin at middle of base of trunk.
*/
Color brown = new Color(0.2f, 0.25f, 0.1f);
Color green = new Color(0f, 0.6f, 0.2f);
Picture trunk =
Picture.box(brown).scale(2,15).at(-1,0);
Picture crown =
Picture.circle(green).size(6).at(0,14);
Picture tree = crown.over(trunk);
/* Define the house.
Height = 20.
Bottom-left corner at (0,0).
*/
Color lightGray = new Color(0.8f, 0.8f, 0.8f);
Color black = Color.black;
Color white = Color.white;
Color red = new Color(1f, 0.2f, 0f);
Picture wall =
Picture.box(white).scale(20,10)
.under(Picture.box(black).scale(3,3).at(5,4))
.under(Picture.box(red).scale(3,7).at(13,0));
Picture roof =
Picture.triangle(0,10, 10,20, 20,10, lightGray)
.over(Picture.box(white).scale(3,10).at(13,10));
Picture house = roof.over(wall);
Picture scene =
house.size(0.8).at(11,0)
.over(tree.at(4.5,0))
.over(tree.size(0.75).at(30,0))
.over(tree.at(36,0))
.over(sun.at(11,24));
return scene;
}
/****************************************************/
public static void main(String[] a) {
houseAndTrees().
show(0,0,40,30,7,Color.blue);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -