Coder Social home page Coder Social logo

scala-view's Introduction

scala-view

This is a small Scala library for animating a Stream of Images on-screen in a separate window managed by your window manager. It works with both ScalaFX Images (recommended) and Scala Swing/AWT BufferedImages (legacy). The stream of images is animated in a window with some simple controls to start and stop the animation, and to turn on and off the saving of image frames to disk (typically for the purpose of turning the image sequence into a movie). An example of what a window might look like is given below.

Example window

Using the package (with SBT)

The binary package is published on the Central repository (AKA Maven Central), and is cross-built for Scala 2.11.x and 2.12.x. To use it with an SBT-based Scala project, add:

libraryDependencies += "com.github.darrenjw" %% "scala-view" % "0.5"

to your SBT build for the "official" release. This is recommended for new users. If you need the latest available snapshot, use

libraryDependencies += "com.github.darrenjw" %% "scala-view" % "0.6-SNAPSHOT"

and note that this will require a sonatype snapshot resolver

resolvers += "Sonatype Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots/"

Pre-built ScalaDoc API Documentation is also available.

Building from source

This is an SBT project, so building from source should be as simple as sbt package (assuming that sbt in installed and in your path). ScalaDoc documentation can be built with sbt doc, etc.

Using the package in your code

ScalaFX API (recommended)

The idea is that you create a Stream of Images (an instance of scalafx.scene.image.Image, such as a WritableImage) for your application and then visualise it by calling scalaview.SfxImageViewer(sbi) where sbi has type Stream[Image]. This allows construction of the image stream in a pure functional way. Further details can be found in the ScalaDoc (which can be built with sbt doc). Note that it is usually better to use the constructor(s) in the companion object for the SfxImageViewer rather than the default class constructor.

Examples

Examples of use can be found in the examples-sfx subdirectory.

Tutorial

There is a step-by-step tutorial for working through the construction and visualisation of a stream of images using the ScalaFX API.

Scala Swing API (legacy)

The idea is that you create a Stream of BufferedImages for your application and then visualise it by calling scalaview.SwingImageViewer(sbi) where sbi has type Stream[BufferedImage]. Further details can be found in the ScalaDoc (which can be built with sbt doc). Note that it is usually better to use the constructor(s) in the companion object for the SwingImageViewer rather than the default class constructor.

Examples

Examples of use can be found in the examples-swing subdirectory.

Turning frames into a movie

This is not really anything to do with this library, but people keep asking me how to turn a bunch of frames into a movie for incorporating into talk presentations, etc. On Ubuntu, I will often use something like:

avconv -r 10 -i siv-%06d.png movie.mp4

to create a movie at 10 frames per second.

Copyright

Copyright (C) 2016-2018 Darren J Wilkinson, released under an Apache 2 Open Source license.

scala-view's People

Contributors

darrenjw avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

scala-view's Issues

auto-start option

add an api option for auto-starting the display without clicking a button

publish to sonatype

publish to a a standard scala open source repository, such as sonatype or maven central

tidy gui

the gui buttons should be presented horizontally

tests

Add tests, at least for the Utils

separate example repo

separate off the examples into a separate repo and add more. eg. a simple (finite) counter, GoL and a Mandelbrot (single) frame

finite streams

Make sure that the code works with finite streams, leaving the final frame on screen, and add a constructor for displaying a single image

save option

add an option for saving image frames from streams, in the api and the gui

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.