Skip to content

Commit 99ec216

Browse files
committed
Merge branch 'Qianqianye-master'
2 parents aa7ba15 + ee6eb8f commit 99ec216

File tree

29 files changed

+383
-325
lines changed

29 files changed

+383
-325
lines changed

dist/assets/examples/zh-Hans/03_Arrays/00_Array.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
/*
2-
* @name Array
3-
* @description An array is a list of data. Each piece of data in an array
4-
* is identified by an index number representing its position in
5-
* the array. Arrays are zero based, which means that the first
6-
* element in the array is [0], the second element is [1], and so on.
7-
* In this example, an array named "coswave" is created and
8-
* filled with the cosine values. This data is displayed three
9-
* separate ways on the screen.
2+
* @name 数组
3+
* @description 数组是数据列表。数组中的每条数据由表示其在数组中的位置的索引号标识。
4+
* 数组基于零,这意味着数组中的第一个元素是[0],第二个元素是[1],依此类推。
5+
* 在此示例中,一个名为 “coswave” 的数组被创建并使用余弦值填充。此数据在屏幕上以三种不同的方式显示。
106
*/
117
var coswave = [];
128

dist/assets/examples/zh-Hans/03_Arrays/01_Array_2d.js

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
/*
2-
* @name Array 2D
3-
* @description Demonstrates the syntax for creating a two-dimensional (2D)
4-
* array. Values in a 2D array are accessed through two index values.
5-
* 2D arrays are useful for storing images. In this example, each dot
6-
* is colored in relation to its distance from the center of the image.
2+
* @name 2D 数组
3+
* @description 演示创建二维(2D)数组的句法。 2D 数组中的值是通过两个索引值来访问的。
4+
* 2D 阵列特别适用于对于存储图像。在该示例中,每个点是通过其相对于距图像中心的距离来进行着色的。
75
*/
86
var distances = [];
97
var maxDistance;
@@ -13,22 +11,19 @@ function setup() {
1311
createCanvas(720, 360);
1412
maxDistance = dist(width/2, height/2, width, height);
1513
for (var x = 0; x < width; x++) {
16-
distances[x] = []; // create nested array
14+
distances[x] = []; // 创建嵌套数组
1715
for (var y = 0; y < height; y++) {
1816
var distance = dist(width/2, height/2, x, y);
1917
distances[x][y] = distance/maxDistance * 255;
2018
}
2119
}
2220
spacer = 10;
23-
noLoop(); // Run once and stop
21+
noLoop(); // 执行一次之后停止
2422
}
2523

2624
function draw() {
2725
background(0);
28-
// This embedded loop skips over values in the arrays based on
29-
// the spacer variable, so there are more values in the array
30-
// than are drawn here. Change the value of the spacer variable
31-
// to change the density of the points
26+
// 这个嵌入式循环基于 spacer 变量跳过数组中的值,因此数组中的值多于此处绘制的值。更改 spacer 变量的值可以更改点的密度
3227
for (var x = 0; x < width; x += spacer) {
3328
for (var y = 0; y < height; y += spacer) {
3429
stroke(distances[x][y]);

dist/assets/examples/zh-Hans/03_Arrays/02_Array_Objects.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
2-
* @name Array Objects
3-
* @description Demonstrates the syntax for creating an array of custom objects.
2+
* @name 数组对象
3+
* @description 演示创建自定义对象数组的句法。
44
*/
55
var unit = 40;
66
var count;

dist/assets/examples/zh-Hans/04_Control/00_Iteration.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
2-
* @name Iteration
3-
* @description Iteration with a "for" structure to construct repetitive forms.
2+
* @name 迭代
3+
* @description 用 “for” 结构迭代来构造重复的形式。
44
*/
55
var y;
66
var num = 14;
@@ -11,15 +11,15 @@ function setup() {
1111
background(102);
1212
noStroke();
1313

14-
// Draw white bars
14+
// 画白条
1515
fill(255);
1616
y = 60;
1717
for(var i = 0; i < num/3; i++) {
1818
rect(50, y, 475, 10);
1919
y+=20;
2020
}
2121

22-
// Gray bars
22+
// 灰条
2323
fill(51);
2424
y = 40;
2525
for(var i = 0; i < num; i++) {
@@ -32,7 +32,7 @@ function setup() {
3232
y += 20;
3333
}
3434

35-
// Thin lines
35+
// 细线
3636
y = 45;
3737
fill(0);
3838
for(var i = 0; i < num-1; i++) {

dist/assets/examples/zh-Hans/04_Control/01_Embedded_Iteration.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
2-
* @name Embedded Iteration
3-
* @description Embedding "for" structures allows repetition in two dimensions.
2+
* @name 嵌入式迭代
3+
* @description 嵌入 “for” 结构允许在两个维度上进行重复。
44
*/
55
function setup() {
66

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
11
/*
2-
* @name Conditionals 1
3-
* @description Conditions are like questions.
4-
* They allow a program to decide to take one action if
5-
* the answer to a question is true or to do another action
6-
* if the answer to the question is false.
7-
* The questions asked within a program are always logical
8-
* or relational statements. For example, if the variable 'i' is
9-
* equal to zero then draw a line.
2+
* @name 条件 1
3+
* @description 条件就像问题。
4+
* 如果问题的答案为真值,它们允许程序决定采取一个动作;如果问题的答案为假值,则允许程序执行另一个动作。
5+
* 程序中提出的问题始终是逻辑或关系语句。例如,如果变量 'i' 等于零,则绘制一条线。
106
*/
117
function setup() {
128

13-
createCanvas(720, 360);
9+
createCanvas(720, 360);
1410
background(0);
1511

1612
for(var i = 10; i < width; i += 10) {
@@ -21,7 +17,7 @@ function setup() {
2117
line(i, 80, i, height/2);
2218
} else {
2319
stroke(153);
24-
line(i, 20, i, 180);
20+
line(i, 20, i, 180);
2521
}
2622
}
2723
}

dist/assets/examples/zh-Hans/04_Control/03_Conditionals_2.js

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,24 @@
11
/*
2-
* @name Conditionals 2
3-
* @description We extend the language of conditionals from the previous
4-
* example by adding the keyword "else". This allows conditionals
5-
* to ask two or more sequential questions, each with a different
6-
* action.
2+
* @name 条件 2
3+
* @description 我们通过添加关键字 “else” 来扩展前一个示例中的条件语言。
4+
* 这允许条件连续提出两个或更多个问题,每个问题都有不同的操作。
75
*/
86
function setup() {
97

10-
createCanvas(720, 360);
8+
createCanvas(720, 360);
119
background(0);
1210

1311
for(var i = 2; i < width-2; i += 4) {
14-
// If 'i' divides by 20 with no remainder
12+
// 如果 'i' 除以 20 而没有余数
1513
if((i % 20) == 0) {
1614
stroke(255);
1715
line(i, 80, i, height/2);
18-
// If 'i' divides by 10 with no remainder
16+
// 如果 'i' 除以 10 而没有余数
1917
} else if ((i % 10) == 0) {
2018
stroke(153);
21-
line(i, 20, i, 180);
22-
// If neither of the above two conditions are met
23-
// then draw this line
24-
} else {
19+
line(i, 20, i, 180);
20+
// 如果上述两个条件都不满足,则绘制这条线
21+
} else {
2522
stroke(102);
2623
line(i, height/2, i, height-20);
2724
}

dist/assets/examples/zh-Hans/04_Control/04_Logical_Operators.js

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,39 @@
11
/*
2-
* @name Logical Operators
3-
* @description The logical operators for AND (&&) and OR (||) are used to
4-
* combine simple relational statements into more complex expressions.
5-
* The NOT (!) operator is used to negate a boolean statement.
2+
* @name 逻辑操作符
3+
* @description AND(&&)和 OR(||)的逻辑操作符被用于将简单的关系语句组合成更复杂的表达式
4+
* NOT (!) 操作符被用于否定布尔语句。
65
*/
76
var test = false;
87

98
function setup() {
109

11-
createCanvas(720, 360);
10+
createCanvas(720, 360);
1211
background(126);
1312

1413
for (var i = 5; i <= height; i += 5) {
15-
// Logical AND
14+
// 逻辑 AND
1615
stroke(0);
1716
if((i > 35) && (i < 100)) {
1817
line(width/4, i, width/2, i);
1918
test = false;
2019
}
21-
22-
// Logical OR
20+
21+
// 逻辑 OR
2322
stroke(76);
2423
if ((i <= 35) || (i >= 100)) {
2524
line(width/2, i, width, i);
2625
test = true;
2726
}
28-
29-
// Testing if a boolean value is "true"
30-
// The expression "if(test)" is equivalent to "if(test == true)"
27+
28+
// 测试布尔值是否为 “true
29+
// 表达式 “if(test)” 等同于 "if(test == true)"
3130
if (test) {
3231
stroke(0);
3332
point(width/3, i);
3433
}
35-
36-
// Testing if a boolean value is "false"
37-
// The expression "if(!test)" is equivalent to "if(test == false)"
34+
35+
// 测试布尔值是否为 "false"
36+
// 表达式 “if(test)” 等同于 "if(test == false)"
3837
if (!test) {
3938
stroke(255);
4039
point(width/4, i);

dist/es/examples/index.html

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ <h3 name='arrays' class='anchor'>Arreglos</h3>
370370

371371
data-es='Arreglo'
372372

373-
data-zh-Hans='Array'
373+
data-zh-Hans='数组'
374374

375375
>Array</a><br>
376376

@@ -381,7 +381,7 @@ <h3 name='arrays' class='anchor'>Arreglos</h3>
381381

382382
data-es='Arreglo 2D'
383383

384-
data-zh-Hans='Array 2D'
384+
data-zh-Hans='2D 数组'
385385

386386
>Array 2D</a><br>
387387

@@ -392,7 +392,7 @@ <h3 name='arrays' class='anchor'>Arreglos</h3>
392392

393393
data-es='Arreglo de objetos'
394394

395-
data-zh-Hans='Array Objects'
395+
data-zh-Hans='数组对象'
396396

397397
>Array Objects</a><br>
398398

@@ -409,7 +409,7 @@ <h3 name='control' class='anchor'>Control</h3>
409409

410410
data-es='Iteración'
411411

412-
data-zh-Hans='Iteration'
412+
data-zh-Hans='迭代'
413413

414414
>Iteration</a><br>
415415

@@ -420,7 +420,7 @@ <h3 name='control' class='anchor'>Control</h3>
420420

421421
data-es='Iteración anidada'
422422

423-
data-zh-Hans='Embedded Iteration'
423+
data-zh-Hans='嵌入式迭代'
424424

425425
>Embedded Iteration</a><br>
426426

@@ -431,7 +431,7 @@ <h3 name='control' class='anchor'>Control</h3>
431431

432432
data-es='Condicionales 1'
433433

434-
data-zh-Hans='Conditionals 1'
434+
data-zh-Hans='条件 1'
435435

436436
>Conditionals 1</a><br>
437437

@@ -442,7 +442,7 @@ <h3 name='control' class='anchor'>Control</h3>
442442

443443
data-es='Condicionales 2'
444444

445-
data-zh-Hans='Conditionals 2'
445+
data-zh-Hans='条件 2'
446446

447447
>Conditionals 2</a><br>
448448

@@ -453,7 +453,7 @@ <h3 name='control' class='anchor'>Control</h3>
453453

454454
data-es='Operadores lógicos'
455455

456-
data-zh-Hans='Logical Operators'
456+
data-zh-Hans='逻辑操作符'
457457

458458
>Logical Operators</a><br>
459459

0 commit comments

Comments
 (0)