high-level operations on pictures

Slides:



Advertisements
Similar presentations
Spreadsheet Vocabulary
Advertisements

Spreadsheet Vocabulary Split the screen so you can see the words AND the crossword puzzle AND the quiz at the same time.
The Web Wizards Guide to HTML Chapter Six Tables.
Chapter 4 Transforming and Distorting Objects. Objectives Transform objects Offset and outline paths Create compound paths Work with the Pathfinder panel.
This terms course Last term we both worked on learning 2 things –Processing –The concepts of graphics etc. This term will focus more on the basic concepts.
Python Programming, 2/e1 CS177: Programming in Multimedia Objects Recitation Topic: Graphics Library.
Week 7 - Monday.  What did we talk about last time?  Specular shading  Aliasing and antialiasing.
Picture Manipulation The manipulation of (already created) pictures. May be applied to vector graphics or bitmaps. We will consider bitmaps and introduce.
GUI and Swing, part 2 The illustrated edition. Scroll bars As we have previously seen, a JTextArea has a fixed size, but the amount of text that can be.
Six compound procedures and higher-order procedures.
Four simple expressions in meta. Data objects Pieces of data in a computer are called objects Today, we’ll talk about four kinds of objects Numbers Pictures.
Twenty high-level operations on pictures. Recap: vector graphics constructors [box width height] Creates a picture with a box [group pictures …] Makes.
CSC 160 Computer Programming for Non-Majors Lecture #8: Animations I Prof. Adam M. Wittenstein
Eleven colors and rasters. Color objects [color name] Returns color with the specified name [color red green blue] Returns color with the specified amounts.
Fifteen high-level operations on pictures. Recap: vector graphics constructors [box width height] Creates a picture with a box [group pictures …] Makes.
Twelve painting with procedures. Overview Making shaded images with procedures Making a more elegant language Making textures with noise functions.
Four simple expressions in meta. Data objects Pieces of data in a computer are called objects Today, we’ll talk about four kinds of objects Numbers Pictures.
CSE 113 Week 5 February , Announcements  Module 2 due 2/15  Exam 3 is on 2/15  Module 3 due 2/22  Exam 4 is on 2/25  Module 4 due 2/29.
Six compound procedures and higher-order procedures.
Games and Simulations O-O Programming in Java The Walker School
ULI101: XHTML Basics (Part III) Introduction to XHTML / Continued … Block-Level vs. Inline Elements (tags) Manipulating Text,  , Text Characteristics,,,,,,,,,,,,,,,
CHAPTER 11 Tables. How Are Tables Used Data Display  Very tidy and very useful Better Text Alignment  Putting text in tables allows you to format indents.
Tutorial 1 Introducing Adobe Flash CS3 Professional
tiled Map Case Study: Rendering with JPanel © Allan C. Milne v
Lecture 15: Intro to Graphics Yoni Fridman 7/25/01 7/25/01.
Chapter 4 Working with Frames. Align and distribute objects on a page Stack and layer objects Work with graphics frames Work with text frames Chapter.
1 Building Java Programs Supplement 3G: Graphics These lecture notes are copyright (C) Marty Stepp and Stuart Reges, They may not be rehosted, sold,
1 SheetCourse: Engineering Graphics 1504Memorial University of Newfoundland Engineering Graphics 1504 Lecture 2 – Orthographic Sketches Objectives l Recap.
CSC508 Convolution Operators. CSC508 Convolution Arguably the most fundamental operation of computer vision It’s a neighborhood operator –Similar to the.
© 2011 Delmar, Cengage Learning Chapter 4 Working with Frames.
COMPUTER PROGRAMMING I SUMMER 2011 Objective 8.01 Understand coordinate systems. (3%)
Scope: What’s in a Name? CMSC Introduction to Computer Programming October 16, 2002.
Introduction to Graphics. Graphical objects To draw pictures, we will use three classes of objects: –DrawingPanel : A window on the screen. –Graphics.
Review Expressions and operators Iteration – while-loop – for-loop.
Chapter 11: Scrolling with Greenfooot. What Is Scrolling? Scrolling is an important and often necessary concept in games. It can be used to: a)Convey.
CS552: Computer Graphics Lecture 16: Polygon Filling.
Periodic Table  Organized like a big grid  Has rows (left to right horizontally) called periods  Has columns (top to bottom vertically) called groups.
Laying out Elements with CSS
What is a Function Expression?
Pixels, Colors and Shapes
Adapted from slides by Marty Stepp and Stuart Reges
CSS Layouts: Grouping Elements
Examining Two Pieces of Data
Building Java Programs
constructing simple procedures using abstraction
painting with procedures
3D Transformations Source & Courtesy: University of Wisconsin,
Building Java Programs
Building Java Programs
Fill and Stroke Stroke is the outline of a shape, text or image.
Java Programming: Guided Learning with Early Objects
CSc 110, Spring 2017 Lecture 6: Parameters (cont.) and Graphics
Objectives Create a reset style sheet Explore page layout designs
COMP 175: Computer Graphics February 9, 2016
Data Representation.
WINDOWING AND CLIPPING
Graphic Editing Terms Cropping
Elements of design Elements are the building blocks of any design.
COMP 175: Computer Graphics February 21, 2016
Gray Scale picture def pixBW(pixel): # given a pixel, change to BW
WINDOWING AND CLIPPING
Lecture 26: Lists of Lists
Transforming and Distorting Objects
Two-Dimensional Arrays and Nested Loops – part 2
Arrays and Array Lists CS 21a.
Lecture 12: Message passing The Environment Model
Bootstrap 4 December 17, 2018.
CSc 337 Lecture 5: Grid layout.
Good programming practices
ECE/CSE 576 HW 1 Notes.
Presentation transcript:

high-level operations on pictures fifteen high-level operations on pictures

Recap: vector graphics constructors [box width height] Creates a picture with a box [group pictures …] Makes a compound picture from existing pictures [translate point pictures …] A new picture with all pictures shifted by point [scale size-or-point pictures …] A new picture with all pictures grown/shrunk/stretched If size-or-point is an integer, picture is uniformly grown/shrunk If size-or-point is a point, the pictures are stretched horizontally by the point’s X coordinate, and vertically by its Y coordinate [paint color pictures …] Renders pictures filled with color [ink brush pictures …] Renders pictures outlined with brush

New: vector graphics accessors The bounding box of a picture is the smallest (unrotated) box that completely encloses the picture [left-edge picture] [right-edge picture] [top-edge picture] [bottom-edge picture] Returns the X coordinate of the left/right edge of picture’s bounding box Returns the Y coordinate of the top/bottom edge of picture’s bounding box [width picture] [height picture] The width/height in pixels of picture’s bounding box [center picture] The center point of picture’s bounding box objects in picture bounding box

Stacking boxes How do we write a procedure to stack one picture on top of another? [stack-top [box 40 40] [box 100 100] [define stack-top [top base → [group base [translate [point 0 [− [top-edge base] [bottom-edge top]]] top]]]]

Stacking boxes How do we do the reverse [stack-bottom [box 40 40] [box 100 100] [define stack-bottom [bottom base → [group base [translate [point 0 [− [bottom-edge base] [top-edge bottom]]] top]]]]

Handling variable numbers of objects How do we make it handle more than two arguments? [stack [box 10 10] [box 20 20] [box 30 30]] [define stack [??? → ???]]

New feature: Procedures with variable numbers of arguments [name … → exp] The “…” after the argument name means the procedure can accept a variable number of arguments All of the arguments get packaged as a list and named name. If the procedure is called with no arguments, then name is a list with 0 elements. [name1 name2 … → exp] This means the procedure requires at least 1 argument, which is named name1. Any other arguments are packaged as a list named name2. [name1 name2 name3 … → exp] Same, but the first two arguments are named name1, name2. Can have any number of extra names But only the last name can have the “…” on it.

Handling variable numbers of objects How do we make it handle more than two arguments? [stack [box 10 10] [box 20 20] [box 30 30]] [define stack [pictures … → ???]]

Recap: lists [map proc list] Runs proc on each element of list and returns a new list of the results [fold proc list] [fold proc start-value list] Runs proc on successive elements of list to reduce it to a single value (e.g. [fold + list] returns the sum of all elements of the list. [apply proc list] Runs proc with the elements of list as its arguments. [list item1 item2 … itemn] Makes a new list with items.

Handling variable numbers of objects How do we make it handle more than two arguments? [stack [box 10 10] [box 20 20] [box 30 30]] [define stack [pictures … → [fold stack-top pictures]]]

Esoteric point: Handling empty argument lists The two-argument version of fold breaks when we call it with a list with no arguments. So stack will break if we just say [stack] What if we say this instead: [define stack [pictures … → [fold stack-top [group] «an empty group» pictures]]]

Stacking horizontally [define stack-right [base right → [group base [translate [point [− [right-edge base] [left-edge right]] 0] right]]]] [define splay [pictures … → [fold stack-right [group] pictures]]]

Fixing the position of an object Stack-top, etc. all leave base in its original position … … and stack everything else off the end of it So unlike box, they don’t return a picture centered around the origin How do we recenter an existing picture around the origin? [define recenter [picture → [translate [− [center picture]] picture]]]

Prairie School stained glass patterns Frank Lloyd Wright Designs emphasized strong horizontals and verticals Common motifs Deformed grids Symmetry (vertical and horizontal) Repeated patterns

Making deformed grids We’d like to be able to express this picture simply and clearly Without having to write 35 calls to box We’ll start by just trying to get the leading (the black lines) right, without worrying about color

Making the leading The design consists of almost identical rows of boxes Each row is a fixed design But the height varies from row to row Start by writing code to make one row

Making the top row of boxes [define top-row [splay [box 10 10] [box 10 10] [box 15 10] [box 60 10] [box 15 10] [box 10 10] [box 10 10]]]

Making an arbitrary row [define row [height → [splay [box 10 height] [box 10 height] [box 15 height] [box 60 height] [box 15 height] [box 10 height] [box 10 height]]]]

Making the leading [stack [row 10] [row 15] [row 190] [row 10]]

What’s wrong with this? [stack [row 10] [row 15] [row 190] [row 10]] If we want to change the design we have to redefine row We’d like to have a procedure that Takes the widths and heights of the rows and columns as arguments And makes the picture

Making the heights be a parameter How do we change: [stack [row 10] [row 15] [row 190] [row 10]] into just: [leading [list 10 15 190 15 10]] ?

Making the heights be a parameter [define leading [heights → [stack [map row heights]]]] Well, almost: Generates ArgumentTypeException What’s wrong? Splay wants to take several pictures as arguments … … not a (single) list of pictures

Fixing the bug How do we fix it? [define leading [heights → [apply stack [map row heights]]]]

Making the heights be a parameter Okay, what should we change next? We still need to redefine row any time we want to change the design How do we change it so we can just say: [leading [list 10 10 15 60 15 10 10] [list 10 15 190 15 10]] i.e. so we can pass it both the widths and the heights as arguments?

Making the widths be a parameter Now the widths need to be an argument to row [define leading [widths heights → [apply stack [map [height → [row widths height]] heights]]]]

Fixing the row procedure This time, row will take as arguments A list of widths A single height It needs to make a box for each width And splay all the boxen together [define row [widths height → [apply splay [map [width → [box width height]] widths]]]]

Live hacking exercise Okay, now we have the leading But no color How do we specify the colors for each of the boxes? Big list of colors Procedure to compute color for each box But what are the arguments to the procedure? Width and height? But what if we have identically sized boxes with different colors? Position? In x, y coordinates? Or in grid position?