Skip to content

Commit b2026d7

Browse files
authored
Merge pull request #724 from sm7515/chinese_translate
Translated Instance Mode Section to Chinese
2 parents e5ae80e + 0080e52 commit b2026d7

File tree

2 files changed

+16
-21
lines changed

2 files changed

+16
-21
lines changed

src/data/examples/zh-Hans/15_Instance_Mode/01_Instantiating.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
/*
2-
* @name Instantiation
3-
* @description Create a p5 instance, which keeps all variables
4-
* out of the global scope of your page.
2+
* @name 创建实例
3+
* @description 创建一个 p5 实例,以便让所有变量在全局作用域之外。
54
*/
6-
let sketch = function(p) {
5+
let sketch = function (p) {
76
let x = 100;
87
let y = 100;
98

10-
p.setup = function() {
9+
p.setup = function () {
1110
p.createCanvas(700, 410);
1211
};
1312

14-
p.draw = function() {
13+
p.draw = function () {
1514
p.background(0);
1615
p.fill(255);
1716
p.rect(x, y, 50, 50);
@@ -20,7 +19,7 @@ let sketch = function(p) {
2019

2120
let myp5 = new p5(sketch);
2221

23-
// Compare to "global mode"
22+
// “全局模式” 作为对照
2423
// let x = 100;
2524
// let y = 100;
2625

src/data/examples/zh-Hans/15_Instance_Mode/02_Instance_Container.js

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
/*
22
* @norender
3-
* @name Instance Container
4-
* @description Optionally, you can specify a default container for the canvas
5-
* and any other elements to append to with a second argument. You can give the
6-
* ID of an element in your html, or an html node itself.
3+
* @name 实例容器
4+
* @description 第二个参数可以是你指定作为画布的默认容器,也可以是任何
5+
你想要添加此 p5 实例容器至的元素。可以是带 ID 的 html 元素, 也可以是 html 节点本身。
76
*
8-
* Here are three different options for selecting a container
9-
* DOM element. All DOM elements (canvas, buttons, divs, etc) created by p5
10-
* will be attached to the DOM element specified as the second argument to the
11-
* p5() call.
7+
* 以下列举了三种选择 DOM 元素作为容器的方法。
8+
* 所有由 p5 创建的 DOM 元素(画布,按钮,div 等)都会被添加到指定的 DOM 元素上,
9+
* 这个指定元素就是调用 p5() 时传递的第二个参数。
1210
*/
13-
<!-- pass in the ID of the container element -->
11+
<!-- 传递容器元素的 ID -->
1412
<!DOCTYPE html>
1513
<head>
1614
<script src='p5.js'></script>
@@ -30,7 +28,7 @@
3028
</html>
3129

3230

33-
<!-- pass in a pointer to the container element -->
31+
<!-- 传递指向容器元素的指标 -->
3432
<!DOCTYPE html>
3533
<head>
3634
<script src='p5.js'></script>
@@ -50,8 +48,7 @@
5048
</html>
5149

5250

53-
<!-- create an element, attach it to the body,
54-
and pass in a pointer -->
51+
<!-- 创建一个元素,添加至 body 并传递指标 -->
5552
<!DOCTYPE html>
5653
<head>
5754
<script src='p5.js'></script>
@@ -72,8 +69,7 @@ and pass in a pointer -->
7269
</html>
7370

7471

75-
<!-- create an element, pass in a pointer,
76-
and attach it to the body -->
72+
<!-- 创建一个元素,传递指针并添加到 body -->
7773
<!DOCTYPE html>
7874
<head>
7975
<script src='p5.js'></script>

0 commit comments

Comments
 (0)