Dosen原創
這是我學習quartz composer,Origami,看官方文檔翻譯下來的,每天一篇,有不準確的地方希望能指出,一起交流進步。轉載請與我聯系,擅自轉載視作侵權。
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.
狀態幫你記錄原型的信息。脈沖用來告訴原型執行一個動作。理解他們如何配合使用會幫你在建立Origami原型時提高效率。
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模塊。Switches也是開或關,并且如果你不告訴它們,它們會保持這種狀態。
If we look at a state as it changes over time, it might look something like this:
如果我們看到一個狀態改變并持續,它看起來或許像這樣:
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.
一個switch是關的,直到你將它打開。你可以看到狀態是是立即在一幀從關進入開。一幀通常是一秒的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:
脈沖持續的這段時間看起來像是:
You 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.
它們經常用來告訴模塊去執行一個動作,就像告訴一個開關是打開或關閉。它們經常對于沿著用戶的交互,像點擊屏幕或按一個鍵盤上的鍵是很有用的。
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 2 patch has Down and Up outputs. Down represents the state of whether the finger is currently down on the screen. The Up port outputs a pulse when the finger is released from the screen.
Interaction 2模塊有下和上兩個輸出。Down代表手指當前在屏幕是按下的狀態。當手指從屏幕上抬起時Up接口輸出一個脈沖。
The Counter 2 patch outputs the state of the counter (the number value) and accepts pulses to increase it or decrease it.
Counter 2 模塊輸出計數器的狀態(一個數值)并且接受脈沖去增加它或者減少它。
The Scroll patch outputs the state of the scroller like its current position and page, and accepts pulses to have it jump to a specific position.
Scroll 模塊輸出滾動的狀態,比如它當前的位置,頁數,并且接受脈沖使它跳轉到一個特定的位置。
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 Input Signal. If the Detection Mode is set to Leading, it will output a pulse when the state changes from off to on. If the mode is set to Trailing, it will output a pulse when the state changes from on to off.
有幾種方式可以為狀態創建一個脈沖。最直接的方法是使用脈沖模塊。脈沖模塊允許一個狀態調用Input Signal(輸入信號),如果監測方式設為前置,當狀態從關改變為開時會輸出一個脈沖。如果方式為后置,當狀態從開改變為關時會輸出一個脈沖。
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 the moment the users finger went down on the screen, you could connect the Down port directly to the Switch's Flip port, without needing to use a Pulse patch.
另一個能推理一個狀態改變的方法是直接讓連接一個狀態的接口允許脈沖。允許脈沖的接口會發生什么,要看當狀態從關到開改變時,在這一刻來推斷脈沖。所以如果你想在用戶手指落在屏幕上的時候轉換開關,你可以連接Down接口直接到Switch模塊的Flip接口,不需要使用Pulse模塊。
Transient State with the Delay patch ? ? ? 過渡狀態和延時模塊
Sometimes you need a state to go from off to on for a few moments and then back to 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 D patch.
有時候你需要一個狀態在短時間內從關到開,然后再回到關。例如,當用戶按下一個按鈕后,你使一個確認彈窗只出現幾秒。你可以使用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.
延時模塊可以使狀態在你指定的一些時間改變或延時改變。你也可以告訴它是否是只延時增加(關到開)或減少(開到關)的改變如果你給延時模塊一個脈沖作為輸入,你可以讓從開到關的改變延時,并任意延長脈沖的時間。