Scalanimate An educational programming platform on top of Scastie - - PowerPoint PPT Presentation

scalanimate an educational programming platform on top of
SMART_READER_LITE
LIVE PREVIEW

Scalanimate An educational programming platform on top of Scastie - - PowerPoint PPT Presentation

Scalanimate An educational programming platform on top of Scastie Xavier Pantet Scalacenter EPFL January 22, 2018 1/19 Outline Motivation Introduction Already existing solutions Challenges API Implementation Limitations


slide-1
SLIDE 1

1/19

Scalanimate An educational programming platform on top of Scastie

Xavier Pantet

Scalacenter EPFL

January 22, 2018

slide-2
SLIDE 2

2/19

Outline

Motivation Introduction Already existing solutions Challenges API Implementation Limitations Implementation discussion Problems encountered Conclusion Future perspectives Final words

slide-3
SLIDE 3

3/19

Motivation

Introduction

How did you learn programming?

  • 1. Install a bunch of tools you

have no clue about

  • 2. Write a “Hello World”

program

  • 3. Compile and run it ?
  • 4. Realise it’s useless
  • 5. Learn about variables,

functions, ...

  • 6. Your programs are ugly and

unusable

  • 7. No UI and user controls!
slide-4
SLIDE 4

3/19

Motivation

Introduction

How did you learn programming?

  • 1. Install a bunch of tools you

have no clue about

  • 2. Write a “Hello World”

program

  • 3. Compile and run it ?
  • 4. Realise it’s useless
  • 5. Learn about variables,

functions, ...

  • 6. Your programs are ugly and

unusable

  • 7. No UI and user controls!
slide-5
SLIDE 5

3/19

Motivation

Introduction

How did you learn programming?

  • 1. Install a bunch of tools you

have no clue about

  • 2. Write a “Hello World”

program

  • 3. Compile and run it ?
  • 4. Realise it’s useless
  • 5. Learn about variables,

functions, ...

  • 6. Your programs are ugly and

unusable

  • 7. No UI and user controls!
slide-6
SLIDE 6

3/19

Motivation

Introduction

How did you learn programming?

  • 1. Install a bunch of tools you

have no clue about

  • 2. Write a “Hello World”

program

  • 3. Compile and run it ?
  • 4. Realise it’s useless
  • 5. Learn about variables,

functions, ...

  • 6. Your programs are ugly and

unusable

  • 7. No UI and user controls!
slide-7
SLIDE 7

3/19

Motivation

Introduction

How did you learn programming?

  • 1. Install a bunch of tools you

have no clue about

  • 2. Write a “Hello World”

program

  • 3. Compile and run it ?
  • 4. Realise it’s useless
  • 5. Learn about variables,

functions, ...

  • 6. Your programs are ugly and

unusable

  • 7. No UI and user controls!
slide-8
SLIDE 8

3/19

Motivation

Introduction

How did you learn programming?

  • 1. Install a bunch of tools you

have no clue about

  • 2. Write a “Hello World”

program

  • 3. Compile and run it ?
  • 4. Realise it’s useless
  • 5. Learn about variables,

functions, ...

  • 6. Your programs are ugly and

unusable

  • 7. No UI and user controls!
slide-9
SLIDE 9

3/19

Motivation

Introduction

How did you learn programming?

  • 1. Install a bunch of tools you

have no clue about

  • 2. Write a “Hello World”

program

  • 3. Compile and run it ?
  • 4. Realise it’s useless
  • 5. Learn about variables,

functions, ...

  • 6. Your programs are ugly and

unusable

  • 7. No UI and user controls!

dreamincode.net

slide-10
SLIDE 10

3/19

Motivation

Introduction

How did you learn programming?

  • 1. Install a bunch of tools you

have no clue about

  • 2. Write a “Hello World”

program

  • 3. Compile and run it ?
  • 4. Realise it’s useless
  • 5. Learn about variables,

functions, ...

  • 6. Your programs are ugly and

unusable

  • 7. No UI and user controls!

dreamincode.net

slide-11
SLIDE 11

4/19

Motivation

Introduction

How can we do better?

◮ Not having to install

anything

◮ Create visual programs ◮ Provide immediate and

intuitive feedback to the user

◮ Provide useful functions to

make possible writing cool and usable programs

slide-12
SLIDE 12

4/19

Motivation

Introduction

How can we do better?

◮ Not having to install

anything

◮ Create visual programs ◮ Provide immediate and

intuitive feedback to the user

◮ Provide useful functions to

make possible writing cool and usable programs

slide-13
SLIDE 13

4/19

Motivation

Introduction

How can we do better?

◮ Not having to install

anything

◮ Create visual programs ◮ Provide immediate and

intuitive feedback to the user

◮ Provide useful functions to

make possible writing cool and usable programs

slide-14
SLIDE 14

4/19

Motivation

Introduction

How can we do better?

◮ Not having to install

anything

◮ Create visual programs ◮ Provide immediate and

intuitive feedback to the user

◮ Provide useful functions to

make possible writing cool and usable programs

slide-15
SLIDE 15

4/19

Motivation

Introduction

How can we do better?

◮ Not having to install

anything

◮ Create visual programs ◮ Provide immediate and

intuitive feedback to the user

◮ Provide useful functions to

make possible writing cool and usable programs

slide-16
SLIDE 16

5/19

Motivation

Already existing solutions

Figure: Scratch

◮ “Block-assembling” ◮ Fairly simple and intuitive for beginners ◮ Slow ◮ Not a programming language

slide-17
SLIDE 17

5/19

Motivation

Already existing solutions

Figure: Scratch

◮ “Block-assembling” ◮ Fairly simple and intuitive for beginners ◮ Slow ◮ Not a programming language

slide-18
SLIDE 18

5/19

Motivation

Already existing solutions

Figure: Scratch

◮ “Block-assembling” ◮ Fairly simple and intuitive for beginners ◮ Slow ◮ Not a programming language

slide-19
SLIDE 19

5/19

Motivation

Already existing solutions

Figure: Scratch

◮ “Block-assembling” ◮ Fairly simple and intuitive for beginners ◮ Slow ◮ Not a programming language

slide-20
SLIDE 20

5/19

Motivation

Already existing solutions

Figure: Scratch

◮ “Block-assembling” ◮ Fairly simple and intuitive for beginners ◮ Slow ◮ Not a programming language

slide-21
SLIDE 21

6/19

Motivation

Already existing solutions

Figure: WoofJS

◮ Code-based version of Scratch in Javascript ◮ Simple API ◮ Javascript is known to be messy ◮ Main source of inspiration for Scalanimate

slide-22
SLIDE 22

6/19

Motivation

Already existing solutions

Figure: WoofJS

◮ Code-based version of Scratch in Javascript ◮ Simple API ◮ Javascript is known to be messy ◮ Main source of inspiration for Scalanimate

slide-23
SLIDE 23

6/19

Motivation

Already existing solutions

Figure: WoofJS

◮ Code-based version of Scratch in Javascript ◮ Simple API ◮ Javascript is known to be messy ◮ Main source of inspiration for Scalanimate

slide-24
SLIDE 24

6/19

Motivation

Already existing solutions

Figure: WoofJS

◮ Code-based version of Scratch in Javascript ◮ Simple API ◮ Javascript is known to be messy ◮ Main source of inspiration for Scalanimate

slide-25
SLIDE 25

6/19

Motivation

Already existing solutions

Figure: WoofJS

◮ Code-based version of Scratch in Javascript ◮ Simple API ◮ Javascript is known to be messy ◮ Main source of inspiration for Scalanimate

slide-26
SLIDE 26

7/19

Motivation

Already existing solutions

Figure: Doodle

◮ Compositional vector graphics in Scala + Scala.js ◮ Highlights functional programming ◮ Composition, composition and composition ◮ Rather difficult for beginners

slide-27
SLIDE 27

7/19

Motivation

Already existing solutions

Figure: Doodle

◮ Compositional vector graphics in Scala + Scala.js ◮ Highlights functional programming ◮ Composition, composition and composition ◮ Rather difficult for beginners

slide-28
SLIDE 28

7/19

Motivation

Already existing solutions

Figure: Doodle

◮ Compositional vector graphics in Scala + Scala.js ◮ Highlights functional programming ◮ Composition, composition and composition ◮ Rather difficult for beginners

slide-29
SLIDE 29

7/19

Motivation

Already existing solutions

Figure: Doodle

◮ Compositional vector graphics in Scala + Scala.js ◮ Highlights functional programming ◮ Composition, composition and composition ◮ Rather difficult for beginners

slide-30
SLIDE 30

7/19

Motivation

Already existing solutions

Figure: Doodle

◮ Compositional vector graphics in Scala + Scala.js ◮ Highlights functional programming ◮ Composition, composition and composition ◮ Rather difficult for beginners

slide-31
SLIDE 31

7/19

Challenges

slide-32
SLIDE 32

8/19

Challenges

A game is elegant when a small number of basic actions allow the player to do a large number of strategic actions. Jesse Schell

schellgames.com

◮ A simple API for drawings and animations... ◮ ... that offers many possibilities to the end user ◮ Designed for the web (integration into Scastie)

slide-33
SLIDE 33

8/19

Challenges

A game is elegant when a small number of basic actions allow the player to do a large number of strategic actions. Jesse Schell

schellgames.com

What we want:

◮ A simple API for drawings and animations... ◮ ... that offers many possibilities to the end user ◮ Designed for the web (integration into Scastie)

slide-34
SLIDE 34

8/19

Challenges

A game is elegant when a small number of basic actions allow the player to do a large number of strategic actions. Jesse Schell

schellgames.com

What we want:

◮ A simple API for drawings and animations... ◮ ... that offers many possibilities to the end user ◮ Designed for the web (integration into Scastie)

slide-35
SLIDE 35

8/19

Challenges

A game is elegant when a small number of basic actions allow the player to do a large number of strategic actions. Jesse Schell

schellgames.com

What we want:

◮ A simple API for drawings and animations... ◮ ... that offers many possibilities to the end user ◮ Designed for the web (integration into Scastie)

slide-36
SLIDE 36

8/19

Challenges

A game is elegant when a small number of basic actions allow the player to do a large number of strategic actions. Jesse Schell

schellgames.com

What we want:

◮ A simple API for drawings and animations... ◮ ... that offers many possibilities to the end user ◮ Designed for the web (integration into Scastie)

slide-37
SLIDE 37

8/19

User API

slide-38
SLIDE 38

9/19

API

We want the user to be able to:

◮ Draw shapes (circles, rectangles, polygons, ...) ◮ Set fill and border colors ◮ Rotate the shapes ◮ Move them ◮ Show and hide them ◮ Display images ◮ React to basic user input (mouse clicks and key presses) ◮ Detect collisions between shapes and the edges of the drawing

context

slide-39
SLIDE 39

9/19

API

We want the user to be able to:

◮ Draw shapes (circles, rectangles, polygons, ...) ◮ Set fill and border colors ◮ Rotate the shapes ◮ Move them ◮ Show and hide them ◮ Display images ◮ React to basic user input (mouse clicks and key presses) ◮ Detect collisions between shapes and the edges of the drawing

context

slide-40
SLIDE 40

9/19

API

We want the user to be able to:

◮ Draw shapes (circles, rectangles, polygons, ...) ◮ Set fill and border colors ◮ Rotate the shapes ◮ Move them ◮ Show and hide them ◮ Display images ◮ React to basic user input (mouse clicks and key presses) ◮ Detect collisions between shapes and the edges of the drawing

context

slide-41
SLIDE 41

9/19

API

We want the user to be able to:

◮ Draw shapes (circles, rectangles, polygons, ...) ◮ Set fill and border colors ◮ Rotate the shapes ◮ Move them ◮ Show and hide them ◮ Display images ◮ React to basic user input (mouse clicks and key presses) ◮ Detect collisions between shapes and the edges of the drawing

context

Figure: A colored rotated rectangle

slide-42
SLIDE 42

9/19

API

We want the user to be able to:

◮ Draw shapes (circles, rectangles, polygons, ...) ◮ Set fill and border colors ◮ Rotate the shapes ◮ Move them ◮ Show and hide them ◮ Display images ◮ React to basic user input (mouse clicks and key presses) ◮ Detect collisions between shapes and the edges of the drawing

context

Figure: A colored rotated rectangle

slide-43
SLIDE 43

9/19

API

We want the user to be able to:

◮ Draw shapes (circles, rectangles, polygons, ...) ◮ Set fill and border colors ◮ Rotate the shapes ◮ Move them ◮ Show and hide them ◮ Display images ◮ React to basic user input (mouse clicks and key presses) ◮ Detect collisions between shapes and the edges of the drawing

context

Figure: A colored rotated rectangle

slide-44
SLIDE 44

9/19

API

We want the user to be able to:

◮ Draw shapes (circles, rectangles, polygons, ...) ◮ Set fill and border colors ◮ Rotate the shapes ◮ Move them ◮ Show and hide them ◮ Display images ◮ React to basic user input (mouse clicks and key presses) ◮ Detect collisions between shapes and the edges of the drawing

context

Figure: A colored rotated rectangle

slide-45
SLIDE 45

9/19

API

We want the user to be able to:

◮ Draw shapes (circles, rectangles, polygons, ...) ◮ Set fill and border colors ◮ Rotate the shapes ◮ Move them ◮ Show and hide them ◮ Display images ◮ React to basic user input (mouse clicks and key presses) ◮ Detect collisions between shapes and the edges of the drawing

context

Figure: A colored rotated rectangle

slide-46
SLIDE 46

9/19

API

We want the user to be able to:

◮ Draw shapes (circles, rectangles, polygons, ...) ◮ Set fill and border colors ◮ Rotate the shapes ◮ Move them ◮ Show and hide them ◮ Display images ◮ React to basic user input (mouse clicks and key presses) ◮ Detect collisions between shapes and the edges of the drawing

context

Figure: A colored rotated rectangle

slide-47
SLIDE 47

9/19

Implementation

slide-48
SLIDE 48

10/19

Implementation

Classes hierarchy

Figure: Scalanimate’s classes hierarchy

slide-49
SLIDE 49

11/19

Implementation

Click detection

slide-50
SLIDE 50

12/19

Implementation

Animations

Figure: Animations using every()

slide-51
SLIDE 51

13/19

Implementation

Key presses

slide-52
SLIDE 52

13/19

Implementation

Key presses

slide-53
SLIDE 53

13/19

Implementation

Key presses

slide-54
SLIDE 54

13/19

Implementation

Key presses

slide-55
SLIDE 55

14/19

Implementation

Collisions

◮ Separated Axis Theorem (SAT) ◮ Project all the corners of the shapes on the main axes ◮ Only works for convex shapes

Figure: SAT for collision detection

Source: http://www.phailed.me

slide-56
SLIDE 56

14/19

Implementation

Collisions

◮ Separated Axis Theorem (SAT) ◮ Project all the corners of the shapes on the main axes ◮ Only works for convex shapes

Figure: SAT for collision detection

Source: http://www.phailed.me

slide-57
SLIDE 57

14/19

Implementation

Collisions

◮ Separated Axis Theorem (SAT) ◮ Project all the corners of the shapes on the main axes ◮ Only works for convex shapes

Figure: SAT for collision detection

Source: http://www.phailed.me

slide-58
SLIDE 58

14/19

Implementation

Collisions

◮ Separated Axis Theorem (SAT) ◮ Project all the corners of the shapes on the main axes ◮ Only works for convex shapes

Figure: SAT with non convex shapes

slide-59
SLIDE 59

14/19

Limitations

slide-60
SLIDE 60

15/19

Limitations

Implementation discussion

◮ Cumbersome use of Canvas ◮ Strong inheritance to MutableShape ◮ No support for functional programming

slide-61
SLIDE 61

15/19

Limitations

Implementation discussion

◮ Cumbersome use of Canvas ◮ Strong inheritance to MutableShape ◮ No support for functional programming

slide-62
SLIDE 62

15/19

Limitations

Implementation discussion

◮ Cumbersome use of Canvas ◮ Strong inheritance to MutableShape ◮ No support for functional programming

slide-63
SLIDE 63

16/19

Limitations

Problems encountered

◮ Vector graphics ◮ Possible to animate one

element at a time

◮ DOM structure ◮ Slow (?) ◮ Reusing Doodle? ◮ Bitmap images ◮ Fast (?) ◮ No representation for shapes ◮ Needs to be refreshed to

create animations

slide-64
SLIDE 64

16/19

Limitations

Problems encountered

SVG

◮ Vector graphics ◮ Possible to animate one

element at a time

◮ DOM structure ◮ Slow (?) ◮ Reusing Doodle? ◮ Bitmap images ◮ Fast (?) ◮ No representation for shapes ◮ Needs to be refreshed to

create animations

slide-65
SLIDE 65

16/19

Limitations

Problems encountered

SVG

◮ Vector graphics ◮ Possible to animate one

element at a time

◮ DOM structure ◮ Slow (?) ◮ Reusing Doodle? ◮ Bitmap images ◮ Fast (?) ◮ No representation for shapes ◮ Needs to be refreshed to

create animations

slide-66
SLIDE 66

16/19

Limitations

Problems encountered

SVG

◮ Vector graphics ◮ Possible to animate one

element at a time

◮ DOM structure ◮ Slow (?) ◮ Reusing Doodle? ◮ Bitmap images ◮ Fast (?) ◮ No representation for shapes ◮ Needs to be refreshed to

create animations

slide-67
SLIDE 67

16/19

Limitations

Problems encountered

SVG

◮ Vector graphics ◮ Possible to animate one

element at a time

◮ DOM structure ◮ Slow (?) ◮ Reusing Doodle? ◮ Bitmap images ◮ Fast (?) ◮ No representation for shapes ◮ Needs to be refreshed to

create animations

slide-68
SLIDE 68

16/19

Limitations

Problems encountered

SVG

◮ Vector graphics ◮ Possible to animate one

element at a time

◮ DOM structure ◮ Slow (?) ◮ Reusing Doodle? ◮ Bitmap images ◮ Fast (?) ◮ No representation for shapes ◮ Needs to be refreshed to

create animations

slide-69
SLIDE 69

16/19

Limitations

Problems encountered

SVG

◮ Vector graphics ◮ Possible to animate one

element at a time

◮ DOM structure ◮ Slow (?) ◮ Reusing Doodle? ◮ Bitmap images ◮ Fast (?) ◮ No representation for shapes ◮ Needs to be refreshed to

create animations

slide-70
SLIDE 70

16/19

Limitations

Problems encountered

◮ Vector graphics ◮ Possible to animate one

element at a time

◮ DOM structure ◮ Slow (?) ◮ Reusing Doodle?

Canvas

◮ Bitmap images ◮ Fast (?) ◮ No representation for shapes ◮ Needs to be refreshed to

create animations

slide-71
SLIDE 71

16/19

Limitations

Problems encountered

◮ Vector graphics ◮ Possible to animate one

element at a time

◮ DOM structure ◮ Slow (?) ◮ Reusing Doodle?

Canvas

◮ Bitmap images ◮ Fast (?) ◮ No representation for shapes ◮ Needs to be refreshed to

create animations

slide-72
SLIDE 72

16/19

Limitations

Problems encountered

◮ Vector graphics ◮ Possible to animate one

element at a time

◮ DOM structure ◮ Slow (?) ◮ Reusing Doodle?

Canvas

◮ Bitmap images ◮ Fast (?) ◮ No representation for shapes ◮ Needs to be refreshed to

create animations

slide-73
SLIDE 73

16/19

Limitations

Problems encountered

◮ Vector graphics ◮ Possible to animate one

element at a time

◮ DOM structure ◮ Slow (?) ◮ Reusing Doodle?

Canvas

◮ Bitmap images ◮ Fast (?) ◮ No representation for shapes ◮ Needs to be refreshed to

create animations

slide-74
SLIDE 74

16/19

Limitations

Problems encountered

◮ Vector graphics ◮ Possible to animate one

element at a time

◮ DOM structure ◮ Slow (?) ◮ Reusing Doodle?

Canvas

◮ Bitmap images ◮ Fast (?) ◮ No representation for shapes ◮ Needs to be refreshed to

create animations

slide-75
SLIDE 75

16/19

Demo & Conclusion

slide-76
SLIDE 76

17/19

Future perspectives

Integration into Scastie

Figure: Scastie’s current wireframe

slide-77
SLIDE 77

17/19

Future perspectives

Integration into Scastie

Figure: Side-by-side integration

slide-78
SLIDE 78

17/19

Future perspectives

Integration into Scastie

Figure: Separate window integration

slide-79
SLIDE 79

18/19

Future perspectives

Various ideas

◮ Providing a functional API ◮ Developing a teaching environment ◮ Algorithms visualization ◮ Recursive drawing ◮ Extending possibilities

slide-80
SLIDE 80

18/19

Future perspectives

Various ideas

◮ Providing a functional API ◮ Developing a teaching environment ◮ Algorithms visualization ◮ Recursive drawing ◮ Extending possibilities

slide-81
SLIDE 81

18/19

Future perspectives

Various ideas

◮ Providing a functional API ◮ Developing a teaching environment ◮ Algorithms visualization ◮ Recursive drawing ◮ Extending possibilities

slide-82
SLIDE 82

18/19

Future perspectives

Various ideas

◮ Providing a functional API ◮ Developing a teaching environment ◮ Algorithms visualization ◮ Recursive drawing ◮ Extending possibilities

slide-83
SLIDE 83

18/19

Future perspectives

Various ideas

◮ Providing a functional API ◮ Developing a teaching environment ◮ Algorithms visualization ◮ Recursive drawing ◮ Extending possibilities

slide-84
SLIDE 84

19/19

Conclusion

Final words

Thank you! Any questions? :-)