Layout and Animation Language Why Would I Walk Through Mud? Ras - - PowerPoint PPT Presentation

layout and animation language
SMART_READER_LITE
LIVE PREVIEW

Layout and Animation Language Why Would I Walk Through Mud? Ras - - PowerPoint PPT Presentation

Layout and Animation Language Why Would I Walk Through Mud? Ras Bodik, Thibaud Hottelier, James Ide, Doug Kimelman (IBM), Kimmo Kuusilinna (Nokia), Per Ljung (Nokia) # NY Times 2 How Fancy Layout Are Created Today Pick a canned layout from


slide-1
SLIDE 1

Layout and Animation Language

Why Would I Walk Through Mud?

Ras Bodik, Thibaud Hottelier, James Ide, Doug Kimelman (IBM), Kimmo Kuusilinna (Nokia), Per Ljung (Nokia)

#

slide-2
SLIDE 2

NY Times

2

slide-3
SLIDE 3

How Fancy Layout Are Created Today

Pick a canned layout from ProtoViz (DSL for vis.)

– Limited to the library. – Non-programmers cannot define their own.

If programmer, must write own layout engine.

– May takes days => can’t quickly try layout ideas. – ~10x more code if using Python/JavaScript

5

slide-4
SLIDE 4

Our Language Mud

We choose declarative programming because

  • Empower designers

– Designers know the “what”, but not the “how”

  • Naturally maps on human thought process for

layout/visualization if well designed

  • Eventually, programming by demonstration

Our compiler does synthesis. Why not use an off-the-shelf constraint solver? Ex: Cassowary[Badros], SMT solvers, Prolog.

  • Performance

– We compile down to tree passes. Linear Time. – No search and backtrack.

6

slide-5
SLIDE 5

TreeMap of Financial Industry

7

NY Times

slide-6
SLIDE 6

TreeMap on the Drawing Board

Designer’s View

  • Area is market capitalization
  • Companies stacked vertically

(or horizontally)

  • Parent exactly encompasses

children

8

slide-7
SLIDE 7

Mud Hello World

  • 1. Document is a tree.
  • 2. We place local constraints

In TreeMap, we have two building blocks

  • H, the horizontal divider
  • V, the vertical divider

9

A C B

<A> <B/> <C/> </A> C.w = B.w = A.w / 2

B C A

slide-8
SLIDE 8

Specification of V

Let’s write the spec in English and then translate it progressively into Mud English Specification:

1. V is a rectangle with some style. 2. V area is divided vertically among its children 3. V’s children are stacked on top of each other. 4. V area is proportional the sum its children’s capitalization

Cap =70 Cap = 30

10

V

slide-9
SLIDE 9

The Three Constraints

trait VDiv(h, w) { // vertical division h = children[0].h + children[1].h w = children[0].w = children[1].w } trait VStack() { // vertical stacking children.left = 0 children[0].top = 0 children[0].h = children[1].top } trait TreeMap(h, w, cap) { // area =~ cap SCALE * cap = h * w cap = children[0].cap + children[1].cap }

11

slide-10
SLIDE 10

V Is a Composition of Trait

Let’s declare two new building blocks:

let V with RelCoord, BasicBoxStyle, VDiv, VStack, TreeMap let H with RelCoord, BasicBoxStyle, HDiv, HStack, TreeMap

“Trait”: Composable unit of behaviour

12

slide-11
SLIDE 11

Are we done?

Tool: “your treemap is under-constrained”

– There are distinct ways to lay it out:

Fix: Root.h = 640 Alternative fix: set the aspect ratio. Benefits of our semantics:

– Show possible solutions ==> Designer-friendly debugging – Unique solution ==> predictable layout.

13

slide-12
SLIDE 12

Prototyping with Mud

Mud flexibility allows designers to experiment. Example: Let’s make treemap fixed size!

– At Root node: h = 640, w = 320 – Tool tells us to make the scaling factor a variable

Mud compiler produces the new layout engine

– New engine requires four, rather than three passes – The extra pass computes the right scaling factor.

14

slide-13
SLIDE 13

Animations

How to add animation?

ie, transform the tilemap from Jan to Feb layout?

  • 1. Interpolate Jan-to-Feb capitalization data,
  • btaining new capitalization for each frame
  • 2. Update the document tree with this data
  • 3. Rerun the layout engine (recompute layout)

15

slide-14
SLIDE 14

Radial Layout

Polar coordinates in Mud trait Polar (x, y, ω, radius) { x = parent.x + radius * cos(ω) y = parent.y + radius * sin(ω) }

16

slide-15
SLIDE 15

Under the Hood

TreeMap Table Building Blocks Prop Fun Prop Fun Functions Dependencies AG compiler [Leo & Adam] Tree traversals SideBar Specifications Bi-directional constraints Declarative/relational Directional constraints Operational/functional Attribute Grammar Layout Engine

18

slide-16
SLIDE 16

Ongoing Work

The rubber meets the mud:

– Data visualization: this summer @ Nokia Lab – GUIs, documents will be next – Learn how designers would use and debug Mud

Come see the demos at poster session

– Vertical integration of almost entire browser stack – Give us your ideas for data vis of personal data

19

slide-17
SLIDE 17

Summary

  • Declarative programming for designers (data

visualization, GUIs, documents).

  • Fast layout for big data and small battery. No

search, no fixed-point. Instead, linear time, parallel.

  • Constraints compiler based on two-step
  • synthesis. Local constraints to functions.

Functions to global solver.

20

slide-18
SLIDE 18

That is all folks

21