1

考虑一个模型:

model : Signal Model

以及以下两个信号:

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))

即我想 sampleOn clickPosition,但保留采样值。

我怎么能那样做?

4

1 回答 1

3

看起来你desiredSignal是三个信号的最新值,元组,但只会随着clickPosition信号的变化而变化。您可以通过首先组合它们,然后对clickPosition信号进行采样来做到这一点:

desiredSignal =
  Signal.map3 (,,) clickPosition model dimensions
  |> Signal.sampleOn clickPosition
于 2015-11-04T11:02:44.433 回答