Comments (1)
Another possibility here (which would just work on JS) would be to do something similar to Tyrian's HotReload
In this case, there would be something like:
class HotReloadRenderLoop[S](decodeState: String => Option[S], encodeState: S => String) {
private def loadState(): Option[S] =
Option(dom.window.localStorage.getItem(key)).flatMap(decodeState)
private def saveState(state: S): String =
dom.window.localStorage.setItem(key, encodeState(state))
def run(runner: LoopRunner, canvasManager: CanvasManager, canvasSettings: Canvas.Settings, initialState: S) = {
val canvas = canvasManager.init(canvasSettings)
runner
.finiteLoop(
(state: S) => renderFrame(canvas, state).tap(saveState),
(newState: S) => terminateWhen(newState) || !canvas.isCreated(),
frameRate,
() => if (canvas.isCreated()) canvas.close()
)
.run(loadState().getOrElse(initialState))
}
}
I think that with some adjustments, it might also be able to plug this logic into the PureRenderLoop
without a ton of work.
from minart.
Related Issues (20)
- Fix janky rendering on scaled HTML canvas
- Convert examples to scala-cli
- Add audio support
- Add instructions on how to compile native applications on windows HOT 3
- Improve FullScreen ergonomics
- Add GamePad support HOT 1
- Fix cross-compilation in examples
- Provide cross-platform ExecutionContext
- Fix audio sync problems in Firefox
- Surface#fillRegion implementations should check bounds
- Set sbt versionScheme
- Stereo sound output
- Alpha channel support HOT 1
- Replace scala.math with java.lang.math
- Add Skia backends HOT 1
- Add Android Support HOT 3
- Remove dependency on scalanative-graphics-bindings HOT 2
- Publish scaladoc HOT 1
- Fix Java Renderling in Linux HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from minart.