getting_started_with_processing.py.pdf

(13700 KB) Pobierz
Make:
Getting
Started with
Processing.py
Making Interactive Graphics with
Python's Processing Mode
Allison Parrish,
Ben Fry, Casey Reas
Technology & Engineering / Python/Digital Media
Make:
Getting Started with Processing.py
This book by the creators of Processing is the best starting point for
anyone interested in using the Python syntax for making drawings,
animations, and interactive images.
With this handy book, readers can learn how to get started with
interactive graphics even if they have no programming experience.
Processing, a programming environment, makes it easy for anyone to
create visual art in real time. Now Processing.py takes Processing to the
Python programming language!
With
Getting Started with Processing.py,
you’ll learn to make
interactive graphics using Python’s powerful plugin modules!
»
Introduces readers to the world of creative coding without having to
leave the comfortable world of Python
»
Opens Python to a wider audience: artists, designers, educators,
beginners
»
Excellent book for getting young people engaged with computing
»
Written by the authors of the original Processing language and an
expert in Python
Processing.py is a library that starts with the original goal of Processing,
to make coding accessible for artists, designers, educators, and
beginners, and integrates it with the popular programming language
Python.
Get out and start py-rocessing!
US $24.99 CAN $28.99
ISBN: 978-1-4571-8683-7
Make:
makezine.com
Getting
Started with
Processing.py
Allison Parrish, Ben Fry, and
Casey Reas
Getting Started with Processing.py
by Allison Parrish, Ben Fry, and Casey Reas
Copyright © 2016 Maker Media. All rights reserved.
Printed in the United States of America.
Published by Maker Media, Inc., 1160 Battery Street East, Suite 125, San Francisco,
CA 94111.
Maker Media books may be purchased for educational, business, or sales promo-
tional use. Online editions are also available for most titles (http:/
/safaribookson-
line.com).
For more information, contact O’Reilly Media’s institutional sales depart-
ment: 800-998-9938 or
corporate@oreilly.com.
Editor:
Patrick Di Justo
Production Editor:
Nicholas Adams
Copyeditor:
Jasmine Kwityn
Proofreader:
Gillian McGarvey
May 2016:
First Edition
Indexer:
Angela Howard
Interior Designer:
David Futato
Cover Designer:
Karen Montgomery
Illustrator:
Rebecca Demarest
Revision History for the First Edition
2016-05-06: First Release
See
http:/
/oreilly.com/catalog/errata.csp?isbn=9781457186837
for release details.
Make:, Maker Shed, and Maker Faire are registered trademarks of Maker Media, Inc.
The Maker Media logo is a trademark of Maker Media, Inc.
Getting Started with Pro-
cessing.py
and related trade dress are trademarks of Maker Media, Inc.
Many of the designations used by manufacturers and sellers to distinguish their
products are claimed as trademarks. Where those designations appear in this book,
and Maker Media, Inc. was aware of a trademark claim, the designations have been
printed in caps or initial caps.
While every precaution has been taken in the preparation of this book, the publisher
and authors assume no responsibility for errors or omissions, or for damages result-
ing from the use of the information contained herein.
978-1-457-18683-7
[LSI]
Contents
Preface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1/Hello. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
ix
1
Sketching and Prototyping.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Flexibility.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Giants.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Family Tree.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Join In.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5
2/Starting to Code. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Python Mode.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Your First Program.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Example 2-1: Draw an Ellipse.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Example 2-2: Make Circles.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Show.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Save and New.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Share.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Examples and Reference.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
3/Draw. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
13
The Display Window.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Example 3-1: Draw a Window.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Example 3-2: Draw a Point.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Basic Shapes.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Example
Example
Example
Example
Example
Example
3-3:
3-4:
3-5:
3-6:
3-7:
3-8:
Draw
Draw
Draw
Draw
Draw
Draw
a Line.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Basic Shapes.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
a Rectangle.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
an Ellipse.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Part of an Ellipse.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . .
with Degrees.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16
16
16
17
18
19
Drawing Order.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
Example 3-9: Control Your Drawing Order.
. . . . . . . . . . . . . . . . . . . . . . . . . 20
Example 3-10: Put It in Reverse.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
iii
Zgłoś jeśli naruszono regulamin