egrapher: A Programming Language for Art

Similar documents
egrapher Language Reference Manual

B. Examples Set up the integral(s) needed to find the area of the region bounded by

Language Proposal: tail

QUADRATIC AND CUBIC GRAPHS

Intro to Programming & C Why Program? 1.2 Computer Systems: Hardware and Software. Why Learn to Program?

do fifty-two: An Introductory Programming Language

MATLAB SUMMARY FOR MATH2070/2970

Introduction to Octave/Matlab. Deployment of Telecommunication Infrastructures

G Programming Languages Spring 2010 Lecture 6. Robert Grimm, New York University

pixelman Pixel Manipulation Language Anthony Chan tc2665 Teresa Choe tc2716 Gabriel Lucas Kramer-Garcia glk2110 Brian Tsau bt2420

PIC 10A. Review for Midterm I

6. Operatoren. 7. Safe Programming: Assertions. Table of Operators. Table of Operators - Explanations. Tabular overview of all relevant operators

easel Manager Danielle Crosswell dac2182 Language Guru Tyrus Cukavac thc2125 System Architect Yuan-Chao Chou yc3211 Tester Xiaofei Chen xc2364

Chapter 2: Introduction to C++

Chapter 2: Special Characters. Parts of a C++ Program. Introduction to C++ Displays output on the computer screen

Introduction to Programming Using Java (98-388)

Course Text. Course Description. Course Objectives. StraighterLine Introduction to Programming in C++

Language Reference Manual

Full file at

Pace University. Fundamental Concepts of CS121 1

Lecture 2 Tao Wang 1

CS115 - Module 4 - Compound data: structures

Language Reference Manual simplicity

Scheme Tutorial. Introduction. The Structure of Scheme Programs. Syntax

Python for Astronomers. Week 1- Basic Python

CISC 1600 Lecture 3.1 Introduction to Processing

CS1 Lecture 3 Jan. 18, 2019

Scientific Computing

easel LANGUAGE REFERENCE MANUAL

Math 1206 Calculus Sec. 5.6: Substitution and Area Between Curves (Part 2) Overview of Area Between Two Curves

Chapter 4. Computation. Bjarne Stroustrup.

CS1 Lecture 3 Jan. 22, 2018

Exam 1 Prep. Dr. Demetrios Glinos University of Central Florida. COP3330 Object Oriented Programming

Programming in C++ Prof. Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

Computer Programming : C++

A short, pragmatic and INCOMPLETE intro to C++/ROOT programming. Mikołaj Krzewicki Nikhef/UU

Expressions and Casting. Data Manipulation. Simple Program 11/5/2013

Basic concepts. Chapter Toplevel loop

Chapter 4 Introduction to Control Statements

Physics 326G Winter Class 2. In this class you will learn how to define and work with arrays or vectors.

C++ Support Classes (Data and Variables)

Appendix A. Introduction to MATLAB. A.1 What Is MATLAB?

Practices (1) 6.MP.2. Reason abstractly and quantitatively.

Expressions and Casting

( &% class MyClass { }

LECTURE 18. Control Flow

SFPL Reference Manual

TOPIC 2 INTRODUCTION TO JAVA AND DR JAVA

Points and lines. x x 1 + y 1. y = mx + b

Introduction to: Computers & Programming: Review prior to 1 st Midterm

+. n is the function parameter and the function returns the sum.

3. Logical Values. Boolean Functions; the Type bool; logical and relational operators; shortcut evaluation

The design recipe. Readings: HtDP, sections 1-5. (ordering of topics is different in lectures, different examples will be used)

C Syntax Out: 15 September, 1995

Graphing Linear Equations and Inequalities: Graphing Linear Equations and Inequalities in One Variable *

Contents. Jairo Pava COMS W4115 June 28, 2013 LEARN: Language Reference Manual

It is better to have 100 functions operate one one data structure, than 10 functions on 10 data structures. A. Perlis

Advanced Systems Programming

LECTURE 17. Expressions and Assignment

Faculty of Engineering Computer Engineering Department Islamic University of Gaza C++ Programming Language Lab # 6 Functions

S206E Lecture 13, 5/22/2016, Grasshopper Math and Logic Rules

LECTURE 02 INTRODUCTION TO C++

Mobile Computing Professor Pushpendra Singh Indraprastha Institute of Information Technology Delhi Java Basics Lecture 02

CSCI 131, Midterm Exam 1 Review Questions This sheet is intended to help you prepare for the first exam in this course. The following topics have

FRAC: Language Reference Manual

Chapter 1: Building Blocks of Programming

Java Primer 1: Types, Classes and Operators

Mirage. Language Reference Manual. Image drawn using Mirage 1.1. Columbia University COMS W4115 Programming Languages and Translators Fall 2006

Ordinary Differential Equation Solver Language (ODESL) Reference Manual

MathLight: Lightweight MATLAB implementation

Typesetting spectral sequences in L A TEX with luasseq.sty

2.1. Chapter 2: Parts of a C++ Program. Parts of a C++ Program. Introduction to C++ Parts of a C++ Program

ChartLan A Language for Chart COMS W4115 PLT project proposal Professor: Stephen A. Edwards

Typescript on LLVM Language Reference Manual

4. Logical Values. Our Goal. Boolean Values in Mathematics. The Type bool in C++

CS3157: Advanced Programming. Outline

Chapter 1 INTRODUCTION

Integer Multiplication and Division

CS 31: Intro to Systems C Programming. Kevin Webb Swarthmore College September 13, 2018

CMSC 330: Organization of Programming Languages. Operational Semantics

Chapter 1. Linear Equations and Straight Lines. 2 of 71. Copyright 2014, 2010, 2007 Pearson Education, Inc.

Chapter 3 Syntax, Errors, and Debugging. Fundamentals of Java

for (i=1; i<=100000; i++) { x = sqrt (y); // square root function cout << x+i << endl; }

Midterm I - CSE11 Fall 2013 CLOSED BOOK, CLOSED NOTES 50 minutes, 100 points Total.

CSCI 2212: Intermediate Programming / C Review, Chapters 10 and 11

CS 112 Introduction to Computing II. Wayne Snyder Computer Science Department Boston University

Basics of Java: Expressions & Statements. Nathaniel Osgood CMPT 858 February 15, 2011

Intro. Scheme Basics. scm> 5 5. scm>

CS-211 Fall 2017 Test 1 Version Practice For Test on Oct. 2, Name:

PROGRAMMING IN HASKELL. Chapter 2 - First Steps

for (i=1; i<=100000; i++) { x = sqrt (y); // square root function cout << x+i << endl; }

A SHORT COURSE ON C++

Functional Programming. Big Picture. Design of Programming Languages

JME Language Reference Manual

Recap from last time. Programming Languages. CSE 130 : Fall Lecture 3: Data Types. Put it together: a filter function

3. Except for strings, double quotes, identifiers, and keywords, C++ ignores all white space.

x = 3 * y + 1; // x becomes 3 * y + 1 a = b = 0; // multiple assignment: a and b both get the value 0

Proposal for TED. In recent years, as big data analysis has become a more common practice among

C++ PROGRAMMING. For Industrial And Electrical Engineering Instructor: Ruba A. Salamh

Yo : A Video Analytical Editing Programming Language

Transcription:

egrapher: A Programming Language for Art Long Long: ll3078@columbia.edu Xinli Jia: xj2191@columbia.edu Jiefu Ying: jy2799@columbia.edu Linnan Wang: lw2645@columbia.edu Darren Chen: dsc2155@columbia.edu September 28, 2016 1 / 8

Contents 1 Introduction and Motivation 3 2 Language Design and Syntax 3 2.1 Comments........................................................................ 4 2.2 Built-in Data Types................................................................. 4 2.3 Operators......................................................................... 5 2.4 Data type Built-in Functions.......................................................... 5 2.5 Control Flow...................................................................... 7 2.6 Function Statement................................................................. 7 3 Sample Code 8 2 / 8

1 Introduction and Motivation egrapher offers an innovative way of drawing art with pinpoint accuracy. The language gives the user a wide set of tools to accurately illustrate detailed drawings compared to simple and rigid pre-installed tools such as paint on Windows. The goal of egrapher is to make drawing on digital systems easier as well as allow for users to draw more complicated paintings through mathematical functions. The project will allow us to also better understand the intersection of mathematics and art. Users will be able to use simple syntax and math expression to draw graphs, diagrams, and more complicated objects through simple objects. In addition, egrapher could serve as a useful introductory language for elementary school kids combining programming, mathematics, and art into one package. Students will be able to learn how to use simple functions and loops to draw an actual picture. For example, one exercise could ask students to draw a heart through polar coordinates. 2 Language Design and Syntax The typing style, flow control, and function in egrapher takes is reminiscent of C++, while the overall design takes several interesting ideas from Matlab. It intends to throw away complex object oriented features and provide stronger build-in data type and functions to help users finish their plotting efficiently. The egrapher compiler compiles code into LLVM and links to C library for further executions. The egrapher system open a main window to show the picture which users drawn using egrapher code, while it also supports standard output stream connected to the terminal or console. In the main window, there is a big backboard. Users code to generate curves and paste them on the board then comes a graph. In order to figure out the correct place to paste, there should be an only axis system on the board. Formula may have strong mutual relations to each other, so egrapher offers group structure to manage formula. Board, axis, group and formula are four basic concepts form the whole plotting system of egrapher. Take the following picture as an example, grids and axis are fixed on the white board. Two groups of formula, particularly two houses are plotted. x = -7 {-5< y<-0.5 3 / 8

Since the design goal of egrapher is to draw paintings through mathematical functions, focusing on implantation of four basic data type (board, axis, group, formula) and their build-in functions can greatly improve and guarantee plotting and coding experience. 2.1 Comments Syntax Comment Style # code Single line /* Multiple lines code */ 2.2 Built-in Data Types Table 1: Comment Styles egrapher is statically strongly typed language egrapher comes with four basic types: int, float, bool and string. Each of these basic types can be used as raw values with no prior declaration of variables or can be assigned as the values of variables. egrapher also provides two built-in data types: dot and formula, which provide the basis for drawing element. The built-in collections are list, group and board In addition to these data types, egrapher also includes the value null, which represents the absence of value for any data type. Data Type int float bool string formula dot list group axis board Explanation 32-bit integer 32-bit floating-point number Boolean value Sequence of characters closed with double quotes To define function A dot on graph on (x, y) axis position Sequence of numeric, Boolean, or other types Combination of one or more formula and dot Set axis limits and aspect ratios All the element on displayed. Contain groups and axis. Table 2: Built-in Data Types 4 / 8

2.3 Operators Category Data type Operator Explanation Arithmetic int, float +, -, *, /, %, ^ Arithmetic computation operations in the same way as mainstream languages such as C/C++ and Matlab. ^ symbol means power. Comparison int, float, string ==,! =, <, >, <=, >= Comparison operations supporting numbers and strings. While string equality compares the characters contained in the string. Concatenation string + Concatenate two strings. Assignment int, float =, +=, =, =, /= Assign value to variables, mostly after certain calculation. 2.4 Data Type Built-in Functions Table 3: Operators Output functions int.print (int i) Print out given integer i, similar to stdout. float.print (float f) Print out given floating number f. string.print (string s) Print out given string s. display_group() Show a particular group of formula on screen in export_board(string filename, string type) Table 4: Basic data type build-in functions main window. Export the present board to an image file. Filename and type can be specified. Formula management set_expression(string e) Set numerical expression for each formula. In default case, a new-built formula takes as its expression and empty formula will be ignored when plotting. set_limits({xlim{ylim) Both x limits and y limts can be set here. Although argument and dependent variable roles can switch, we suppose the first brace describe x limit, the second one indicates y limits. set_color(r,g,b) set_linesyle(style, width) Table 5: Formula type build-in functions Take three integers as rgb value of the line color. Both style and witdth are integers. Width simply implies line width, while adjusting style can produce dotted line, * line, things like that. A detailed map of styles and index numbers will be released later. 5 / 8

Dot Management set_position(float x, float y) Set position for a dot. set_color(r,g,b) Take three integers as RGB value of the dot color. set_dotsyle(style, size) Both style and size are integers. Size simply implies mark size, while adjusting style can produce dotted, *, +, marks like that. A detailed map of style and index numbers will be released later. Table 6: Dot type build-in functions Group Management add_element(f) Add elements to a certain group. Group is quite similar to list with two data types (formula and dot in it) in it. delete_element(int index) Delete a certain element in group using its index. Index are maintained according to the attendance order. set_uniform_color(r,g,b) Paint all the elements in the group with same color. The default value of uniform color vector is (-1,-1,-1), which means no requirements. set_uniform_linesyle(style, width) Similar to uniform color, this time a uniform line style applies to each formula. set_uniform_dotsyle(style, width) Similar to uniform line style, this time a uniform dot style applies to each dot. size() return number of elements in group list_formula() return all the formula in group as a list. list_dot() return all the dots in group as a list. set_diplay(bool) Plot the group or not. Table 7: Group type build-in functions Axis management set_xlim(float x, float y) Set the display limits of x-axis. show_xlabel(bool) Whether show lables on x-axis. show_xaxis(bool)_ Whther show x-axis. set_ylim(float x, float y) Set the display limits of y-axis. show_ylabel(bool) Whether show lables on y-axis. show_yaxis(bool)_ Whther show y-axis. Table 8: Axis type build-in functions Board management show() Open the main window and show the picture. List_group() Return a list of groups. set_backgroud_color(r,g,b) Set background color according to rgb value. Table 9: Board type build-in functions 6 / 8

2.5 Control Flow Syntax while condition { /* code */ for init; cond; inc/dec { /* code */ for variable in list { /* code */ Examples while (a > 1) { a -= 1 for (i; i<10;i+=1) { int.print (i) for i in L { int.print (i) Table 10: Loops Syntax if condition if condition else if condition else if condition else Examples if (a==b) { a += b if (a==b) { a += b else { a -=b if (a==b) { a += b else if (a>b) { a -=b else { a *=b Table 11: Condition Statements 2.6 Function Statement Syntax fun function_name (variable1, variable2 ) { function Example fun addition(int a, int b) { return a+b 7 / 8

3 Sample Code formula f1, f2, f3, f4; f1.set_expression( (t+tcost,t+sint) ); f1.set_limit( 0<=t<=10 ); f1.set_color(117,103,174); f2.set_expression( (t-tcost,t-sint) ); f2.set_limit( 0<=t<=10 ); f2.set_color(255,163,104); f3.set_expression( (x-10)^2+(y-10)^2=10^2 ); f3.set_color(194,107,115); f4.set_expression( y>x ); f4.set_limit( 0<x, 0<y<20 ); f4.set_color(88,143,192); dot d1; d1.set_position(17.071,17.071); d1.set_color(88,143,192); group g; g.add_element (f1); g.add_element (f2); g.add_element (f3); g.add_element (d3); Axis.xrange(0, 20); Board.plot(); 8 / 8