Appendix C. Programming Concepts
Many graphic designers want to use the scripting capability of SVG as described in Chapter 11. If they’re not familiar with programming, they tend to practice what might be called “voodoo scripting.” In the popular-culture stereotype,[27] voodoo works by reciting a mysterious spell and hoping that your enemies die horribly. Voodoo scripting works by copying someone else’s mysterious script into your SVG document and hoping that your document continues to live. We’re under no illusion (nor even a spell) that reading this brief, purposely oversimplified summary will turn you into a master programmer. Our goal is simply to introduce enough of the elementary programming concepts to remove some of the mystery from the scripts that you copy and modify. The particular programming language that we will discuss in this appendix is called ECMA Script;[28] the concepts used in ECMA Script are common to many other programming languages.
Constants
A constant is a fancy word for a number or string of
characters that never changes. Examples are 2
, 2.71828
,
"message"
, and 'communication'
. The last two are called
string constants. In ECMA Script, you can use either single or double
quotes to mark the boundaries of a string. This is good if you ever need
to write things like "O'Reilly & Associates"
or 'There is no "there" there.'
.
You will sometimes see the two Boolean constants true
and false
, which are used for “yes-or-no”
situations.
Variables
A variable is a block ...
Get SVG Essentials now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.