Home

Awesome

InteractiveCanvas

The library distributes canvas animation over set of devices.

<p align="center"><img src="docs/pingpong.gif"/></p> <p align="center"><img src="docs/mirror.gif"/></p>

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

Limitations

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