100% found this document useful (5 votes)
149 views

Learn Python Visually Creative Coding With Processing Py 1st Edition Tristan Bunn Download PDF

py

Uploaded by

ilionsaivija
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (5 votes)
149 views

Learn Python Visually Creative Coding With Processing Py 1st Edition Tristan Bunn Download PDF

py

Uploaded by

ilionsaivija
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 62

Download the full version of the textbook now at textbookfull.

com

Learn Python Visually Creative Coding with


Processing py 1st Edition Tristan Bunn

https://textbookfull.com/product/learn-python-
visually-creative-coding-with-processing-py-1st-
edition-tristan-bunn/

Explore and download more textbook at https://textbookfull.com


Recommended digital products (PDF, EPUB, MOBI) that
you can download immediately if you are interested.

Make Getting Started with Processing py Allison Parrish

https://textbookfull.com/product/make-getting-started-with-processing-
py-allison-parrish/

textbookfull.com

Coding Art: The Four Steps to Creative Programming with


the Processing Language Yu Zhang

https://textbookfull.com/product/coding-art-the-four-steps-to-
creative-programming-with-the-processing-language-yu-zhang/

textbookfull.com

Coding Art The Four Steps to Creative Programming with the


Processing Language 1st Edition Yu Zhang Mathias Funk

https://textbookfull.com/product/coding-art-the-four-steps-to-
creative-programming-with-the-processing-language-1st-edition-yu-
zhang-mathias-funk/
textbookfull.com

Transactions on Computational Collective Intelligence XXXV


Ngoc Thanh Nguyen

https://textbookfull.com/product/transactions-on-computational-
collective-intelligence-xxxv-ngoc-thanh-nguyen/

textbookfull.com
Fight or Flight A Brother s Best Friend Novel 1st Edition
Cameron Hart [Hart

https://textbookfull.com/product/fight-or-flight-a-brother-s-best-
friend-novel-1st-edition-cameron-hart-hart/

textbookfull.com

Big bucks the explosion of the art market in the 21st


century Adam

https://textbookfull.com/product/big-bucks-the-explosion-of-the-art-
market-in-the-21st-century-adam/

textbookfull.com

Advanced Data Assimilation for Geosciences Lecture Notes


of the Les Houches School of Physics Special Issue June
2012 1st Edition Eric Blayo
https://textbookfull.com/product/advanced-data-assimilation-for-
geosciences-lecture-notes-of-the-les-houches-school-of-physics-
special-issue-june-2012-1st-edition-eric-blayo/
textbookfull.com

Tease Me Dragons Love Curves 02 0 Sassy Ever After


Universe 49 0 1st Edition Aidy Award

https://textbookfull.com/product/tease-me-dragons-love-
curves-02-0-sassy-ever-after-universe-49-0-1st-edition-aidy-award/

textbookfull.com

Environmental Assessment on Energy and Sustainability by


Data Envelopment Analysis 1st Edition Toshiyuki Sueyoshi

https://textbookfull.com/product/environmental-assessment-on-energy-
and-sustainability-by-data-envelopment-analysis-1st-edition-toshiyuki-
sueyoshi/
textbookfull.com
Graph Structures for Knowledge Representation and
Reasoning Madalina Croitoru

https://textbookfull.com/product/graph-structures-for-knowledge-
representation-and-reasoning-madalina-croitoru/

textbookfull.com
FULL
COLOR

LE ARN PY THON
V I S U A L LY
C R E A T I V E C O D I N G W I T H
P R O C E S S I N G . P Y

TRISTAN BUNN
LEARN PYTHON VISUALLY
LEARN PYTHON
V I S U A L LY
C R E AT I V E CO D I N G W I T H P RO C E S S I N G .P Y

b y Tr is t a n B u nn

San Francisco
LEARN PYTHON VISUALLY. Copyright © 2021 by Tristan Bunn.

All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means,
electronic or mechanical, including photocopying, recording, or by any information storage or retrieval
system, without the prior written permission of the copyright owner and the publisher.

25 24 23 22 21 123456789

ISBN-13: 978-1-7185-0096-9 (print)


ISBN-13: 978-1-7185-0097-6 (ebook)

Publisher: William Pollock


Executive Editor: Barbara Yien
Production Editor: Katrina Taylor
Developmental Editors: Annie Choi and Jill Franklin
Cover Design: Gina Redman
Interior Design: Octopod Studios
Technical Reviewer: Paddy Gaunt
Copyeditor: Sharon Wilkey
Compositor: Craig Woods, Happenstance Type-O-Rama
Proofreader: Emelie Battaglia
Indexer: BIM Creatives, LLC

For information on book distributors or translations, please contact No Starch Press, Inc. directly:
No Starch Press, Inc.
245 8th Street, San Francisco, CA 94103
phone: 1-415-863-9900; [email protected]
www.nostarch.com

Library of Congress Control Number: 2020950273

No Starch Press and the No Starch Press logo are registered trademarks of No Starch Press, Inc. Other
product and company names mentioned herein may be the trademarks of their respective owners. Rather
than use a trademark symbol with every occurrence of a trademarked name, we are using the names only
in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of
the trademark.

The information in this book is distributed on an “As Is” basis, without warranty. While every precaution
has been taken in the preparation of this work, neither the author nor No Starch Press, Inc. shall have any
liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly
or indirectly by the information contained in it.
About the Author
Tristan Bunn kicked off his web design career back in the days of
PlayStation 1, grunge music, and dial-up modems. Since then, he’s worked
on a diverse range of digital projects for varied clients. He’s currently
involved in lecturing, research, and work that blends code, interaction,
interface design, and creativity. Tristan has years of experience teaching
coding for art, games, web, and other creative technologies.

About the Tech Reviewer


Paddy Gaunt studied engineering at Cambridge University (UK), working
in the chemical and gas industries as well as textile manufacturing. Much
of the time, he had the responsibility of implementing IT systems as these
became a more significant part of management and marketing. Since its
launch in 2012, he has been the chief maintainer of the pi3d Python mod-
ule for fast 3D graphics on the Raspberry Pi microcomputer.
BRIEF CONTENTS

Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiii

Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xv

Chapter 1: Hello, World! . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

Chapter 2: Drawing More Complicated Shapes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29

Chapter 3: Introduction to Strings and Working with Text . . . . . . . . . . . . . . . . . . . . . . . . . . 53

Chapter 4: Conditional Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69

Chapter 5: Iteration and Randomness . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85

Chapter 6: Motion and Transformation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105

Chapter 7: Working with Lists and Reading Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133

Chapter 8: Dictionaries and JSON . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159

Chapter 9: Functions and Periodic Motion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175

Chapter 10: Object-Oriented Programming and PVector . . . . . . . . . . . . . . . . . . . . . . . . . 207

Chapter 11: Mouse and Keyboard Interaction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239

Afterword . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255

Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259
CONTE NT S IN DE TA IL

ACKNOWLEDGMENTS XIII

INTRODUCTION XV
Who Is This Book For? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvi
What Is Python Mode for Processing? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvi
What Are Algorithms? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvii
What Is Creative Coding? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xviii
Where Can I Find Help? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xx
Online Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxi
Source Code and Solutions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxi
What’s in This Book? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxi
Let’s Go! . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxii

1
HELLO, WORLD! 1
Processing Installation and Python Mode Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Your First Sketch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Whitespace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Color . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Fills and Strokes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Background Color . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Color Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
2D Primitives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
triangle() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
ellipse() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
quad() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
line() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Challenge #1: Rainbow Task . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Arithmetic Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
Basic Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
Modulo Operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
Arcs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
Challenge #2: Disk Usage Analyzer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28

2
DRAWING MORE COMPLICATED SHAPES 29
Displaying a Grid . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
Drawing Curves Using Catmull-Rom Splines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
Curving Lines with curve() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
Changing Curves with curveTightness() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
Visit https://textbookfull.com
now to explore a rich
collection of eBooks, textbook
and enjoy exciting offers!
Drawing Bézier Curves . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
Using the bezier() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
Positioning Anchor and Control Points . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
Drawing Shapes Using Vertices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
Bézier Vertices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
Using Vector Graphics Software for Generating Shapes . . . . . . . . . . . . . . . . . . . . . . . . 50
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51

3
INTRODUCTION TO STRINGS AND WORKING WITH TEXT 53
Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
Creating Strings in Python . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
Using Concatenation and String Formatting . . . . . . . . . . . . . . . . . . . . . . . . . . 56
Working with String Length . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
String Manipulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
Slice Notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
String Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
Typography . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
Fonts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
Text Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67

4
CONDITIONAL STATEMENTS 69
Control Flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
Conditional Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
The Boolean Data Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
Relational Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
if Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
elif Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
else Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
Logical Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
Challenge #3: Four-Square Task . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83

5
ITERATION AND RANDOMNESS 85
Iteration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
Using Iteration to Draw Concentric Circles . . . . . . . . . . . . . . . . . . . . . . . . . . 86
while Loops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
for Loops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
Challenge #4: Create Line Patterns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
break and continue Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
Randomness . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
random() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
Random Seed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
Truchet Tiles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103

x Contents in Detail
6
MOTION AND TRANSFORMATION 105
Perceiving Motion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
Adding Motion to Processing Sketches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
The draw() and setup() Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
Global Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
Saving Frames . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
Challenge #5: DVD Screensaver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116
Transformations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
Processing Transformation Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120
translate() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120
rotate() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
scale() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
shearX() and shareY() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
pushMatrix() and popMatrix() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
Challenge #6: Analog Clock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132

7
WORKING WITH LISTS AND READING DATA 133
Introducing Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134
Creating and Accessing Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135
Modifying Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
Combining Loops and Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
Drawing Shapes by Using a List of Color Values . . . . . . . . . . . . . . . . . . . . . 140
Looping with enumerate() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143
Creating Lists of Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144
Challenge #7: Breakout Level . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150
Reading Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153
File Formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153
CSV . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154
Challenge #8: Games Sales Chart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158

8
DICTIONARIES AND JSON 159
Introducing Dictionaries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160
Accessing Dictionaries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161
Modifying Dictionaries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162
Nesting Dictionaries and Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162
Combining Loops and Dictionaries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
Iterating Keys . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164
Iterating Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165
Iterating Items . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165
Working with JSON . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167
Understanding JSON Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168
Using Web APIs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169
Reading in JSON Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170
Challenge #9: Coffee Chart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173

Contents in Detail xi
9
FUNCTIONS AND PERIODIC MOTION 175
Defining Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176
Creating a Simple Speech Bubble Function . . . . . . . . . . . . . . . . . . . . . . . . . 176
Drawing Compound Shapes Using a Function . . . . . . . . . . . . . . . . . . . . . . . 179
Adding Arguments and Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181
Using Keyword Arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183
Setting Default Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184
Mixing Positional and Keyword Arguments . . . . . . . . . . . . . . . . . . . . . . . . . 186
Returning Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187
Defining Functions for Periodic Motion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188
An Introduction to Trigonometric Functions . . . . . . . . . . . . . . . . . . . . . . . . . . 190
Circular and Elliptical Motion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192
Sine Waves . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195
Lissajous Curves . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198
Creating Screensaver-Like Patterns with Lissajous Curves . . . . . . . . . . . . . . . . 203
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206

10
OBJECT-ORIENTED PROGRAMMING AND PVECTOR 207
Working with Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208
Defining a New Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209
Creating an Instance from a Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210
Adding Attributes to a Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211
Adding Methods to a Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216
Splitting Your Python Code into Multiple Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222
Programming Movement with Vectors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224
The PVector Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225
Moving an Amoeba with PVector . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226
Adding Many Amoebas to the Simulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233
Challenge #10: Collision Detection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237

11
MOUSE AND KEYBOARD INTERACTION 239
Mouse Interaction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 240
Mouse Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 240
Mouse Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243
Creating a Paint App . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243
Keyboard Interaction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251
Adding Keyboard Shortcuts to the Paint App . . . . . . . . . . . . . . . . . . . . . . . . 251
Challenge #11: Adding Paint App Features . . . . . . . . . . . . . . . . . . . . . . 252
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253

AFTERWORD 255

INDEX 259

xii 
ACKNOWLEDGMENTS

I’ve been a fan of No Starch Press books for years, and I’m thrilled to have
them publish my first book. I’d like to thank everybody there, in particular
my editors, Jill Franklin and Annie Choi, for their invaluable feedback and
direction. Thanks to Paddy Gaunt, the technical reviewer, for checking over
all my code and offering some excellent suggestions to improve it.
Additionally, I’d like to thank the creators, maintainers, and community
surrounding Processing and its related projects, and also the developers of
the Python programming language. You’ve inspired my students and me, and
it’s a privilege to share your hard work with everybody who reads this book.
INTRODUCTION

When I first encountered programming


code, I stared, amazed and bewildered, at
a screen of obscure commands and symbols
and wondered how anybody could understand
it, let alone write it. I’d hit the F5 key, and the program
would magically spawn a cityscape in which two play-
ers, depicted as gorillas, could hurl explosive bananas
at each other. I tried changing a few lines to see what
would happen, and on occasion, it was something pre-
dictable or cool. More often than not, the game would
simply fail to run. In a futile attempt to be helpful, the computer would diag-
nose my errors, rambling on about syntax and “illegal” operations of varying
description.
For some years thereafter, I was content to avoid learning to program.
That began to change when I became interested in making my creative
work more interactive. You may already have encountered a few of the same
barriers that frustrated me. Maybe you were getting by just fine with visual
tools but then hit a wall. Or to your disappointment (and horror?), you dis-
covered that what you sought to accomplish required delving into code.
Software applications, with all of their graphical widgets, make us feel
like we’re in control. The illusion, however, soon fades when you discover
that the tool you desire is missing. Through learning to program, you gain
a true mastery of your computer.

Who Is This Book For?


This book assumes no prior programming experience. It strives to make
the process of learning to program as visual and entertaining as possible.
The content is based on my extensive experience teaching first-time coders,
designers, and interactive media students. The skills and knowledge you’ll
gain are fundamental to programming for an ever-expanding horizon of
creative technologies, such as games, the web, augmented/virtual reality,
and even visual effects for films.
If you’re an artist, student, designer, researcher, or just somebody keen
on picking up coding skills, Python Mode for Processing is excellent for
learning to program in a visual context.
For anybody with prior programming experience, this book would be
useful for learning Python, Python Mode for Processing, or creative coding
techniques.
You may have experience with another visual programming language—
something like Scratch, where you connect together graphical elements like
boxes, icons, and arrows. Python is not such a language—rather, it is a tex-
tual programming language that requires you to type code. To make learn-
ing visual, though, you’ll focus on writing code that produces drawings,
patterns, animations, data visualizations, user interfaces, and simulations.
This approach not only makes for cool-looking graphics, but also helps you
visualize the underlying concepts of programming.

What Is Python Mode for Processing?


Python Mode for Processing combines the Python programming language and
Processing, a development environment for interactive and graphics program-
ming. You’ll also see Python Mode for Processing referred to as Processing.py.
The project started as a command line tool named Processing.py, but its
developer decided to label it Python Mode when it was made available for
the Processing development environment. In this book, you can consider the
terms largely interchangeable.
Python is one of the most popular programming languages in use
today. There are many good reasons for this, but here’s why you should
care. First, Python is a beginner-friendly language. It’s more approachable
than languages like Java or C++, so you’ll find it easier to read, write, and

xvi Introduction
understand. Second, it’s a general-purpose language, suitable for program-
ming artificial intelligence (AI), games, simulations, web applications, and
just about everything in between.
Processing, which has been around since the early 2000s, is composed
of a programming language and an editor for writing and compiling code.
It provides a collection of special commands that allow you to draw, animate,
and handle user input by using code. The creators, Casey Reas and Ben Fry,
developed Processing to make programming more accessible for designers
and artists, although its thriving user base has grown to include researchers,
hobbyists, and educators.
Java is the basis for the original Processing programming language,
but other variants have since appeared, including JavaScript (p5.js) and
Ruby (JRubyArt) versions. In 2010, Jonathan Feinberg created Processing.py,
which you can think of as a sort of extension for Processing that allows you
to write Python instead of Java-esque code.
Both Python and Processing are open source and won’t cost you a cent.
What’s more, you can use them on just about any platform, including Linux,
macOS, and Microsoft Windows.

What Are Algorithms?


You’ll encounter the term algorithm frequently in the domain of pro-
gramming. You can think of an algorithm as a set of rules a computer or
machine must follow to achieve a particular goal. As an example, an algo-
rithm for making a cup of instant coffee would read as follows:

1. Place one teaspoon of coffee granules in a mug.


2. Fill the kettle with water.
3. Switch on the kettle.
4. Once the water has boiled, add 240 ml boiling water to the mug.
5. Add one level teaspoon of sugar to the same mug.
6. Stir the contents.
7. Serve.

However, this set of steps is insufficient for programming a real-life


coffee-making robot. Should the sizes of the mugs vary, smaller ones would
overflow. Furthermore, the robot would ignore any requests for milk or
extra sugar. Computers cannot make any assumptions, and require explicit
and unambiguous direction, communicated in a language that machines
understand—like Python. Learning the Python language may be the hur-
dle you face initially, but as you grow more fluent, the challenge will shift
toward the mastery of algorithmic thinking.

Introduction xvii
What Is Creative Coding?
Creative coding is computer programming for creative output. This broad term
encompasses, but is not limited to, computer-generated audio and visual art,
interactive installations, experimental games, and data visualizations.
Take, for example, Frederic Brodbeck’s Cinemetrics project. Using Python,
Brodbeck developed a program that analyzes DVD movie data to generate
visual fingerprints of films. The fingerprint is an open ring formed from many
segments; a single segment represents a span of 10 shots, and the concentric
bands show the color breakdown for each of those segments. The diagonal
length of each segment indicates the amount of motion. Figure 1 is a
Cinemetrics fingerprint for the film Quantum of Solace (2008).

beginning
end
amount of
motion
1 segment
= 10 shots

chapter
color palette

Figure 1: Quantum of Solace fingerprint, created by Frederic Brodbeck. Screenshot from http://cinemetrics.site/.

The fingerprints can also be animated, in which case motion is instead


visualized using pulsating segments. An interactive interface provides a
selection of presets and filters so that you can arrange fingerprints along-
side one another and make comparisons—for example, between originals
and remakes, different genres, the works of a single director, and so forth.
Figure 2 compares (from left to right) 2001: A Space Odyssey (1968), The
Simpsons Movie (2007), and a soccer match.

xviii Introduction
Figure 2: Fingerprints comparing (left to right) 2001: A Space Odyssey, The Simpsons Movie, and a soccer
match. Screenshots from http://cinemetrics.site/.

Many creative coding projects employ a similar underlying approach, in


which data is fed into a program to influence how it controls output. Music
visualizations with real-time audio synchronization—like those featured
in popular media player software—are a good example. However, you can
experiment with plenty of other data sources, such as web feeds, fitness track-
ers, environmental sensors, and a plethora of public datasets.
In some instances, it’s useful to opt for randomized data values.
Consider procedurally generated game content. As opposed to construct-
ing levels manually, you can program games to generate dungeon layouts,
terrain, narrative elements, and enemy spawn locations automatically. Of
course, such games should include sensible constraints; for instance, a cap
on the total number of enemies that can appear at once, and algorithms
for ensuring that stage layouts are not impossible to traverse.
Game characters may be composed using a random selection of modu-
lar components, or generated entirely from shapes and formulas. As an
example, I’ve written a Processing Python program that generates the
randomized microbial beasties displayed in Figure 3. The code—an adap-
tation of Lieven Menschaert’s NodeBox script Aquatics!—spawns a creature
with a random fill color, shape (defined by something named the superfor-
mula), and no fewer than three eyes. There’s a 70 percent chance that hair
will grow along the creature’s edges, which can be swayed by the force of a
randomly directed current.

Introduction xix
Visit https://textbookfull.com
now to explore a rich
collection of eBooks, textbook
and enjoy exciting offers!
Figure 3: A Processing.py adaption of Lieven Menschaert’s NodeBox script Aquatics!

Countless examples of cool, creative coding projects exist—from


robots that doodle and write poetry, to evolutionary simulators, and even
a program that pores over satellite imagery in search of architecture or
infrastructure that resembles letters (The Aerial Bold Project by Benedikt
Groß and Joey Lee, 2016).
Perhaps this creative coding thing sounds a bit too artsy for you?
Processing also isn’t ideal for that race car sim you’ve always dreamed of
building, and it’s definitely no good for backend web development. That’s
okay. Creative coding with Processing’s Python Mode need not be the ulti-
mate goal of reading this book. Think of it as a starting point for exploring
Python, other frameworks, creative applications for coding, and program-
ming in general.

Where Can I Find Help?


Programming is rewarding, in part because it’s challenging. If you find
yourself struggling with something, do not stress; that’s normal! With a
little perseverance, you’ll soon grasp whatever has you snagged.

xx Introduction
Online Resources
If you’re getting nowhere, reach out to online communities. You’ll find a
dedicated category for Processing.py in the official Processing forum at
https://discourse.processing.org/. You’ll often discover that somebody has already
encountered and received a solution for the challenge you’re facing; if not, go
ahead and create a new topic. Incidentally, the author of this book is known
to lurk about in this friendly and welcoming corner of the internet.
The official Python Mode reference is available at https://py.processing
.org/reference/. Each entry includes a description and brief code example. It’s
handy to keep this web page open while you work in the Processing develop-
ment environment.

Source Code and Solutions


You’ll be typing a lot of code. This is a good thing because the best way
to learn is by doing. At times, however, you might mistype something or
be unable to figure why your code refuses to work. In such instances, it
can be helpful to have access to a complete, working version of the file.
You can access all of the code in this book, as well as solutions to the chal-
lenges in each chapter, at https://github.com/tabreturn/processing.py-book/.
You can also find any updates to this book at https://www.nostarch.com/
Learn-Python-Visually/.

What’s in This Book?


This book begins with the basics and builds up toward more advanced
topics as you progress. Each chapter, therefore, requires a grasp of the
concepts introduced in the chapters preceding it. You’ll be working, step
by step, through a series of practical tasks. You’ll also find some theory,
plenty of visuals, and challenges to consolidate what you’ve learned.
The following outline provides a brief overview of the contents in
each chapter:
Chapter 1: Hello, World!   This chapter covers the installation and
setup procedure for the book and introduces the basics of drawing with
code. You’ll also learn how computers manage color, how you can store
and reuse values (using variables), and how to perform basic arithmetic
operations using Python.
Chapter 2: Drawing More Complicated Shapes   Having covered some
drawing essentials in the first chapter, you’ll move on to drawing more
organic shapes, as opposed to geometric ones. You’ll learn to define
shapes by using points (or vertices) and curves, which enable you to
draw just about any shape with code.
Chapter 3: Introduction to Strings and Working with Text   In this
chapter, you’ll learn how to use Python’s string features to manipulate
text. You’ll also learn how to use Processing functions to draw text to the
display window, in different styles and colors, and in different fonts.

Introduction xxi
Chapter 4: Conditional Statements   This is where you really begin to
think like a programmer. In this chapter, you’ll introduce control flow
to your programs. In other words, you’ll learn how to write programs
that can make decisions, executing different actions to respond to dif-
ferent situations.
Chapter 5: Iteration and Randomness   In this chapter, you’ll learn how
to write programs that can repeat an operation a specified number of
times or until a certain requirement is met. Toward the end of the chap-
ter, you’ll experiment with randomness and creating tiled patterns.
Chapter 6: Motion and Transformation   This chapter focuses primar-
ily on adding motion to your Processing programs and transforming the
drawing space. You’ll also learn how to save frames as images and how to
get time values from your computer. You’ll use these skills to create an
animated screensaver and analog clock.
Chapter 7: Working with Lists and Reading Data   Python lists will
unlock powerful ways to manage and manipulate values in collections.
You’ll explore techniques for data visualization. You’ll also learn to read
in list data from external files. For the final task, you’ll render a chart by
using a CSV file.
Chapter 8: Dictionaries and JSON   Dictionaries are similar to lists
in that they store collections of items. With dictionaries, however, you
access items by using a key (usually a word) instead of referring to the
item position. Once again, you’ll get to use your new dictionary skills
for data visualization. You’ll also learn to work with JSON data.
Chapter 9: Functions and Periodic Motion   You’ll use functions to
divide a program into named sections of reusable code. This will make
your code more modular, and easier to read and modify. You’ll also delve
into some trigonometry for generating elliptical and wave-type motions.
Chapter 10: Object-Oriented Programming and PVector   You can use
object-oriented programming to structure programs by modeling real-
world objects. In this chapter, you’ll employ an object-oriented approach
to building an amoeba simulation. You’ll also learn to program the
amoebas’ motion by using Processing’s PVector class.
Chapter 11: Mouse and Keyboard Interaction   In this chapter, you’ll
add interactivity to your programs. Processing can handle input from
various devices, but here you’ll focus on mouse and keyboard input to
build a paint app. In the process, you’ll learn about event functions and
how to control Processing’s draw loop behavior.

Let’s Go!
The speed at which you progress through these chapters is likely to be influ-
enced by your prior experience in similar areas. If you’ve done any type of
programming before, Python or otherwise, you’ll encounter some familiar
concepts. That said, it’s not a race! Enjoy the ride, stop for breaks, and if
you’re feeling really inspired, feel free to head off-road.

xxii Introduction
1
H E L L O, W O R L D !

When learning a new programming lan­


guage, it’s a long-standing tradition that
the first code you write is to display the
message ‘Hello, World!’ In keeping with that
tradition, you’ll do that here too—but that’s not
all. This chapter introduces everything you need to
understand the fundamentals of Processing, and
you’ll quickly move on from a simple ‘Hello, World!’
to drawing with code.
To get started, you’ll set up Python Mode for Processing so you can create
your own sketches. Along the way, you’ll learn the basic rules of writing code
in Processing, as well as how to deal with errors, use variables, and perform
arithmetic operations. You’ll also learn about how Processing handles color
and how to measure angles using radians. By the end of this chapter, you’ll be
comfortable drawing colorful geometric shapes by using various Processing
functions. Let’s get started.
Processing Installation and Python Mode Setup
Before writing any code, you first need to set up Python Mode for Processing.
Head over to the Processing downloads web page (https://processing.org/
download/) and grab the version of Processing appropriate for your system
(Windows, Linux, or macOS). As of January 2021, Processing 3.5.4 is the lat­
est stable release.
Processing does not employ an installation program. Instead, you simply
extract the file you have downloaded (usually a .zip archive) and run the
application. The exact process varies slightly between operating systems:

• On Windows, unzip all of the contents by right-clicking the file and


selecting Extract All, and then follow the instructions. Extract or move
the folder to any location on your computer, including your Program
Files folder or Desktop.
• On macOS, unzip the file by double-clicking it, and then move the
extracted app to any location on your computer, including your
Applications folder or Desktop.
• The Linux version of Processing is a .tar archive. Extract or move the
folder to any location on your computer, including your home folder
or desktop.

Once you’re finished, open the newly extracted folder. Figure 1-1 shows
an abridged listing of what you can expect to see in your file manager. Next,
locate and run the executable file named processing. On macOS, you’ll just
have a single file named processing.

processing-x.x.x

core
java
lib
modes
tools
processing
... ...

Figure 1-1: The contents of a freshly


extracted processing folder for Windows
or Linux

The application layout may vary slightly among systems and Processing
versions, but the key elements are outlined in Figure 1-2. If you’re a Mac user,
you’ll find the menu bar in its usual position at the top of your screen. Note
that the upper right button in the Processing interface is labeled Java. This is
because Processing comes bundled with Java mode as the default.

2 Chapter 1
Random documents with unrelated
content Scribd suggests to you:
trade friendly societies was proposed but eventually rejected. A
particularly odious feature of the 1799 Act, under which defendants
were required to give evidence against themselves under severe
penalties for refusal, was left unaltered. A series of interesting
clauses providing for the reference of wage disputes to arbitration—
copied from the contemporary Act relating to the cotton trade[119]—
aroused great opposition, as tending “to fix wages” and as involving
the recognition of the Trade Union representative, but they were
finally adopted; without, so far as we are aware, ever being put in
force. [120]
The general Combination Act of 1800 was not merely the codification
of existing laws, or their extension from particular trades to the
whole field of industry. It represented a new and momentous
departure. Hitherto the central or local authority had acted as a
court of appeal on all questions affecting the work and wages of the
citizen. If the master and journeyman failed to agree as to what
constituted a fair day’s wage for a fair day’s work, the higgling of the
market was peremptorily superseded by the authoritative
determination, presumably on grounds of social expediency, of the
standard of remuneration. Probably the actual fixing of wages by
justices of the peace fell very rapidly into disuse as regards the
majority of industries, although formal orders are found in the
minutes of Quarter Sessions during the first quarter of the
nineteenth century, and deep traces of the practice long survived in
the customary rates of hiring. Towards the end of the eighteenth
century, at any rate, free bargaining between the capitalist and his
workmen became practically the sole method of fixing wages. Then
it was that the gross injustice of prohibiting combinations of
journeymen became apparent. “A single master,” said Lord Jeffrey,
“was at liberty at any time to turn off the whole of his workmen at
once—100 or 1000 in number—if they would not accept of the
wages he chose to offer. But it was made an offence for the whole of
the workmen to leave that master at once if he refused to give the
wages they chose to require.”[121] What was even more oppressive
in practice was the employers’ use of the threat of prosecution to
prevent even the beginnings of resistance among the workmen to
any reduction of wages or worsening of conditions.
It is true that the law forbade combinations of employers as well as
combinations of journeymen. Even if it had been impartially carried
out, there would still have remained the inequality due to the fact
that, in the new system of industry, a single employer was himself
equivalent to a very numerous combination. But the hand of justice
was not impartial. The “tacit, but constant” combination of
employers to depress wages, to which Adam Smith refers, could not
be reached by the law. Nor was there any disposition on the part of
the magistrates or the judges to find the masters guilty, even in
cases of flagrant or avowed combination. No one prosecuted the
master cutlers who, in 1814, openly formed the Sheffield Mercantile
and Manufacturing Union, having for its main rule that no merchant
or manufacturer should pay higher prices for any article of Sheffield
make than were current in the preceding year, with a penalty of
£100 for each contravention of this illegal agreement.[122] During
the whole epoch of repression, whilst thousands of journeymen
suffered for the crime of combination, there is no case on record in
which an employer was punished for the same offence.
To the ordinary politician a combination of employers and a
combination of workmen seemed in no way comparable. The former
was, at most, an industrial misdemeanour: the latter was in all cases
a political crime. Under the shadow of the French Revolution, the
English governing classes regarded all associations of the common
people with the utmost alarm. In this general terror lest
insubordination should develop into rebellion were merged both the
capitalist’s objection to high wages and the politician’s dislike of
Democratic institutions. The Combination Laws, as Francis Place tells
us, “were considered as absolutely necessary to prevent ruinous
extortions of workmen, which, if not thus restrained, would destroy
the whole of the Trade, Manufactures, Commerce, and Agriculture of
the nation.... This led to the conclusion that the workmen were the
most unprincipled of mankind. Hence the continued ill-will,
suspicion, and in almost every possible way the bad conduct of
workmen and their employers towards one another. So thoroughly
was this false notion entertained that whenever men were
prosecuted to conviction for having combined to regulate their
wages or the hours of working, however heavy the sentence passed
on them was, and however rigorously it was inflicted, not the
slightest feeling of compassion was manifested by anybody for the
unfortunate sufferers. Justice was entirely out of the question: they
could seldom obtain a hearing before a magistrate, never without
impatience or insult; and never could they calculate on even an
approximation to a rational conclusion.... Could an accurate account
be given of proceedings, of hearings before magistrates, trials at
sessions and in the Court of King’s Bench, the gross injustice, the
foul invective, and terrible punishments inflicted would not, after a
few years have passed away, be credited on any but the best
evidence.” [123]
It must not, however, be supposed that every combination was
made the subject of prosecution, or that the Trade Union leader of
the period passed his whole life in gaol. Owing to the extremely
inefficient organisation of the English police, and the absence of any
public prosecutor, a combination was usually let alone until some
employer was sufficiently inconvenienced by its operations to be
willing himself to set the law in motion. In many cases we find
employers apparently accepting or conniving at their men’s
combinations.[124] The master printers in London not only
recognised the very ancient institution of the “chapel,” but evidently
found it convenient, at any rate from 1785 onwards, to receive and
consider proposals from the journeymen as an organised body. In
1804 we even hear of a joint committee consisting of an equal
number of masters and journeymen, authorised by their respective
bodies to frame regulations for the future payment of labour, and
resulting in the elaborate “scale” of 1805, signed by both masters
and men.[125] The London coopers had a recognised organisation in
1813, in which year a list of prices was agreed upon by
representatives of the masters and men. This list was revised in
1816 and 1819, without any one thinking of a prosecution.[126] The
Trade Union was openly reformed in 1821 as the Philanthropic
Society of Coopers. The London brushmakers in 1805 had “A List of
Prices agreed upon between the Masters and Journeymen,” which is
still extant. The framework knitters, and also the tailors of the
various villages in Nottinghamshire, were, from 1794 to 1810, in the
habit of freely meeting together, both masters and men, “to consider
of matters relative to the trade,” the conferences being convened by
public advertisement.[127] The minute books of the local Trade Union
of the carpenters of Preston for the years 1807 to 1824 chronicle an
apparently unconcealed and unmolested existence, in
correspondence with other carpenters’ societies throughout
Lancashire. The accounts contain no items for the expense of
defending their officers against prosecutions, whereas there are
several payments for advertisements and public meetings, and, be it
added, a very large expenditure in beer. And there is a lively
tradition among the aged block printers of Glasgow that, in their
fathers’ time, when their very active Trade Union exacted a fee of
seven guineas from each new apprentice, this money was always
straightway drunk by the men of the print-field, the employer taking
his seat at the head of the table, and no work being done by any
one until the fund was exhausted. The calico-printers’ organisation
appears, at the early part of the nineteenth century, to have been
one of the strongest and most complete of the Unions. In an
impressive pamphlet of 1815 the men are thus appealed to by the
employers: “We have by turns conceded what we ought all manfully
to have resisted, and you, elated with success, have been led on
from one extravagant demand to another, till the burden is become
too intolerable to be borne. You fix the number of our apprentices,
and oftentimes even the number of our journeymen. You dismiss
certain proportions of our hands, and will not allow others to come
in their stead. You stop all Surface Machines, and go the length even
to destroy the rollers before our face. You restrict the Cylinder
Machine, and even dictate the kind of pattern it is to print. You
refuse, on urgent occasions, to work by candlelight, and even
compel our apprentices to do the same. You dismiss our overlookers
when they don’t suit you; and force obnoxious servants into our
employ. Lastly, you set all subordination and good order at defiance,
and instead of showing deference and respect to your employers,
treat them with personal insult and contempt.”[128] Notwithstanding
all this, no systematic attempt appears to have been made to put
down the calico-printers’ combination, and only one or two isolated
prosecutions can be traced. In Dublin, too, the cabinetmakers in the
early part of the present century were combined in a strong union
called the Samaritan Society, exclusively for trade purposes; “but
though illegal, the employers do not seem to have looked upon it
with any great aversion; and when on one occasion the chief
constable had the men attending a meeting arrested, the employers
came forward to bail them. Indeed, they professed that their object,
though primarily to defend their own interests against the masters,
was also to defend the interests of the masters against unprincipled
journeymen. Many of the masters on receiving the bill of a
journeyman were in the habit of sending it to the trades’ society
committee to be taxed, after which the word Committee was
stamped upon it. One case was mentioned, when between two and
three pounds were knocked off a bill of about eight pounds by the
trade committee.” [129] And both in London and Edinburgh the
journeymen openly published, without fear of prosecution, elaborate
printed lists of piecework prices, compiled sometimes by a
committee of the men’s Trade Union, sometimes by a joint
committee of employers and employed.[130]“The London
Cabinetmakers’ Union Book of Prices,” of which editions were
published in 1811 and 1824, was a costly and elaborate work, with
many plates, published “by a Committee of Masters and Journeymen
... to prevent those litigations which have too frequently existed in
the trade.” Various supplements and “index keys” to this work were
published; and other similar lists exist. So lax was the administration
of the law that George White, the energetic clerk to Hume’s
Committee, asserted that the Act of 1800 had “been in general a
dead letter upon those artisans upon whom it was intended to have
an effect—namely, the shoemakers, printers, papermakers,
shipbuilders, tailors, etc., who have had their regular societies and
houses of call, as though no such Act was in existence; and in fact it
would be almost impossible for many of those trades to be carried
on without such societies, who are in general sick and travelling
relief societies; and the roads and parishes would be much pestered
with these travelling trades, who travel from want of employment,
were it not for their societies who relieve what they call tramps.”
[131]

But although clubs of journeymen might be allowed to take, like the


London bookbinders, “a social pint of porter together,” and even, in
times of industrial peace, to provide for their tramps and perform all
the functions of a Trade Union, the employers had always the power
of meeting any demands by a prosecution. Even those trades in
which we have discovered evidence of the unmolested existence of
combinations furnish examples of the rigorous application of the law.
In 1819 we read of numerous prosecutions of cabinetmakers,
hatters, ironfounders, and other journeymen, nominally for leaving
their work unfinished, but really for the crime of combination.[132] In
1798 five journeymen printers were indicted at the Old Bailey for
conspiracy. The employers had sent for the men’s leaders to discuss
their proposals, when, as it was complained, “the five defendants
came, clothed as delegates, representing themselves as the head of
a Parliament as we may call it.” The men were in fact members of a
trade friendly society of pressmen “held at the Crown, near St.
Dunstan’s Church, Fleet Street,” which, as the prosecuting counsel
declared, “from its appearance certainly bore no reproachable mark
upon it. It was called a friendly society, but by means of some
wicked men among them this society degenerated into a most
abominable meeting for the purpose of a conspiracy; those of the
trade who did not join their society were summoned, and even the
apprentices, and were told unless they conformed to the practices of
these journeymen, when they came out of their times they should
not be employed.” Notwithstanding the fact that the employers had
themselves recognised and negotiated with the society, the Recorder
sentenced all the defendants to two years’ imprisonment. [133]
Twelve years later it was the brutality of another prosecution of the
compositors that impressed Francis Place with the necessity of an
alteration in the law. “The cruel persecutions,” he writes, “of the
Journeymen Printers employed in The Times newspaper in 1810
were carried to an almost incredible extent. The judge who tried and
sentenced some of them was the Common Sergeant of London, Sir
John Sylvester, commonly known by the cognomen of ‘Bloody Black
Jack.’... No judge took more pains than did this judge on the
unfortunate printers, to make it appear that their offence was one of
great enormity, to beat down and alarm the really respectable men
who had fallen into his clutches, and on whom he inflicted
scandalously severe sentences.”[134] Nor did prosecution always
depend on the caprice of an employer. In December 1817 the Bolton
constables, accidentally getting to know that ten delegates of the
calico-printers from the various districts of the kingdom were to
meet on New Year’s Day, arranged to arrest the whole body and
seize all their papers. The ten delegates suffered three months’
imprisonment, although no dispute with their employers was in
progress.[135] But the main use of the law to the employers was to
checkmate strikes, and ward off demands for better conditions of
labour. Already, in 1786, the law of conspiracy had been strained to
convict, and punish with two years’ imprisonment, the five London
bookbinders who were leading a strike to reduce hours from twelve
to eleven.[136] When, at the Aberdeen Master Tailors’ Gild, in 1797,
“it was represented to the trade that their journeymen had entered
into an illegal combination for the purpose of raising their wages,”
the masters unanimously “agreed not to give any additional wages
to their servants,” and backed up this resolution of their own
combination by getting twelve journeymen prosecuted and fined for
the crime of combining.[137] In 1799 the success of the London
shoemakers in picketing obnoxious employers led to the prosecution
of two of them, which was made the means of inducing the men to
consent to dissolve their society, then seven years old, and return to
work at once.[138] Two other shoemakers of York were convicted in
the same year for the crime of “combining to raise the price of their
labour in making shoes, and refusing to make shoes under a certain
price,” and counsel said that “in every great town in the North
combinations of this sort existed.”[139] The coach-makers’ strike of
1819 was similarly stopped, and the “Benevolent Society of
Coachmakers” broken up by the conviction of the general secretary
and twenty other members, who were, upon this condition, released
on their own recognisances.[140] In 1819 some calico-engravers in
the service of a Manchester firm protested against the undue
multiplication of apprentices by their employers, and enforced their
protest by declining to work. For this “conspiracy” they were fined
and imprisoned.[141] And though the master cutlers were allowed,
with impunity, to subscribe to the Sheffield Mercantile and
Manufacturing Union, which fixed the rates of wages, and brought
pressure to bear on recalcitrant employers, the numerous trade
clubs of the operatives were not left unmolested. In 1816 seven
scissor-grinders were sentenced to three months’ imprisonment for
belonging to what they called the “Misfortune Club,” which paid out-
of-work benefit, and sought to maintain the customary rates. [142]
But it was in the new textile industries that the weight of the
Combination Laws was chiefly felt. White and Henson describe the
Act of 1800 as being in these trades “a tremendous millstone round
the neck of the local artisan, which has depressed and debased him
to the earth: every act which he has attempted, every measure that
he has devised to keep up or raise his wages, he has been told was
illegal: the whole force of the civil power and influence of the district
has been exerted against him because he was acting illegally: the
magistrates, acting, as they believed, in unison with the views of the
legislature, to check and keep down wages and combination,
regarded, in almost every instance, every attempt on the part of the
artisan to ameliorate his situation or support his station in society as
a species of sedition and resistance of the Government: every
committee or active man among them was regarded as a turbulent,
dangerous instigator, whom it was necessary to watch and crush if
possible.”[143] To cite one only of the instances, it was given in
evidence before Hume’s Committee that in 1818 certain Bolton
millowners suggested to the operative weavers that they should
concert together to leave the employment of those who paid below
the current rate. Acting on this hint a meeting of forty delegates
took place, at which it was resolved to ask for the advance agreed to
by the good employers. A fortnight later the president and the two
secretaries were arrested, convicted of conspiracy, and imprisoned
for one and two years respectively, although their employers gave
evidence on the prisoners’ behalf to the effect that they had
themselves requested the men to attend the meeting, and had
approved the resolutions passed.[144] In the following year fifteen
cotton-spinners of Manchester, who had met “to receive
contributions to bury their dead,” under “Articles” sanctioned by
Quarter Sessions in 1795, were seized in the committee-room by the
police, and committed to trial for conspiracy, bail being refused. After
three or four months’ imprisonment they were brought to trial, the
whole local bar—seven in number—being briefed against them.
Collections were made in London and elsewhere (including the town
of Lynn in Norfolk) for their defence. The enrolment of their club as
a friendly society availed little. It was urged in court that “all
societies, whether benefit societies or otherwise, were only cloaks
for the people of England to conspire against the State,” and most of
the defendants were sentenced to varying terms of imprisonment.
[145]

But the Scottish Weavers’ Strike of 1812, described in the preceding


chapter, is the most striking case of all. In the previous year certain
cotton-spinners had been convicted of combination and imprisoned,
the judge observing that there was a clear remedy in law, as the
magistrates had full power and authority to fix rates of wages or
settle disputes. In 1812 many of the employers refused to accept the
rates which the justices had declared as fair for weaving; and all the
weavers at the forty thousand looms between Aberdeen and Carlisle
struck to enforce the justices’ rates. The employers had already
made overtures through the sheriff of the county for a satisfactory
settlement when the Government arrested the central committee of
five, who were directing the proceedings. These men were
sentenced to periods of imprisonment varying from four to eighteen
months; the strike failed, and the association broke up.[146] The
student of the newspapers between 1800 and 1824 will find
abundant record of judicial barbarities, of which the cases cited
above may be taken as samples. No statistics exist as to the
frequency of the prosecutions or the severity of the sentences; but it
is easy to understand, from such reports as are available, the sullen
resentment which the working class suffered under these laws. Their
repeal was a necessary preliminary to the growth among the most
oppressed sections of the workers of any real power of protecting
themselves, by Trade Union effort, against the degradation of their
Standard of Life.
The failure of the Combination Laws to suppress the somewhat
dictatorial Trade Unionism of the skilled handicraftsmen, and their
efficacy in preventing the growth of permanent Unions among other
sections of the workers, is explained by class distinctions, now
passed away or greatly modified, which prevailed at the beginning of
the present century. To-day, when we speak of “the aristocracy of
labour” we include under that heading the organised miners and
factory operatives of the North on the same superior footing as the
skilled handicraftsman. In 1800 they were at opposite extremes of
the social scale in the wage-earning class, the weaver and the miner
being then further removed from the handicraftsman than the
docker or general labourer is from the Lancashire cotton-spinner or
Northumberland hewer of to-day. The skilled artisans formed, at any
rate in London, an intermediate class between the shopkeeper and
the great mass of unorganised labourers or operatives in the new
machine industries. The substantial fees demanded all through the
eighteenth century for apprenticeship to the “crafts” had secured to
the members and their eldest sons a virtual monopoly.[147] Even
after the repeal of the laws requiring a formal apprenticeship some
time had to elapse before the supply of this class of handicraftsmen
overtook the growing demand. Thus we gather from the surviving
records that these trades have never been more completely
organised in London than between 1800 and 1820.[148] We find the
London hatters, coopers, curriers, compositors, millwrights, and
shipwrights maintaining earnings which, upon their own showing,
amounted to the comparatively large sum of thirty to fifty shillings
per week. At the same period the Lancashire weaver or the Leicester
hosier, in full competition with steam-power and its accompaniment
of female and child labour, could, even when fully employed, earn
barely ten shillings. We see this difference in the Standard of Life
reflected in the characters of the combinations formed by the two
classes.
In the skilled handicrafts, long accustomed to corporate government,
we find, even under repressive laws, no unlawful oaths, seditious
emblems, or other common paraphernalia of secret societies. The
London Brushmakers, whose Union apparently dates from the early
part of the eighteenth century, expressly insisted “that no person
shall be admitted a member who is not well affected to his present
Majesty and the Protestant Succession, and in good health and of a
respectable character.” But this loyalty was not inconsistent with their
subscribing to the funds of the 1831 agitation for the Reform Bill.
[149] The prevailing tone of the superior workmen down to 1848
was, in fact, strongly Radical; and their leaders took a prominent
part in all the working-class politics of the time. From their ranks
came such organisers as Place, Lovett, and Gast.[150] But wherever
we have been able to gain any idea of their proceedings, their trade
clubs were free from anything that could now be conceived as
political sedition. It was these clubs of handicraftsmen that formed
the backbone of the various “central committees” which dealt with
the main topics of Trade Unionism during the next thirty years. They
it was who furnished such assistance as was given by working men
to the movement for the repeal of the Combination Laws. And their
influence gave a certain dignity and stability to the Trade Union
Movement, without which, under hostile governments, it could never
have emerged from the petulant rebellions of hunger-strikes and
machine-breaking.
The principal effect of the Combination Laws on these well-organised
handicrafts in London, Liverpool, Dublin, and perhaps other towns,
was to make the internal discipline more rigid and the treatment of
non-unionists more arbitrary. Place describes how “in these societies
there are some few individuals who possess the confidence of their
fellows, and when any matter relating to the trade has been talked
over, either at the club or in a separate room, or in a workshop or a
yard, and the matter has become notorious, these men are expected
to direct what shall be done, and they do direct—simply by a hint.
On this the men act; and one and all support those who may be
thrown out of work or otherwise inconvenienced. If matters were to
be discussed as gentlemen seem to suppose they must be, no
resolution would ever be come to. The influence of the men alluded
to would soon cease if the law were repealed. It is the law and the
law alone which causes the confidence of the men to be given to
their leaders. Those who direct are not known to the body, and not
one man in twenty, perhaps, knows the person of any one who
directs. It is a rule among them to ask no questions, and another
rule among them who know most, either to give no answer if
questioned, or an answer to mislead.” [151]
In the new machine industries, on the other hand, the repeated
reductions of wages, the rapid alterations of processes, and the
substitution of women and children for adult male workers, had
gradually reduced the workers to a condition of miserable poverty.
The reports of Parliamentary committees, from 1800 onward,
contain a dreary record of the steady degradation of the Standard of
Life in the textile industries. “The sufferings of persons employed in
the cotton manufacture,” Place writes of this period, “were beyond
credibility: they were drawn into combinations, betrayed,
prosecuted, convicted, sentenced, and monstrously severe
punishments inflicted on them: they were reduced to and kept in the
most wretched state of existence.”[152] Their employers, instead of
being, as in the older handicrafts, little more than master workmen,
recognising the customary Standard of Life of their journeymen,
were often capitalist entrepreneurs, devoting their whole energies to
the commercial side of the business, and leaving their managers to
buy labour in the market at the cheapest possible rate. This labour
was recruited from all localities and many different occupations. It
was brigaded and controlled by despotic laws, enforced by
numerous fines and disciplinary deductions. Cases of gross tyranny
and heartless cruelty are not wanting. Without a common standard,
a common tradition, or mutual confidence, the workers in the new
mills were helpless against their masters. Their ephemeral
combinations and frequent strikes were, as a rule, only passionate
struggles to maintain a bare subsistence wage. In place of the
steady organised resistance to encroachments maintained by the
handicraftsmen, we watch, in the machine industries, the alternation
of outbursts of machine-breaking and outrages, with intervals of
abject submission and reckless competition with each other for
employment. In the conduct of such organisation as there was,
repressive laws had, with the operatives as with the London artisans,
the effect of throwing great power into the hands of a few men.
These leaders were implicitly obeyed in times of industrial conflict,
but the repeated defeats which they were unable to avert prevented
that growth of confidence which is indispensable for permanent
organisation.[153] Both leaders and rank and file, too, were largely
implicated in political seditions, and were the victims of spies and
Ministerial emissaries of all sorts. All these circumstances led to the
prevalence among them of fearful oaths, mystic initiation rites, and
other manifestations of a sensationalism which was sometimes
puerile and sometimes criminal.
The most notorious of these “seditions,” about which little is really
known, was the “Luddite” upheaval of 1811-12, when riotous mobs
of manual workers, acting under some sort of organisation, went
about destroying textile machinery and sometimes wrecking
factories. To what extent this had any direct connection with the
Trade Union Movement seems to us, pending more penetrating
investigation of the unpublished evidence, somewhat uncertain. That
the operatives very generally sympathised with the most violent
protest against the displacement of hand labour by machinery, and
the extreme distress which it was causing, is clear. The Luddite
movement apparently began among the Framework-knitters, who
had long been organised in local clubs, with some rudimentary
federal bond; and the whole direction of the Luddites was often
ascribed, as by the Mayor of Leicester in 1812, to “the Committee of
Framework-knitters, who have as complete an organisation of the
whole body as you could have of a regiment.”[154] But money was
collected from men of other trades, notably bricklayers, masons,
spinners, weavers, and colliers, as well as from the soldiers in some
of the regiments stationed at provincial centres; and such evidence
as we have found points rather to a widespread secret oath-bound
conspiracy, not of the men of any one trade, but of wage-earners of
all kinds. We find an informer stating (June 22, 1812), with what
truth we know not, “that the Union extends from London to
Nottingham, and from thence to Manchester and Carlisle. Small
towns lying between the principal places are not yet organised, such
as Garstang and Burton. Only some of the trades have taken the
first oath. He says there is a second oath taken by suspicious
persons.”[155] On the other hand, it looks as if the various local
Trade Clubs were made use of, in some cases informally, as agents
or branches of the conspiracy.
General Maitland, writing from Buxton (June 22, 1812) to the Home
Secretary, says that, in his opinion, “the whole of this business ...
originated in those constant efforts made by these associations for
many years past to keep up the price of the manufacturers’ wages;
that finding their efforts for this unavailing, both from the
circumstances of the trade and the high price of provisions, they in a
moment of irritation, for which it is but just to say they had
considerable ground from the real state of distress in which they
were placed ... began to think of effecting that by force which they
had ever been trying to do by other means; and that in this state the
oath was introduced.... I believe the whole to be, certainly a most
mischievous, but undefined and indistinct attempt to be in a state of
preparation to do that by force which they had not succeeded in
carrying into effect as they usually did by other means.” The whole
episode has been too much ignored, even by social historians; and
“Byron’s famous speech and Charlotte Brontë’s more famous novel
give to most people their idea of the misery of the time, and of its
cause, the displacement of hand labour by machinery.” [156]
The coal-miners were in many respects even worse off than the
hosiery workers and the cotton weavers. In Scotland they had been
but lately freed from actual serfdom, the final act of emancipation
not having been passed until 1799. In Monmouthshire and South
Wales the oppression of the “tommy shops” of the small employers
was extreme. In the North of England the “yearly bond,” the truck
system, and the arbitrary fines kept the underground workers in
complete subjection. The result is seen in the turbulence of their
frequent “sticks” or strikes, during which troops were often required
to quell their violence. The great strike of 1810 was carried on by an
oath-bound confederacy recruited by the practice of “brothering,” “so
named because the members of the union bound themselves by a
most solemn oath to obey the orders of the brotherhood, under the
penalty of being stabbed through the heart or of having their bowels
ripped up.”[157]
Notwithstanding these differences between various classes of
workers, the growing sense of solidarity among the whole body of
wage-earners rises into special prominence during this period of
tyranny and repression. The trades in which it was usual for men to
tramp from place to place in search of employment had long
possessed, as we have seen, some kind of loose federal organisation
extending throughout the country. In spite of the law of 1797
forbidding the existence of “corresponding societies,” the various
federal organisations of Curriers, Hatters, Calico-printers,
Woolcombers, Woolstaplers, and other handicraftsmen kept up
constant correspondence on trade matters, and raised money for
common trade purposes. In some cases there existed an elaborate
national organisation, with geographical districts and annual
delegate meetings; like that of the Calico-printers who were arrested
by the Bolton constables in 1818. The rules of the Papermakers,[158]
which certainly date from 1803, provide for the division of England
into five districts, with detailed arrangements for representation and
collective action. This national organisation was, notwithstanding
repressive laws, occasionally very effective. We need cite only one
instance, furnished by the Liverpool Ropemakers in 1823. When a
certain firm attempted to put labourers to the work, the local society
of ropespinners informed it that this was “contrary to the regulations
of the trade,” and withdrew all their members. The employers, failing
to get men in Liverpool, sent to Hull and Newcastle, but found that
the Ropespinners’ Society had already apprised the local trade clubs
at those towns. The firm then imported “blacklegs” from Glasgow,
who were met on arrival by the local unionists, inveigled to a “trade
club-house,” and alternately threatened and cajoled out of their
engagements. Finally the head of the firm went to London to
purchase yarn; but the London workmen, finding that the yarn was
for a “struck shop,” refused to complete the order. The last resource
of the employers was an indictment at the Sessions for combination,
but a Liverpool jury, in the teeth of the evidence and the judge’s
summing up, gave a verdict of acquittal. [159]
This solidarity was not confined to the members of a particular
trade. The masters are always complaining that one trade supports
another, and old account books of Trade Unions for this period
abound with entries of sums contributed in aid of disputes in other
trades, either in the same town or elsewhere. Thus the small society
of London Goldbeaters, during the three years 1810-12, lent or gave
substantial sums, amounting in all to £200, to fourteen other trades.
[160] The Home Secretary was informed in 1823 that a combination
of cotton-spinners at Bolton, whose books had been seized, had
received donations, not only from twenty-eight cotton-spinners’
committees in as many Lancashire towns, but also from fourteen
other trades, from coal-miners to butchers.[161] A picturesque
illustration of this brotherly help in need occurs in the account of an
appeal to the Pontefract Quarter Sessions by certain Sheffield cutlers
against their conviction for combination: “The appellants were in
court, but hour after hour passed, and no counsel moved the case.
The reason was a want of funds for the purpose. At last, whilst in
court, a remittance from the clubs in Manchester, to the amount of
one hundred pounds, arrived, and then the counsel was fee’d, and
the case, which, but for the arrival of the money from this town,
must have dropped in that stage, was proceeded with.”[162] And
although the day of Trades Councils had not yet come, it was a
common thing for the various trade societies of a particular town to
unite in sending witnesses to Parliamentary Committees, preparing
petitions to the House of Commons and paying counsel to support
their case, engaging solicitors to prosecute offending employers, and
collecting subscriptions for strikes.[163] This tendency to form joint
committees of local trades was, as we shall see, greatly
strengthened in the agitation against the Combination Laws from
1823-25. With the final abandonment of all legislative protection of
the Standard of Life, and the complete divorce of the worker from
the instruments of production, the wage-earners in the various
industrial centres became indeed ever more conscious of the
widening of the old separate trade disputes into “the class war”
which has characterised the past century.
It is difficult to-day to realise the naïve surprise with which the
employers of that time regarded the practical development of
working-class solidarity. The master witnesses before Parliamentary
Committees, and the judges in sentencing workmen for combination,
are constantly found reciting instances of mutual help to prove the
existence of a widespread “conspiracy” against the dominant classes.
That the London Tailors should send money to the Glasgow
Weavers, or the Goldbeaters to the Ropespinners, seemed to the
middle and upper classes little short of a crime.
The movement for a repeal of the Combination Laws began in a
period of industrial dislocation and severe political repression. The
economic results of the long war, culminating in the comparatively
low prices of the peace for most manufactured products, though not
for wheat, led in 1816 to an almost universal reduction of wages
throughout the country. In open defiance of the law the masters, in
many instances, deliberately combined in agreements to pay lower
rates. This agreement was not confined to the employers in a
particular trade, who may have been confronted by organised bodies
of journeymen, but extended, in some cases, to all employers of
labour in a particular locality. The landowners and farmers of
Tiverton, for instance, at a “numerous and respectable meeting at
the Town Hall” in 1816, resolved “that, in consequence of the low
price of provisions,” not more than certain specified wages should be
given to smiths, carpenters, masons, thatchers, or masons’
labourers.[164] The Compositors, Coopers, Shoemakers, Carpenters,
and many other trades record serious reductions of wages at this
period. In these cases the masters justified their action on the
ground that, owing to the fall of prices, the Standard of Life of the
journeymen would not be depressed. But in the great staple
industries there ensued a cutting competition between employers to
secure orders in a falling market, their method being to undersell
each other by beating down wages below subsistence level—an
operation often aided by the practice, then common, of
supplementing insufficient earnings out of the Poor Rate. This
produced such ruinous results that local protests were soon made.
At Leicester the authorities decided to maintain the men’s
“Statement Price” by agreeing to wholly support out of a voluntary
fund those who could not get work at the full rates. This was bitterly
resented by the neighbouring employers, who seriously
contemplated indicting the lord-lieutenant, mayor, alder-men, clergy,
and other subscribers for criminal conspiracy to keep up wages.[165]
And in 1820 a public meeting of the ratepayers of Sheffield protested
against the “evil of parish pay to supplement earnings,” and
recommended employers to revert to the uniform price list which the
men had gained in 1810.[166] Finally we have the employers
themselves publicly denouncing the ruinous extent to which the
cutting of wages had been carried. A declaration dated June 16,
1819, and signed by fourteen Lancashire manufacturers, regrets that
they have been compelled by the action of a few competitors to
lower wages to the present rates, and strongly condemns any
further reduction; whilst twenty-five of the most eminent calico-
printing firms append an emphatic approval of the protest, and state
“that the system of paying such extremely low wages for
manufacturing labour is injurious to the trade at large.”[167] At
Coventry the ribbon manufacturers combined with the Weavers’
Provident Union to maintain a general adherence to the agreed list
of prices, and in 1819 subscribed together no less than £16,000 to
cover the cost of proceedings with this object. This combination
formed the subject of an indictment at Warwick Assizes, which put
an end to the association, the remaining funds being handed over to
the local “Streets Commissioners” for paving the city. These protests
and struggles of the better employers were in vain. Rates were
reduced and strikes occurred all over the country, and were met, not
by redress or sympathy, but by an outburst of prosecutions and
sentences of more than the usual ferocity. The common law and
ancient statutes were ruthlessly used to supplement the
Combination Acts, often by strained constructions. The Scotch
judges in particular, as an eminent Scotch jurist declared to the
Parliamentary Committee in 1824, applied the criminal procedure of
Scotland to cases of simple combination, from 1813-19, in a way
that he, on becoming Lord Advocate, refused to countenance.[168]
The workers, on attempting some spasmodic preparations for
organised political agitation, were further coerced, in 1819, by the
infamous “Six Acts,” which at one blow suppressed practically all
public meetings, enabled the magistrate to search for arms,
subjected all working-class publications to the crushing stamp duty,
and rendered more stringent the law relating to seditious libels. The
whole system of repression which had characterised the
statesmanship of the Regency culminated at this period in a tyranny
not exceeded by any of the monarchs of the “Holy Alliance.” The
effect of this tyranny was actually to shield the Combination Laws by
turning the more energetic and enlightened working-class leaders
away from all specific reforms to a thorough revolution of the whole
system of Parliamentary representation. Hence there was no popular
movement whatever for the repeal of the Combination Laws. If we
were writing the history of the English working class instead of that
of the Trade Union Movement, we should find in William Cobbett or
“Orator” Hunt, in Samuel Bamford or William Lovett, a truer
representative of the current aspirations of the English artisan at this
time than in the man who now came unexpectedly on the scene to
devise and carry into effect the Trade Union Emancipation of 1824.
Francis Place was a master tailor who had created a successful
business in a shop at Charing Cross. Before setting up for himself he
had worked as a journeyman breeches-maker, and had organised
combinations in his own and other trades. After 1818 he left the
conduct of the business to his son, and devoted his keenly practical
intellect and extraordinary persistency first to the repeal of the
Combination Laws, and next to the Reform Movement. In social
theory he was a pupil of Bentham and James Mill, and his ideal may
be summed up as political Democracy with industrial liberty, or, as
we should now say, thoroughgoing Radical Individualism. No one
who has closely studied his life and work will doubt that, within the
narrow sphere to which his unswerving practicality confined him, he
was the most remarkable politician of his age. His chief merit lay in
his thorough understanding of the art of getting things done. In
agitation, permeation, wire-pulling, Parliamentary lobbying, the
drafting of resolutions, petitions, and bills—in short, of all those
artifices by which a popular movement is first created and then
made effective on the Parliamentary system—he was an inventor
and tactician of the first order. Above all, he possessed in perfection
the rare quality of permitting other people to carry off the credit of
his work, and thus secured for his proposals willing promoters and
supporters, some of the leading Parliamentary figures of the time
owing all their knowledge on his questions to the briefs with which
he supplied them. The invaluable collection of manuscript records
left by him, now in the British Museum, prove that modesty had
nothing to do with his contemptuous readiness to leave the trophies
of victory to his pawns provided his end was attained. He was
thoroughly appreciative of the fact that in every progressive
movement his shop at Charing Cross was the real centre of power
when the Parliamentary stage of a progressive movement was
reached. It remained, from 1807 down to about 1834, the
recognised meeting-place of all the agitators of the time. [169]
It was in watching the effect of the Combination Laws in his own
trade that Place became converted to their repeal. The special laws
of 1720 and 1767, fixing the wages of journeymen tailors, as well as
the general law of 1800 against all combinations, had failed to
regulate wages, to prevent strikes, or to hinder those masters who
wished in times of pressure to engage skilled men, from offering the
bribe of high piecework rates, or even time wages in excess of the
legal limit. Place gave evidence as a master tailor before the Select
Committee of the House of Commons which inquired into the subject
in 1810; and it was chiefly his weighty testimony in favour of
freedom of contract that averted the fresh legal restrictions which a
combination of employers was then openly promoting.[170] This
experience of the practical freedom of employers to combine
intensified Place’s sense of the injustice of denying a like freedom to
the journeymen, whilst the brutal prosecution of the compositors of
the Times in the same year brought home to his mind the severity of
the law. Four years later (1814), as he himself tells us, he “began to
work seriously to procure a repeal of the laws against combinations
of workmen, but for a long time made no visible progress.” The
employers were firmly convinced that combinations of wage-earners
would succeed in securing a great rise of wages, to the serious
detriment of profits. Far from contemplating a repeal of the Act of
1800, they were in 1814 and 1816 pestering the Home Secretary for
legislation of greater stringency as the only safeguard for their
“freedom of enterprise.”[171] The politicians were equally certain that
Trade Union action would raise prices, and thus undermine the
foreign trade upon which the prosperity and international influence
of England depended. The working men themselves afforded in the
first instance no assistance. Those who had suffered legal
prosecution were hopeless of redress from an unreformed
Parliament, and offered no support. One trade, the Spitalfields silk-
weavers, supported the Government because they enjoyed what
they deemed to be the advantage of legal protection from the
lowering of wages by competition.[172] Others were suspicious of the
intervention of one who was himself an employer, and who had not
yet gained recognition as a friend to labour. But Place was
undismayed by hostility and indifference. Knowing that with an
English public the strength of his cause would lie, not in any abstract
reasoning or appeal to natural rights, but in an enumeration of
actual cases of injustice, he made a point of obtaining the particulars
of every trade dispute. He intervened, as he says, in every strike,
sometimes as a mediator, sometimes as an ally of the journeymen.
He opened up a voluminous correspondence with Trade Unions
throughout the kingdom, and wrote innumerable letters to the
newspapers. In 1818 he secured a useful medium in the Gorgon,
[173] a little working-class political newspaper, started by one Wade,
a woolcomber, and subsidised by Bentham and Place himself. This
gained him his two most important disciples, eventually the chief
instruments of his work, J. R. McCulloch and Joseph Hume.
McCulloch, afterwards to gain fame as an economist, was at that
time the editor of the Scotsman, perhaps the most important of the
provincial newspapers. A powerful article based on Place’s facts
which he contributed to the Edinburgh Review in 1823 secured many
converts; and his constant advocacy gave Place’s idea a weight and
notoriety which it had hitherto lacked. Joseph Hume was an even
more important ally. His acknowledged position in the House of
Commons as one of the leaders of the growing party of Philosophic
Radicalism gained for the repeal movement a steadily increasing
support with advanced members of Parliament. Among a certain
section in the House the desirability of freedom of combination
began to be discussed; presently it was considered practicable; and
soon many came to regard it as an inevitable outcome of their
political creed. In 1822 Place thought the time ripe for action; and
Hume accordingly gave notice of his intention to bring in a Bill to
repeal all the laws against combinations.
Place’s manuscripts and letters contain a graphic account of the
wire-pullings and manipulations of the next two years.[174] In these
contemporary pictures of the inner workings of the Parliamentary
system we watch Hume cajoling Huskisson and Peel into granting
him a Select Committee, staving off the less tactful proposals of a
rival M.P.,[175] and finally, in February 1824, packing the Committee
of Inquiry at length appointed. Hume, with some art, had included in
his motion three distinct subjects—the emigration of artisans, the
exportation of machinery and combinations of workmen, all of which
were forbidden by law. To Place and Hume the repeal of the
Combination Laws was the main object; but Huskisson and his
colleagues regarded the Committee as primarily charged with an
inquiry into the possibility of encouraging the rising manufacture of
machinery, which was seriously hampered by the prohibition of sales
to foreign countries. Huskisson tried to induce Hume to omit from
the Committee’s reference all mention of the Combination Laws,
evidently regarding them as only a minor and unimportant part of
the inquiry. But Place and Hume were now masters of the situation;
and for the next few months they devoted their whole time to the
management of the Committee. At first no one seems to have had
any idea that its proceedings were going to be of any moment; and
no trouble was taken by the Ministry with regard to its composition.
“It was with difficulty,” writes Place, “that Mr. Hume could obtain the
names of twenty-one members to compose the Committee; but
when it had sat three days, and had become both popular and
amusing, members contrived to be put upon it; and at length it
consisted of forty-eight members.”[176] Hume, who was appointed
chairman, appears to have taken into his own hands the entire
management of the proceedings. A circular explaining the objects of
the inquiry was sent to the mayor or other public officer of forty
provincial towns, and appeared in the principal local newspapers.
Public meetings were held at Stockport and other towns to depute
witnesses to attend the Committee.[177] Meanwhile Place, who had
by this time acquired the confidence of the chief leaders of the
working class, secured the attendance of artisan witnesses from all
parts of the kingdom. Read in the light of Place’s private records and
daily correspondence with Hume, the proceedings of this
“Committee on Artisans and Machinery” reveal an almost perfect
example of political manipulation. Although no hostile witness was
denied a hearing, it was evidently arranged that the employers who
were favourable to repeal should be examined first, and that the
preponderance of evidence should be on their side. And whilst those
interests which would have been antagonistic to the repeal were
neither professionally represented nor deliberately organised, the
men’s case was marshalled with admirable skill by Place, and fully
brought out by Hume’s examination. Thus the one acted as the
Trade Unionists’ Parliamentary solicitor, and the other as their unpaid
counsel. [178]
Place himself tells us how he proceeded: “The delegates from the
working people had reference to me, and I opened my house to
them. Thus I had all the town and country delegates under my care.
I heard the story which every one of these men had to tell, I
examined and cross-examined them, took down the leading
particulars of each case, and then arranged the matter as briefs for
Mr. Hume, and as a rule, for the guidance of the witnesses, a copy
was given to each.... Each brief contained the principal questions
and answers.... That for Mr. Hume was generally accompanied by an
appendix of documents arranged in order, with a short account of
such proceedings as were necessary to put Mr. Hume in possession
of the whole case. Thus he was enabled to go on with considerable
ease, and to anticipate or rebut objections.” [179]
The Committee sat in private; but Hume’s numerous letters to Place
show how carefully the latter was kept posted up in all the
proceedings: “As the proceedings of the Committee were printed
from day to day for the use of the members, I had a copy sent to
me by Mr. Hume, which I indexed on paper ruled in many columns,
each column having an appropriate head or number. I also wrote
remarks on the margins of the printed evidence; this was copied
daily by Mr. Hume’s secretary, and then returned to me. This
consumed much time, but enabled Mr. Hume to have the whole
mass constantly under his view; and I am very certain that less
pains and care would not have been sufficient to have carried the
business through.” [180]
From Westminster Hall we are transported, by these private notes
for Hume’s use, all now preserved in the British Museum, into the
back parlour of the Charing Cross shop, where the London and
provincial artisan witnesses came for their instructions. “The
workmen,” as Place tells us, “were not easily managed. It required
great care and pains not to shock their prejudices so as to prevent
them doing their duty before the Committee. They were filled with
false notions, all attributing their distresses to wrong causes, which
I, in this state of the business, dared not attempt to remove. Taxes,
machinery, laws against combinations, the will of the masters, the
conduct of magistrates—these were the fundamental causes of all
their sorrows and privations.... I had to discuss everything with them
most carefully, to arrange and prepare everything, and so completely
did these things occupy my time that for more than three months I
had hardly any rest.” [181]
The result of the inquiry was as Hume and Place had ordained. A
series of resolutions in favour of complete freedom of combination
and liberty of emigration was adopted by the Committee, apparently
without dissent. A Bill to repeal all the Combination Laws and to
legalise trade societies was passed through both Houses, within less
than a week, at the close of the session, without either debate or
division. Place and Hume contrived privately to talk over and to
silence the few members who were alive to the situation; and the
measure passed, as Place remarks, “almost without the notice of
members within or newspapers without.”[182] So quietly was the Bill
smuggled through Parliament that the magistrates at a Lancashire
town unwittingly sentenced certain cotton-weavers to imprisonment
for combination some weeks after the laws against that crime had
been repealed. [183]
Place and Hume had, however, been rather too clever. Whilst the
governing classes were quite unconscious that any important
alteration of law or policy had taken place, the unlooked-for success
of Place’s agitation produced, as Nassau Senior describes, “a great
moral effect” in all the industrial centres. “It confirmed in the minds
of the operatives the conviction of the justice of their cause, tardily
and reluctantly, but at last fully, conceded by the Legislature. That
which was morally right in 1824 must have been so, they would
reason, for fifty years before.... They conceived that they had
extorted from the Legislature an admission that their masters must
always be their rivals, and had hitherto been their oppressors, and
that combinations to raise wages, and shorten the time or diminish
the severity of labour, were not only innocent, but meritorious.”[184]
Trade Societies accordingly sprang into existence or emerged into
aggressive publicity on all sides. A period of trade inflation, together
with a rapid rise in the price of provisions, favoured a general
increase of wages. For the next six months the newspapers are full
of strikes and rumours of strikes. Serious disturbances occurred at
Glasgow, where the employers had been exceptionally oppressive,
where the cotton operatives committed several outrages, and where
a general lock-out took place. The cotton-spinners were once more
striking in the Manchester district. The shipping trade of the North-
East Coast was temporarily paralysed by a strong combination of the
seamen on the Tyne and Wear, who refused to sail except with
Unionist seamen and Unionist officers. The Dublin trades, then the
best organised in the kingdom, ruthlessly enforced their bye-laws for
the regulation of their respective industries, and formed a joint
committee, the so-called “Board of Green Cloth,” whose dictates
became the terror of the employers. The Sheffield operatives have to
be warned that, if they persist in demanding double the former
wages for only three days a week work, the whole industry of the
town will be ruined.[185] The London shipwrights insisted on what
their employers considered the preposterous demand for a “book of
rates” for piecework. The London coopers demanded a revision of
their wages, which led to a long-sustained conflict. In fact, as a
provincial newspaper remarked a little later, “it is no longer a
particular class of journeymen at some single point that have been
induced to commence a strike for an advance of wages, but almost
the whole body of the mechanics in the kingdom are combined in
the general resolution to impose terms on their employers.” [186]
The opening of the session of 1825 found the employers throughout
the country thoroughly aroused. Hume and Place had in vain
preached moderation, and warned the Unions of the danger of a
reaction. The great shipowning and shipbuilding interest, which had
throughout the century preserved intact its reputation for
unswerving hostility to Trade Unionism, had possession of the ear of
Huskisson, then President of the Board of Trade and member for
Liverpool. Early in the session he moved for a committee of inquiry
into the conduct of the workmen and the effect of the recent Act,
which, he complained, had been smuggled through the House
without his attention having been called to the fact that it went far
beyond the mere repeal of the special statutes against combinations.
[187] This time the composition of the committee was not left to
chance, or to Hume’s manipulation. The members were, as Place
complains, selected almost exclusively from the Ministerial benches,
twelve out of the thirty being placemen, and many being
representatives of rotten boroughs. Huskisson, [188] Peel, and the
Attorney-General themselves took part in its proceedings; Wallace,
the Master of the Mint, was made chairman, and Hume alone
represented the workmen. Huskisson regarded the Committee as
merely a formal preliminary to the introduction of the Bill which the
shipping interest had drafted,[189] under which Trade Unions, and
even Friendly Societies, would have been impossible. For the inner
history of this Committee we have to rely on Place’s voluminous
memoranda, and Hume’s brief notes to him. According to these, the
original intention was to call only a few employers as witnesses, to
exclude all testimony on the other side, and promptly to report in
favour of the repressive measure already prepared. Place, himself an
expert in such tactics, met them by again supplying Hume daily with
detailed information which enabled him to cross-examine the
masters and expose their exaggerations. And, if Place’s account of
the animus of the Committee and the Ministers against himself be
somewhat highly coloured, we have ample evidence of the success
with which he guided the alarmed Trade Unions to take effectual
action in their own defence. His friend John Gast, secretary to the
London Shipwrights, called for two delegates from each trade in the
metropolis, and formed a committee which kept up a persistent
agitation against any re-enactment of the Combination Laws. Similar
committees were formed at Manchester and Glasgow by the cotton
operatives, at Sheffield by the cutlers, and at Newcastle by the
seamen and shipwrights. Petitions, the draft of which appears in
Place’s manuscripts, poured in to the Select Committee and to both
Houses. If we are to believe Place, the passages leading to the
committee-room were carefully kept thronged by crowds of
workmen insisting on being examined to rebut the accusations of the
employers, and waylaying individual members to whom they
explained their grievances. All this energy on the part of the Unions
was, as Place observes, in marked contrast with their apathy the
year before. The workmen, though they had done nothing to gain
their freedom of association, were determined to maintain it.
Doherty, the leader of the Lancashire Cotton-spinners, writing to
Place in the heat of the agitation, declared that any attempt at a re-
enactment of the Combination Laws would result in a widespread
revolutionary movement. [190] The net result of the inquiry was, on
the whole, satisfactory. The Select Committee found themselves
compelled to hear a certain number of workmen witnesses, who
testified to the good results of the Act of the previous year. The ship-
owners’ Bill was abandoned, and the House of Commons was
recommended to pass a measure which nominally re-established the
general common-law prohibition of combinations, but specifically
excepted from prosecution associations for the purpose of regulating
wages or hours of labour. The master shipbuilders were furious at
this virtual defeat. The handbill is still extant which they distributed
at the doors of the House of Commons on the day of the second
reading of the emasculated Bill.[191] They declared that its
provisions were quite insufficient to save their industry from
destruction. If Trade Unions were to be allowed to exist at all, they
demanded that these bodies should be compelled to render full
accounts of their expenditure to the justices in Quarter Sessions, and
that any diversion of monies raised for friendly society purposes
should be severely punished. They pleaded, moreover, that at any
rate all federal or combined action among trade clubs should be
prohibited. Place and Hume, on the other hand, were afraid, and
subsequent events proved with what good grounds, that the narrow
limits of the trade combinations allowed by the Bill, and still more
the vague terms “molest” and “obstruct,” which it contained, would
be used as weapons against Trade Unionism. The Government,
however, held to the draft of the Committee. The shipbuilders
secured nothing. Hume induced Ministers to give way on some
verbal points, and took three divisions in vain protest against the
measure. Place carried on the agitation to the House of Lords, where
Lord Rosslyn extracted the concession of a right of appeal to Quarter
Sessions, which was afterwards to prove of some practical value.
The Act of 1825 (6 Geo. IV. c. 129)[192]—which became known
among the manufacturers as “Peel’s Act”—though it fell short of the
measure which Place and Hume had so skilfully piloted through
Parliament the year before, effected a real emancipation. The right
of collective bargaining, involving the power to withhold labour from
the market by concerted action, was for the first time expressly
established. And although many struggles remained to be fought
before the legal freedom of Trade Unionism was fully secured, no
overt attempt has since been made to render illegal this first
condition of Trade Union action. [193]
It is a suggestive feature of this, as of other great reforms, that the
men whose faith in its principle, and whose indefatigable industry
and resolution carried it through, were the only ones who proved
altogether mistaken as to its practical consequences. If we read the
lesson of the century aright, the manufacturer was not wholly wrong
when he protested that liberty of combination must make the
workers the ultimate authority in industry, although his narrow fear
as to the driving away of capital and commercial skill and the
reduction of the nation to a dead level of anarchic pauperism were
entirely contradicted by subsequent developments. And the
workman, to whom liberty to combine opened up vistas of indefinite
advancement of his class at the expense of his oppressors, was, we
now see, looking rightly forward, though he, too, greatly
miscalculated the distance before him, and overlooked many
arduous stages of the journey. But what is to be said of the forecasts
of Place and the Philosophic Radicals? “Combinations,” writes Place
to Sir Francis Burdett in 1825, “will soon cease to exist. Men have
been kept together for long periods only by the oppressions of the
laws; these being repealed, combinations will lose the matter which
cements them into masses, and they will fall to pieces. All will be as
orderly as even a Quaker could desire.... He knows nothing of the
working people who can suppose that, when left at liberty to act for
themselves without being driven into permanent associations by the
oppression of the laws, they will continue to contribute money for
distant and doubtful experiments, for uncertain and precarious
benefits. If let alone, combinations—excepting now and then, and
for particular purposes under peculiar circumstances—will cease to
exist.” [194]
It is pleasant to feel that Place was right in regarding the repeal as
beneficial and worthy of his best efforts in its support; but in every
less general respect he and his allies were as wrong as it was
possible for them to be. The first disappointment, however, came to

You might also like