How To Draw With Your Computer

Narrated by Ellie

Creating a New Program

Commenting Your Code

Importing
The Arcade Library

Libraries in Python

  • A library is a set of code you can add to your program for additional functionality.
  • Python calls these "modules."
  • In Python, you module and library mean the same thing.

Specifying Colors

  • arcade.color
  • arcade.csscolor
  • Red-Green-Blue (RGB)

Specifying Colors

Find Links on https://arcade.academy

Specifying Colors

arcade.color

Specifying Colors

arcade.csscolor

RGB Value

Red - Green - Blue

RGB Value

Red - Green - Blue

RGB Value

Red - Green - Blue

What is a "byte"?

Color values go from 0 - 255

How do computers

handle numbers?

Binary numbers are switches

Each 1 or 0 is a "bit"

Binary Numbers

Binary Base 2 - Base 10

0000            0
0001            1
0010            2
0011            3
0100            4
0101            5
0110            6
0111            7
 
Binary Base 2 - Base 10

1000            8
1001            9
1010            10
1011            11
1100            12
1101            13
1110            14
1111            15
 
0000 0000
to
1111 1111

Max Number for a Byte

  • One byte is eight bits
  • 2^8 = 256 combinations
  • A byte can hold 0 - 255
  • (The 0 counts as a combination.)

16-bit numbers

  • 16 one's and zeros
  • 2^16 = 65,536 possible combinations
  • ...or numbers 0 to 65,535

32-bit numbers

  • 32 one's and zeros
  • 2^32 = 4,294,967,296 possible combinations
  • ...or numbers 0 to 4,294,967,295
  • ...or numbers -2,146,483,648 to 2,146,483,645

64-bit numbers

  • 64 one's and zeros
  • 2^64 = 18,446,744,073,709,551,616 possible combinations

Colors

  • One byte for red = 0-255
  • One byte for green = 0-255
  • One byte for blue = 0-255
  • Three bytes total
  • Each byte has 8 bits
  • 8 x 3 = 24 bits

The Coordinate System

Drawing Primitives

Text

Drawing circles, rectangles, lines, and more

Drawing Rectangles

Specifying Parameters
By Name

arcade.draw_arc_outline(300,
                        340,
                        60,
                        100,
                        arcade.csscolor.BLACK,
                        0,
                        180,
                        3,
                        45)
arcade.draw_arc_outline(300,
                        340,
                        60,
                        100,
                        arcade.csscolor.BLACK,
                        0,
                        180,
                        3,
                        45)
arcade.draw_arc_outline(center_x=300,
                        center_y=340,
                        width=60,
                        height=100,
                        color=arcade.csscolor.BLACK,
                        start_angle=0,
                        end_angle=180,
                        border_width=3,
                        tilt_angle=45)

Future Improvements

  • Learn to use variables and expressions for enhanced readability and flexibility.
  • Create our own functions, like draw_tree

Improving Graphics
Performance

Real-World Applications

  • OpenPyXL - Read/write spreadsheets
  • CircuitPython - Control robotics and lights
  • NumPy - Data analytics
  • Beautiful Soup - Web page scraping

Review

  • Learned how to import Python code libraries/modules
  • Learn to call functions from imported module
  • These functions can be used for graphics, spreadsheets, robotics, etc.
  • Colors specified in Red-Green-Blue (RGB) format
  • A bit is a 1 or 0
  • A byte is 8 bits, can hold numbers 0-255
  • Learned how to draw ellipses, arcs, rectangles, triangles, and more.
  • Learned how to look up API documentation

5 How to Draw with Your Computer

By Paul Craven

5 How to Draw with Your Computer

  • 101
Loading comments...

More from Paul Craven