1.11 Concepts 概念 - States & Pulses 狀態和脈沖


States help remember information in your prototype. Pulses are used to tell patches to perform an action. Understanding how these work together will help you be more effective at building Origami prototypes.

狀態幫助記住原型中信息。脈沖用來告訴模塊反饋哪個動作。了解這些工作方式有助于更有效地構建原型。

板栗:跟電路圖其實差不多。【打開開關 → 電流通過 → 點亮燈泡】:打開 = 交互和操作模塊;開關 = 交互對象模塊;電流通過 = 發送脈沖;點亮燈泡 = 切換為定義的狀態。


States 狀態

A state is a value that persists over time. The simplest version of state is in the Switch patch. Switches are either on or off, and they remain that way until you tell them otherwise.

狀態是一個值持續的時間。板栗:也就字面意思,跟“今天狀態不好,昨天狀態特別好”一個意思.

舉個例子,最簡單的能實現狀態切換的模塊是 Switch 開關 模塊。在沒有 打開關閉 前,狀態是會保持不變的。

If we look at a state as it changes over time, it might look something like this:

假設開關本來是一個關閉,我們在 Frame 5 那里點了下開關,那狀態圖形化之后可能看起來是下面圖中那樣:

A switch is off until you turn it on. You can see the state goes from off to on immediately in a single frame. A frame is usually 1/60th of a second.

可以看到狀態 Frame 1~4 是關閉的,Frame 5 之后開啟了。
一個幀通常是1/60秒。板栗:這句不用管了,這里說還挺干擾的...

Pulses 脈沖

While state persists over time, pulses are On ? only for a single frame. The value of the cable sending the pulse is otherwise off.
A pulse over time looks like this:

狀態是一個持續時間,脈沖就不是,脈沖只持續一幀,把信息發送到了就撤了。 否則,這條線路就被占用了不能在發送其他的脈沖了。
狀態的可視化圖形大概就下面這樣的:

our can see that pulses are only On ? for a single frame.
They're used to tell patches to perform an action, like telling a Switch to turn on or turn off. They're also useful for passing along user interactions like tapping on the screen or pressing a key on the keyboard.

可以在圖上看到脈沖只在 Frame 5 上顯示了一下。用于告訴模塊 趕緊的切換狀態啊!,打開或關閉開關。
脈沖還可用于傳遞用戶交互,例如在屏幕上點擊或按鍵盤上的鍵。
板栗:其實吧我覺得所有的信息都是通過脈沖傳遞的。


Examples of State & Pulses 狀態和脈沖的例子

  • The [Switch] patch outputs the state of the switch (on / off) and accepts pulses to flip the switch, turn it on, or turn it off.

  • Switch 模塊接收一個交互模塊發出的脈沖,根據指令輸出開關的狀態將其打開或關閉。

  • The Interaction patch has Down and Tap outputs. Down represents the state of whether the finger is currently down on the screen. The Tap port outputs a pulse when the finger is released from the screen.

  • Interaction 模塊有 Down 和 Tap 輸出口。Down 表示手指在屏幕上按下時的狀態,按下時輸出脈沖。Tap 表示手指在屏幕上按下 - 松開時的狀態,松開輸出脈沖。

  • The Counter patch outputs the state of the counter (the number value) and accepts pulses to increase it or decrease it.

Counter 模塊輸出計數器的狀態(數值)并接受來自其他模塊的脈沖增加或減少數值。


Creating Pulses from State 給狀態創建一個脈沖

There are a couple ways to create a pulse from state. The more explicit way is to use the Pulse patch. The Pulse patch accepts a state called On/Off and will output a pulse on the Turned On port when the state turns on and the Turned Off port when the state turns off. This is an example that flips a switch the moment the user touches the screen.

有幾種方法從狀態創建脈沖。 更明確的方法是使用[Pulse]模塊。 [Pulse]模塊接受一個稱為On / Off的狀態,并在狀態打開時在Turned On端口輸出脈沖,當狀態關閉時,將輸出Turned Off端口的脈沖。 這是在用戶觸摸屏幕的瞬間翻轉開關的示例。

試了個加Pulse模塊的跟不加的也沒區別啊!!

Another way is to infer a state change is to connect a state directly to a port accepting a pulse. What'll happen is the port that accepts a pulse will look to when the state changes from off to on, and at that moment infer a pulse. So if you wanted a switch to flip when the user's finger touches down on the screen, you can connect the Down port directly to the Switch's Flip port, without needing to use a Pulse patch.

這兩節不懂

Temporary State with the Delay patch 臨時狀態和 Delay 模塊

Sometimes you need a state to turn on for a few moments and then turn off. For example, say you were making a confirmation window appear for a couple seconds after the user pressed a button. You could do this using a Switch, but then you'd need to build logic that turns the switch off after some time. A simpler way to do this is to use the Delay patch.

有時你需要一個狀態打開一會兒,然后自動關閉。
這里假設一個交互,用戶按下按鈕后出現確認窗口幾秒鐘,然后自動關閉。
可以使用 Switch 模塊來做到這一點,但是你需要建立“在一段時間后關閉開關”的邏輯,一個更簡單的方法是使用 ** Delay D **模塊替換 Switch。

The Delay patch can take state that's changing and delay the change by an amount of time you specify. You can also tell it whether to only delay increasing (off to on) or decreasing (on to off) changes. If you give a Delay patch a pulse as input, you can delay the change from on to off, extending the pulse for any amount of time you'd like.

Delay 模塊可以采取正在更改的狀態,并將更改延遲時間設置為指定的值。還可以定義類型是有操作就激活,還是只在關閉到打開或打開到關閉時更改。



?? Coordinates 坐標 ? Patches 模塊 - Animation 動畫 - Bouncy Converter ??

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市,隨后出現的幾起案子,更是在濱河造成了極大的恐慌,老刑警劉巖,帶你破解...
    沈念sama閱讀 230,106評論 6 542
  • 序言:濱河連續發生了三起死亡事件,死亡現場離奇詭異,居然都是意外死亡,警方通過查閱死者的電腦和手機,發現死者居然都...
    沈念sama閱讀 99,441評論 3 429
  • 文/潘曉璐 我一進店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人,你說我怎么就攤上這事。” “怎么了?”我有些...
    開封第一講書人閱讀 178,211評論 0 383
  • 文/不壞的土叔 我叫張陵,是天一觀的道長。 經常有香客問我,道長,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 63,736評論 1 317
  • 正文 為了忘掉前任,我火速辦了婚禮,結果婚禮上,老公的妹妹穿的比我還像新娘。我一直安慰自己,他們只是感情好,可當我...
    茶點故事閱讀 72,475評論 6 412
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著,像睡著了一般。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發上,一...
    開封第一講書人閱讀 55,834評論 1 328
  • 那天,我揣著相機與錄音,去河邊找鬼。 笑死,一個胖子當著我的面吹牛,可吹牛的內容都是我干的。 我是一名探鬼主播,決...
    沈念sama閱讀 43,829評論 3 446
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了?” 一聲冷哼從身側響起,我...
    開封第一講書人閱讀 43,009評論 0 290
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎,沒想到半個月后,有當地人在樹林里發現了一具尸體,經...
    沈念sama閱讀 49,559評論 1 335
  • 正文 獨居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內容為張勛視角 年9月15日...
    茶點故事閱讀 41,306評論 3 358
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發現自己被綠了。 大學時的朋友給我發了我未婚夫和他白月光在一起吃飯的照片。...
    茶點故事閱讀 43,516評論 1 374
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖,靈堂內的尸體忽然破棺而出,到底是詐尸還是另有隱情,我是刑警寧澤,帶...
    沈念sama閱讀 39,038評論 5 363
  • 正文 年R本政府宣布,位于F島的核電站,受9級特大地震影響,放射性物質發生泄漏。R本人自食惡果不足惜,卻給世界環境...
    茶點故事閱讀 44,728評論 3 348
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧,春花似錦、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 35,132評論 0 28
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至,卻和暖如春,著一層夾襖步出監牢的瞬間,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 36,443評論 1 295
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人。 一個月前我還...
    沈念sama閱讀 52,249評論 3 399
  • 正文 我出身青樓,卻偏偏與公主長得像,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當晚...
    茶點故事閱讀 48,484評論 2 379

推薦閱讀更多精彩內容