Unformatted text preview:

Glimmer An Image Manipulation Language Terry Tai netherlight gmail com Vida Ha vidaha gmail com Table of Contents 1 White Paper 5 1 1 Introduction 5 1 2 Justification 5 1 3 A Visual Example 5 2 Language Tutorial 7 2 1 Using Glimmer to Create a Simple Image 7 2 2 Defining a Simple Function in Glimmer 7 2 3 Two Version of Assignment 7 2 4 A More Complex Glimmer program 8 3 Language Reference Manual 9 3 1 Lexical Conventions 9 3 1 1 Comments 9 3 1 2 Tokens 9 3 1 3 Whitespace and Line Breaks 9 3 1 4 Identifiers and Literals 9 3 1 5 Keywords 9 3 1 6 Operators 10 3 2 Types 10 3 2 1 Images 10 3 2 2 Pixels 10 3 2 3 Numbers 11 3 3 Identifiers 11 3 3 1 Scopes 12 3 3 2 Type Checking 12 3 4 Program Blocks 12 3 4 1 Include Block 12 3 4 2 Function Definition Block 13 3 4 3 Program Statement Block 13 3 5 Expressions and Operators 13 3 5 1 Function Calls 14 3 5 2 Attribute Selection 14 3 5 3 Pixel References 14 3 5 4 Arithmetic Multiplicative and Comparative Operations 15 3 5 5 Logical Operations 15 3 6 Statements 15 3 6 1 Set 15 3 6 2 Alias 16 3 6 3 Function Calls 16 3 6 4 Return 16 3 6 5 If Else 17 3 6 6 Scan 17 3 6 7 Continue 17 2 4 5 6 7 8 3 6 8 Break 17 3 6 9 Image Input Output 17 3 6 10 Print and Print String 18 Project Plan 19 4 1 Team Responsibilities 19 4 2 Planned Project Timeline 19 4 3 Project Log 19 4 4 Development Environment 20 4 5 Code Style Conventions 20 4 5 1 Antlr Code Style Conventions 20 4 5 2 Java Code Style Conventions 20 Architectural Design 21 5 1 Overview 21 5 2 Glimmer Lexer 21 5 3 Glimmer Parser 22 5 4 GlimmerType Libraries and SymbolTable 22 5 5 Glimmer Walker Interpreter 23 Test Plan 24 6 1 Testing the Lexer Parser 24 6 1 1 Testing Assignments 24 6 1 2 Testing Image Intrinsics 24 6 1 3 Testing Functions 25 6 1 4 Full test 1 25 6 1 5 Full Test 2 26 6 2 Testing the Java Libraries 27 6 2 1 Symbol Table Testing 27 6 2 2 Glimmer Type Testing 29 6 2 3 Image Manipulation Library Testing 31 6 3 Full Integration Testing 32 6 3 1 utils glim 32 6 3 2 Test 1 34 6 3 3 Test 2 37 6 3 4 Test Control 37 Lessons Learned Advice for Future Groups 40 7 1 1 Have patience with the parser 40 7 1 2 The AST orders things differently than the language syntax 40 7 1 3 Stick to one syntax for intrinsics 40 7 1 4 Two person teams worked well 40 7 1 5 Separate walker and interpreter for easier testing 40 7 1 6 Writing a Compiler isn t as bad as its reputation 41 7 1 7 If there had been more time 41 Appendix 42 8 1 Antlr Lexer and Parser Code grammar g 42 8 2 Java Library code 48 8 2 1 GlimmerSymbolTable java 48 8 2 2 GlimmerException java 50 3 8 2 3 GlimmerType java 50 8 2 4 GlimmerID java 52 8 2 5 GlimmerNum java 53 8 2 6 GlimmerPixel java 57 8 2 7 GlimmerImage java 61 8 2 8 GlimmerFunction java 65 8 3 Walker Code walker g 66 4 1 White Paper 1 1 Introduction Glimmer is a new and exciting programming language for manipulating images and creating special imaging effects designed to be easy to learn Extensive programming experience is not a prerequisite for learning Glimmer instead we hope even a novice programmer can quickly pick up Glimmer s commands and dive straight into image modifications To this end Glimmer natively supports images and pixels as first order data types and make it easy to construct advanced filters and effects generators Glimmer is not designed to be an advanced language or to be used for all general purposes While Glimmer has limited support for matrix operations Glimmer is not the best matrix manipulation language around Instead this language will allow more advanced control logic for image manipulation than that provided by standard image editing software packages such as Adobe Photoshop 1 2 Justification So what is it that Glimmer provides really Even very experienced programmers will enjoy the low ramp up time for learning Glimmer and the ease with which someone can edit an image in a programming language setting While stronger languages such as C can handle the parsing of the bitmap and perform the same numeric operations the looping constructs needed would be clumsy and prone to error Glimmer has loop mechanisms specifically tailored for images and easy ways to access surrounding pixels in an image With Glimmer it is possible to do a lot more image manipulation with fewer lines of code In addition Glimmer would be a great language to use to introduce programming to younger students who maybe aren t yet ready to learn a more powerful language There s no typechecking objects or other abstract programming paradigms to learn first We think it s intuitive to pick up and that students will appreciate the visual aspect of imagining A teacher could even use interesting visual patterns to teach elementary algorithms Our main hope is that users will have fun using Glimmer for image processing and find interesting applications for this language 1 3 A Visual Example Generating gradients is a visually appealing task that many image editors can handle However such functions are often limited in their provided options Glimmer can perform a four color gradient generation in just over twenty lines of code This takes the following four colors on the left and generates the gradient on the right See the gradient function in utils glim starting on page 32 5 The four colors used to generate a position proportional gradient 2 Language Tutorial In this section we go over a few simple Glimmer programs as a tutorial on learning the Glimmer Language The LRM ultimately describes each of the commands in detail for further reference 2 1 Using Glimmer to Create a Simple Image This is a first example of a Glimmer program Glimmer s version of a Hello World Rather than printing out a string which would just take one line in Glimmer we create a simple image set it to be blue everywhere and save it to a file Create a new image that is 100 pixels wide and 500 pixels in height new rectangle 100 500 Scan every pixel in scan p in rectangle p pixel red 0 p pixel green 0 p pixel blue 255 the rectangle image and set its color No red component No green component We like blue Save the rectangle image to a file save rectangle blue rectangle png 2 2 Defining …


View Full Document

Columbia COMS W4115 - Glimmer - An Image Manipulation Language

Documents in this Course
YOLT

YOLT

13 pages

Lattakia

Lattakia

15 pages

EasyQL

EasyQL

14 pages

Photogram

Photogram

163 pages

Espresso

Espresso

27 pages

NumLang

NumLang

6 pages

EMPATH

EMPATH

14 pages

La Mesa

La Mesa

9 pages

JTemplate

JTemplate

238 pages

MATVEC

MATVEC

4 pages

TONEDEF

TONEDEF

14 pages

SASSi

SASSi

16 pages

JTemplate

JTemplate

39 pages

BATS

BATS

10 pages

Synapse

Synapse

11 pages

c.def

c.def

116 pages

TweaXML

TweaXML

108 pages

Load more
Loading Unlocking...
Login

Join to view Glimmer - An Image Manipulation Language and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Glimmer - An Image Manipulation Language and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?