mirror of
https://github.com/processing/processing4.git
synced 2026-02-12 10:00:42 +01:00
81 lines
1.5 KiB
XML
81 lines
1.5 KiB
XML
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
<root>
|
|
<name>class</name>
|
|
|
|
<category>Structure</category>
|
|
|
|
<subcategory></subcategory>
|
|
|
|
<usage>Web & Application</usage>
|
|
|
|
<example>
|
|
<image></image>
|
|
<code>
|
|
// Declare and contruct two objects (h1, h2) from the class HLine
|
|
HLine h1 = new HLine(20, 2.0);
|
|
HLine h2 = new HLine(50, 2.5);
|
|
|
|
void setup()
|
|
{
|
|
size(200, 200);
|
|
framerate(30);
|
|
}
|
|
|
|
void loop() {
|
|
background(204);
|
|
h1.update();
|
|
h2.update();
|
|
}
|
|
|
|
class HLine {
|
|
float ypos, speed;
|
|
HLine (float y, float s) {
|
|
ypos = y;
|
|
speed = s;
|
|
}
|
|
void update() {
|
|
ypos += speed;
|
|
if (ypos > width) {
|
|
ypos = 0;
|
|
}
|
|
line(0, ypos, width, ypos);
|
|
}
|
|
}
|
|
</code>
|
|
</example>
|
|
|
|
<description>
|
|
Keyword used to indicate the declaration of a class. A class is a composite of data and methods (functions) which may be instantiated as objects. The first letter of a class name is usually uppercase to separate it from other kinds of variables. A related tutorial on <a href="http://java.sun.com/docs/books/tutorial/java/concepts/index.html" target="_blank">Object-Oriented Programming</a> is hosted from the Sun website.
|
|
</description>
|
|
|
|
<syntax>
|
|
class <c>ClassName</c> {
|
|
<c>statements</c>
|
|
}
|
|
</syntax>
|
|
|
|
<parameter>
|
|
<label>ClassName</label>
|
|
<description>Any valid variable name</description>
|
|
</parameter>
|
|
|
|
<parameter>
|
|
<label>statements</label>
|
|
<description>any valid statements</description>
|
|
</parameter>
|
|
|
|
<returns></returns>
|
|
|
|
<related>
|
|
Object
|
|
</related>
|
|
|
|
<availability>1.0</availability>
|
|
|
|
<type>Keyword</type>
|
|
|
|
<partof>PDE</partof>
|
|
|
|
|
|
</root>
|