Skip to content

Commit 57a5e41

Browse files
committed
tickle
1 parent 2cf6f5e commit 57a5e41

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/data/examples/zh-Hans/10_Interaction/10_Tickle.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
/*
22
* @name Tickle
3-
* @description The word "tickle" jitters when the cursor hovers over.
4-
* Sometimes, it can be tickled off the screen.
3+
* @description "tickle" 这个单词会在光标移至它时抖动。
4+
* 有时还会抖出屏幕。
55
*/
66
let message = 'tickle',
77
font,
8-
bounds, // holds x, y, w, h of the text's bounding box
8+
bounds, // 存储文本框的 x, y, w, h
99
fontsize = 60,
1010
x,
11-
y; // x and y coordinates of the text
11+
y; // 文本的 x 和 y 坐标
1212

1313
function preload() {
1414
font = loadFont('assets/SourceSansPro-Regular.otf');
@@ -17,11 +17,11 @@ function preload() {
1717
function setup() {
1818
createCanvas(710, 400);
1919

20-
// set up the font
20+
// 设置字体
2121
textFont(font);
2222
textSize(fontsize);
2323

24-
// get the width and height of the text so we can center it initially
24+
// 获取文本的宽度和高度,以便我们可以首先将其居中
2525
bounds = font.textBounds(message, 0, 0, fontsize);
2626
x = width / 2 - bounds.w / 2;
2727
y = height / 2 - bounds.h / 2;
@@ -30,12 +30,12 @@ function setup() {
3030
function draw() {
3131
background(204, 120);
3232

33-
// write the text in black and get its bounding box
33+
// 写出黑色的文本并获取其文本框
3434
fill(0);
3535
text(message, x, y);
3636
bounds = font.textBounds(message, x, y, fontsize);
3737

38-
// check if the mouse is inside the bounding box and tickle if so
38+
// 检查鼠标是否在文本框里;如果在,抖动文本
3939
if (
4040
mouseX >= bounds.x &&
4141
mouseX <= bounds.x + bounds.w &&

0 commit comments

Comments
 (0)