AJYN Graphics Language PLT Project by Group JAYN Jared Kennedy Ananya Das Yaniv Schiller Neel Goyal...
-
Upload
august-ferguson -
Category
Documents
-
view
214 -
download
0
Transcript of AJYN Graphics Language PLT Project by Group JAYN Jared Kennedy Ananya Das Yaniv Schiller Neel Goyal...
AJYN Graphics Language
PLT Project by Group JAYN
Jared Kennedy
Ananya Das
Yaniv Schiller
Neel Goyal
May 13, 2003
AJYN Features
• A simple graphics language to model animations.
• Compilation outputs to swf format and plays using any Flash player.
• Simple model of computation allows for quick learning and easy use.
Basic Graphics Overview
• Graphics primitives:• Points• Lines• Rectangles• Ellipses• Polygons
• Transformations:• Translations• Rotations• Scales
Language Functionality
• Additional AJYN features:• Grouping:
Groups together various graphics primitives to be transformed and animated as a single unit.
• Hiding objects:By declaring a given object invisible over a set period of
frames, it can be hidden temporarily from the scene without needing to instantiate a new object.
AJYN Syntax• Initializing a program:
Program name = screen width, screen height, total frames;
•Declaring objects:point id = x coordinate, y coordinate;line id = x1 coord, y1 coord, x2 coord, y2 coord;rect id = upper-left x, upper-left y, rect width, rect height;ellipse id = center x coord, center y coord, x radius, y radius;poly id = x1 coord, y1 coord, x2 coord, y2 coord, …;
•Grouping:group id = obj1, obj2, …objN, x coord, y coord;
AJYN Syntax cont…• Transforming Objects:
translate(id, new x pos, new y pos, start frame, stop frame);rotate(id, rotation degrees, start frame, stop frame);scale(id, scale size, start frame, stop frame);
• Hiding Objects:setInvisible(id, start frame, stop frame);
• Comments:•AJYN only supports commenting of single lines•Comments are denoted by //
Compilation ProcessSource
ANTLR
IR File
Backend Application includingMing API
SWF (“SWIFF”) Output
Abstract Syntax TreeThe AST for out language is a linked list containing the elements that go into creating the animation. It has the follow structure:
Program node
Object node
Groups node
Functions node
Visibility node
Contains info declared in the Program command
Contains a vector holding shapes with an ID number and other object parameters
Contains a vector of nodes that contain group ID numbersalong with a vector of object IDs
Contains a vector of transformation nodes that act on objectsreferenced through their IDs
Contains information about visibility of an object fromframe to frame
Intermediate Representation• Corresponding IR file:
01 3 500 500 2160 02 0 12 1 4 250 250 250 150 0 0 255 12 2 4 250 250 250 350 255 255
255 12 3 4 250 250 250 50 0 255 0 12 4 4 250 250 250 450 255 255
255 14 0 4 250 250 200 200 255 0 0 03 0 19 10 2 1 2 250 250 19 11 2 3 4 250 250 04 0 22 11 3 4320 0 2160 22 10 3 360 0 2160 09 0
• Example Code:Program Clock = 500, 500, 2160;
ActiveColor = 0, 0, 255;line L1 = 250, 250, 250, 150;ActiveColor = 255, 255, 255;line L2 = 250, 250, 250 350;ActiveColor = 0, 255, 0;line L3 = 250, 250, 250, 50;ActiveColor =255, 255, 255;line L4 = 250, 250, 250, 450;ActiveColor = 255, 0, 0;ellipse E1 = 250, 250, 200, 200;
group hours = L1, L2, 250 250;group minutes = L3, L4, 250, 250;
rotate(minutes, 4320 , 0, 2160);rotate(hours, 360, 0, 2160);
Backend CompilationOur point was not to reinvent the wheel, it was to make animations easy to use. Ming, an open source project located on Sourceforge, replaced Macromedia in creating an open source API for swf files. Ming, written in C, comes with extensions for Java, PHP and C++. AJYN uses this source to compile the actual animation file.
Ming does not handle animations in a simple fashion. Objects must be placed on a frame by frame basis. The backend application accepts a file containing the intermediate representation and produces the animations without the complexities of Ming.
Backend Compilation cont…
• Basic backend algorithm:For each frame: Show the objects and groups that are visible If animations: Reposition/Resize the affected objects
• Backend complexities:Swf does not handle ellipses and circles. It only handles Bezier curves. Creating an ellipse requires the conversion from ellipse specifications to a group of curved lines.
Issues in making objects disappear, even mid-animation, and then reappear in the correct location.
Sample Source Code
//Test Code for a Simple Clock
Program Clock = 500, 500, 2160;
ActiveColor = 0, 0, 255;
line L1 = 250, 250, 250, 150;
ActiveColor = 255, 255, 255;
line L2 = 250, 250, 250, 350;
group hour = L1, L2, 250, 250;
ActiveColor = 0, 255, 0;
line L3 = 250, 250, 250, 50;
//Test Code Continued….
ActiveColor =255, 255, 255;
line L4 = 250, 250, 250, 450;
group mins = L3, L4, 250, 250;
ActiveColor = 255, 0, 0;
ellipse E1 = 250, 250, 200, 200;
rotate(mins, 4230, 0, 2160);
rotate(hour, 360, 30, 2160);