Tkar – Tk-based animation process and protocol

The Tkar animator aims to do one thing well: listen to an incoming stream of data and animate it in a 2D canvas. User interaction is streamed back out.

Additional documentation:

Overview

Tkar is a Tk/ruby-based animation program using TkCanvas. It accepts command input from stdin or a socket. Commands may define parametrized shapes, place them on the canvas, move and rotate them, change parameters, etc. User interaction events (click, drag, etc) are sent back on the socket or stdout. The canvas can be resized, scrolled, zoomed, and tracked to an object.

Graphical constructs

Tkar command summary

command| effect ——| —— shape| define shape in terms of primitives (Tk Canvas objects). Shape may expose any Tk parameters (e.g, colors, lengths of poly sides) add| add object to canvas with specified shape, layer, position, rotation, params move, rotate, scale, delete| operate on existing object param| change param value of an object (e.g. change color or geometry over time; change arrow shape because endpoint moves) wait| playback with specified frame rate update| finish time step params| set window params (color, size, zoom) follow| follow a specified object load| load file (like include)

User interaction

Installation

Prerequisites

Tcl/Tk

For windows: www.activestate.com/Products/ActiveTcl/

For linux, just use your distribution's package tool to install tcl. However, you may need to make sure that ruby and linux both use (or do not use) the pthread library.

Ruby

For windows: rubyforge.org/projects/rubyinstaller/

For other platforms: www.ruby-lang.org

Gem installation

  gem install tkar

Alternately, you can download the source code (tar ball or git repo) and run it in place using the --local-lib command line option

  bin/tkar --local-lib

Usage

Command line

See the -h command line option for details on running tkar.

Examples are available with the source code–read the comments to see how to run.

Tkar window

Press the “h” key for on-line help using the tkar window.

Protocol

See protocol for details on the protocol and writing shape files.

Integrating tkar with other applications

There are three transport options:

  1. Over pipe

Invoke as

  cat data | tkar

or

  program | tkar

Invoke as

  tkar [<ipaddr>] <port>

Invoke as

  tkar /path/to/socket

Note that tkar has a -c option which tells it to be the socket client rather than the server. This is useful when your main program needs to choose the port, for example.

Tkar can be interfaced with Simulink. Tkar appears in a simulink model as a block to which can be wired to any number of data sources that drive objects in the animation. You can have several tkar blocks. Think of tkar as the animation version of the built-in plotting block. (Simulink's built-in animation capabilities are bad.)

An additional set of C files need to be compiled as a Simulink extension. Contact author for details.

Author

Copyright 2006-2014, Joel VanderWerf, vjoel@users.sourceforge.org

License

License is BSD. See COPYING.