On 06/06/2013, at 6:08 PM, Francesco Mazzoli wrote:
> At Thu, 6 Jun 2013 12:52:59 +1000,
> Ben Lippmeier wrote:
>> Improvements most welcome, provided they don't complicate the existing
>> API. I considered adding an extra flag to the Display type to enable panning
>> and zooming, but then `Display` becomes more like a `Configuration` type
>> that doesn't just represent the shape of the output window.
>>
>> Perhaps you could factor out the viewport handling code into a separate
>> module. Maybe make a module Graphics.Gloss.Data.ViewPort and have functions
>> like:
>>
>> updateViewStateWithEvents :: [Event] -> ViewState -> ViewState
>> viewPortOfViewState :: ViewState -> ViewPort
>> applyViewPortToPicture :: ViewPort -> Picture -> Picture
>>
>> With those functions it would be easy for the client programmer to add
>> viewport handling to their own code just by using the existing 'play'
>> interface, and the ViewPort code itself would be cleaner.
>>
>> Thoughts?
>
> That sounds fine. I’m quite busy now but I’ll send some darcs patches when I
> get around writing it.
>
> I guess that then it would be better to change the other ViewPort-using
> interfaces (Simulate, Animate, ...) to use the high-level API, right?
I think the Simulate and Animate API modes should provide viewport handling automatically, but the implementation of all should use the same code, yes.
Ben.