考虑一个模型:
model : Signal Model
以及以下2个信号:
clickPosition = Mouse.position
|> Signal.sampleOn Mouse.clicks
和
dimensions = Window.dimensions
我想获得以下desiredSignal
:
(0,0) (30,20) (60,70)
clickPosition +------------+---------------------+---------
M0 M1 M2 M3
model +----+-------------------+------+------------
(600,800) (400,300) (200,800)
dimensions +-----------------+----------+---------------
D1 D2 D3
desiredSignal +------------+---------------------+---------
where:
D1 = ((0,0), M0, (600,800))
D2 = ((30,20), M1, (600,800))
D3 = ((60,70), M3, (200,800))
即。我想样本clickPosition
,但保留采样值。
我怎么能这样做?
答案 0 :(得分:3)
看起来你的desiredSignal
是三个信号的最新值,tupled,但只是改变clickPosition
信号的变化。您可以先组合它们,然后对clickPosition
信号进行采样:
desiredSignal =
Signal.map3 (,,) clickPosition model dimensions
|> Signal.sampleOn clickPosition