-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Canvas interactivity and Game of Life example #325
Conversation
6e9584e
to
f2e63f1
Compare
f2e63f1
to
0a5f1bb
Compare
@clarkmoody I have implemented cursor-based zooming and increased the speed limit to
The lag is somewhat expected as the
If the tick rate is higher than the refresh rate of your monitor, there are states of the simulation you will not see. New cells will also immediately die after drawing them, given the rules of the game. |
Excellent! Tested and works at e7e8e76 |
This seems to produce a 2x speedup.
Also allow toggling the grid lines
I have made the simulation run in a background thread and also implemented some logic to avoid ticks from accumulating. The GUI now will stay responsive even if the simulation cannot keep up with the requested tick rate! Additionally, I have:
I am pretty happy with this example and I believe we are ready to merge! 🎉 |
This PR adds interactivity support for the
Canvas
widget and simplifies its API.A
Canvas
is now created with a value implementing the newProgram
trait. AProgram
contains the local state of theCanvas
, describes itsupdate
anddraw
logic, and can produce meaningful messages.The
Layer
andDrawable
traits have been removed as they added an unnecessary level of indirection to the drawing API. Drawing now consists in directly generating a bunch ofGeometry
with aFrame
orCache
in theProgram::draw
method. Users should be able to create any further drawing abstractions on top of this API to satisfy specific use cases.The changes to the canvas API triggered a bunch of refactors and internal improvements, affecting a considerable part of the codebase. Specifically:
Rectangle
,Point
,Vector
, andStroke
.mouse
types oficed_native
have been moved toiced_core
.Translate
was added toiced_wgpu
.Mesh2D
primitive has now asize
field and any geometry that falls out of bounds is clipped.MouseCursor
has been renamed tomouse::Interaction
with a newCrosshair
variant.Input
variant inkeyboard::Event
andmouse::Event
has been split into explicit pressed and released variants.time
module has been created, which is only exposed when either thetokio
orasync-std
features are enabled. This module currently only exposes anevery
function that returns aSubscription
that produces messages at a set interval. This simplifies some examples considerably!bezier_tool
example has been updated to also use aCanvas
widget instead of a custom one.As always, I have implemented a new example to showcase the new features. The new
game_of_life
example implements an interactive version of Conway's Game of Life on top of the new canvas API!