InteractiveCanvas


Source link: https://github.com/elevenetc/InteractiveCanvas

InteractiveCanvas

The library distributes canvas animation over set of devices.

How it works

The library is based on pretty dumb method: Picture class has writeToStream and createFromStream methods which serializes and deserializes Picture object respectively. After serialization byte array sends to a client device as UDP packet. On a client device the packet is deserialized back into Picture object and finaly rendered on a Canvas. That's all.

Advantages

  • It's quite easy to distribute regular Canvas animation over almost any number of devices. You could develop and test your game (or just animation) on one device and then launch it on a set of Android TV-sets for instance.
  • Picture represents a frame of animation. Size of serialized Picture object is relatively small: could be 100 to 300 bytes - it depends on comlexity of your animation. So there is no need to have wide bandwidth to send 30 or 60 packets(frames) per second.
  • Serialization of frames and game logic execution could be performed on a separate device or even on a separate computer(with Android emulator/virtual machine). It could be useful when you need to perform heavy computations to prepare Picture frames or handle lots of users MotionEvents.

Limitations

  • The library uses deprecated methods. So some day it could just stop working. Though it could be used for some interactive installations or presentations where you have particular set of devices.
  • Initally the libray was designed for relatively simple animation. Complex animation could overflow maximum size of udp packet. In this case you could either try to compress frames or send frames over tcp.

Usage

  1. Host side should extend InteractiveCanvas.java and override onDraw method:
@Override protected void onDraw(Canvas canvas) {
  //...draw on canvas  super.onDraw(canvas);
// at the end of animation `super` method must be called 
}
  1. Then your canvas shoud be configured with array of Screens. Screen represents client device where animation should be displayed.
hostCanvas.config(screens, PICTURES_PORT, TOUCH_EVENTS_PORT);
 hostCanvas.start();
  1. Client should create PictureReceviver instance and configure it with ReceiverView instance:
pictureReceiver = new PictureReceiver(clientId);
 pictureReceiver.config(PICTURES_PORT, HOST_ADDRESS, TOUCH_EVENTS_PORT);
 pictureReceiver.setReceiverView(receiverView);
 pictureReceiver.start();

Samples

Ther're two samples: PingPongActivity and MirrorActivity. Both of the classes contain similar two static fields:

  private static final InetAddress HOST_ADDRESS = Utils.getAddress("192.168.56.101");

private static final InetAddress[] CLIENT_ADDRESSES = new InetAddress[]{

  HOST_ADDRESS,
  Utils.getAddress("192.168.56.102"),
  Utils.getAddress("192.168.56.103"),
  Utils.getAddress("192.168.56.104")

}
;

Change this ip adresses to id adresses of your devices and launch app on all devices.

Download

repositories {

  maven {
 url "https://jitpack.io" 
}
 
}
 //... dependencies {

  //...
  compile 'com.github.elevenetc:interactivecanvas:0.9.0' 
}

Licence

http://www.apache.org/licenses/LICENSE-2.0

Resources

RecyclerView with zoom effect.

Android Audio encapsulation library, with part Rx support.

A library to avoid boilerplate when testing beans and simple data objects.

"Tired of testing beans (aka: objects with just gettes/setters and no logic)? Do not test them!"

A reactive wrapper around Android's Google Play Services Wear API in Kotlin.

This is an event bus designed to allowing your application to communicate efficiently.

RxAndroidBle is a powerful painkiller for Android's Bluetooth Low Energy headaches. It is backed by RxJava, implementing complicated APIs as handy reactive observables.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes