Skip to content

Commit c84b986

Browse files
committed
translated all examples in Objects into Chinese
1 parent b436b8a commit c84b986

File tree

6 files changed

+33
-39
lines changed

6 files changed

+33
-39
lines changed

src/data/examples/zh-Hans/11_Objects/01_Objects.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
/*
2-
* @name Objects
3-
* @description Create a Jitter class, instantiate an object,
4-
* and move it around the screen. Adapted from Getting Started with
5-
* Processing by Casey Reas and Ben Fry.
2+
* @name 物件 (Objects)
3+
* @description 创建一个 Jitter 类, 实例化一个物件,并且在屏幕上移动。
4+
* 改编自 Processing 入门,作者:Casey Reas 和 Ben Fry
65
*/
76

8-
let bug; // Declare object
7+
let bug; // 声明物件
98

109
function setup() {
1110
createCanvas(710, 400);
12-
// Create object
11+
// 创造物件
1312
bug = new Jitter();
1413
}
1514

@@ -19,7 +18,7 @@ function draw() {
1918
bug.display();
2019
}
2120

22-
// Jitter class
21+
// Jitter
2322
class Jitter {
2423
constructor() {
2524
this.x = random(width);

src/data/examples/zh-Hans/11_Objects/02_Multiple_Objects.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
/*
2-
* @name Multiple Objects
3-
* @description Create a Jitter class, instantiate multiple objects,
4-
* and move it around the screen.
2+
* @name 多个物件
3+
* @description 创建一个 Jitter 类,实例化多个物件,并且在屏幕上移动。
54
*/
65

7-
let bug1; // Declare objects
6+
let bug1; // 声明物件
87
let bug2;
98
let bug3;
109
let bug4;
1110

1211
function setup() {
1312
createCanvas(710, 400);
14-
// Create object
13+
// 创造物件
1514
bug1 = new Jitter();
1615
bug2 = new Jitter();
1716
bug3 = new Jitter();
@@ -30,7 +29,7 @@ function draw() {
3029
bug4.display();
3130
}
3231

33-
// Jitter class
32+
// Jitter
3433
class Jitter {
3534
constructor() {
3635
this.x = random(width);

src/data/examples/zh-Hans/11_Objects/03_Objects_Array.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
/*
2-
* @name Array of Objects
3-
* @description Create a Jitter class, instantiate an array of objects
4-
* and move them around the screen.
2+
* @name 物件数组
3+
* @description 创建一个 Jitter 类,实例化多个物件,并且在屏幕上移动。
54
*/
65

7-
let bugs = []; // array of Jitter objects
6+
let bugs = []; // Jitter 物件的数组
87

98
function setup() {
109
createCanvas(710, 400);
11-
// Create objects
10+
// 创造物件
1211
for (let i = 0; i < 50; i++) {
1312
bugs.push(new Jitter());
1413
}
@@ -22,7 +21,7 @@ function draw() {
2221
}
2322
}
2423

25-
// Jitter class
24+
// Jitter
2625
class Jitter {
2726
constructor() {
2827
this.x = random(width);

src/data/examples/zh-Hans/11_Objects/03_Objects_Optional_Arguments.js

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
/*
2-
* @name Objects 2
3-
* @description Ported from example by hbarragan. Move the cursor across the
4-
* image to change the speed and positions of the geometry. The class MRect
5-
* defines a group of lines.
2+
* @name 物件 2
3+
* @description 转自 hbarragan 的范例。在图像上移动光标以更改几何图形的速度和位置。
4+
* MRect 类定义了一组线。
65
*/
76

87
let r1, r2, r3, r4;
@@ -33,12 +32,12 @@ function draw() {
3332

3433
class MRect {
3534
constructor(iw, ixp, ih, iyp, id, it) {
36-
this.w = iw; // single bar width
37-
this.xpos = ixp; // rect xposition
38-
this.h = ih; // rect height
39-
this.ypos = iyp; // rect yposition
40-
this.d = id; // single bar distance
41-
this.t = it; // number of bars
35+
this.w = iw; // 单线条宽度
36+
this.xpos = ixp; // rect x 值
37+
this.h = ih; // rect 高度
38+
this.ypos = iyp; // rect y 值
39+
this.d = id; // 单线条间距
40+
this.t = it; // 单线条数量
4241
}
4342

4443
move(posX, posY, damping) {

src/data/examples/zh-Hans/11_Objects/04_Inheritance.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
/* @name Inheritance
2-
* @description A class can be defined using another class as a
3-
* foundation. In object-oriented programming terminology, one class can
4-
* inherit fields and methods from another. An object that inherits from
5-
* another is called a subclass, and the object it inherits from is called
6-
* a superclass. A subclass extends the superclass.
1+
/* @name 继承 (Inheritance)
2+
* @description 可以用一个类作为基础来定义另一个类。在面向对象的编程术语中,
3+
* 一个类可以继承另一个类的字段 (fields) 和方法 (methods)。
4+
* 从另一个物件继承了的物件称为子类 (subclass),其继承的物件称为基类 (superclass)。
5+
* 子类扩展基类。
76
*/
87
let spots, arm;
98

src/data/examples/zh-Hans/11_Objects/05_Composite_Objects.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
/* @name Composite Objects
2-
* @description An object can include several other objects.
3-
* Creating such composite objects is a good way to use the principles
4-
* of modularity and build higher levels of abstraction within a program.
1+
/* @name 复合物件
2+
* @description 一个物件可以包含多个其他物件。
3+
* 创造复合物件是使用模块性和程序中构建更高级别的抽象的好方法。
54
*/
65
let er1, er2;
76

0 commit comments

Comments
 (0)