1 of 24

Creative Coding in Python

...all you need is a web browser

2 of 24

Who am i?

  • I am Kaustubh Maske Patil
  • I’m a programmer and Free and Open Source (FOSS) enthusiast
  • I like to create art with code for fun
  • I self-host my software!
  • Google Summer of Code @ Postgres
  • 🔗 kaustubh.page
  • 🐤 @n1kochiko

3 of 24

What is Creative Coding

  • In the beginning, there was art
  • Then, there were computers
  • Why not make art with computers?

4 of 24

What’s so good about creative coding?

  • Great way to learn!
  • You can create beautiful things from the start

5 of 24

What is

  • Online non-profit platform to learn programming, managed by FOSS United
  • The most popular course on the platform is The Joy of Programming
  • The course introduces Python through a creative coding library called Joy
  • From mon.school, we also get access to a Python interpreter where we can run our code and see the output

6 of 24

Navigating mon.school

  • Go to mon.school
  • Explore → Sketches → Submit a sketch

See next page for visuals…

7 of 24

1

2

3

8 of 24

Basic Shapes

  • Circle
  • Rectangle
  • Line

9 of 24

Circle

  • By default, grid of 300x300 pixels
  • Circle has default radius 100px

10 of 24

Circle - customising

  • Optionally, can take radius as argument r.

11 of 24

Rectangle

  • Like circle, rectangle is also centered at (0, 0) by default
  • Default height: 100px
  • Default width: 200px

12 of 24

Rectangle – customising

  • w: width of rectangle
  • h: height of rectangle

13 of 24

Line

  • Optionally, takes x1, y1, x2, y2.
  • (x1, y1) are coordinates of starting point
  • (x2, y2) are coordinates of ending point

14 of 24

Combining shapes

  • We can show multiple shapes, one on top of another
  • Let’s draw concentric circles

15 of 24

Transforming shapes – moving shapes around

  • translate(x=..., y=...) can be applied
  • E.g. if you want to move a shape to the right, give positive x value (number of pixels to move to the right)

16 of 24

Transforming shapes – big and small

  • Shapes can be made big or small with the scale(...) transformation
  • If value > 1, then�shape will be�bigger
  • If value < 1, then�shape will be�smaller
  • Concentric circles!

17 of 24

Transforming shapes – rotation

  • Shapes can be rotated anticlockwise by a certain number of degrees with the rotate(...) transformation

18 of 24

Repeating transformations

  • We saw transformations – translate, scale, rotate
  • We can apply transformations repeatedly to get patterns with repeat(n, transformation)

19 of 24

Fun with repeating transformations

“Where did the circle come from?”

20 of 24

More repeating transformations

  • You can combine transformations. Let’s rotate and scale

21 of 24

Colors

  • Every shape takes a fill and stroke argument
  • e.g.

22 of 24

Colors

  • And stroke is for the borders
  • You can also remove border by setting stroke to “none”

23 of 24

Combining colors and transformations

24 of 24

Thank You!