2016 Update
This commit is contained in:
parent
948b86eafa
commit
dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions
29
Task/Classes/SuperCollider/classes-1.supercollider
Normal file
29
Task/Classes/SuperCollider/classes-1.supercollider
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
SpecialObject {
|
||||
|
||||
classvar a = 42, <b = 0, <>c; // Class variables. 42 and 0 are default values.
|
||||
var <>x, <>y; // Instance variables.
|
||||
// Note: variables are private by default. In the above, "<" creates a getter, ">" creates a setter
|
||||
|
||||
*new { |value|
|
||||
^super.new.init(value) // constructor is a class method. typically calls some instance method to set up, here "init"
|
||||
}
|
||||
|
||||
init { |value|
|
||||
x = value;
|
||||
y = sqrt(squared(a) + squared(b))
|
||||
}
|
||||
|
||||
// a class method
|
||||
*randomizeAll {
|
||||
a = 42.rand;
|
||||
b = 42.rand;
|
||||
c = 42.rannd;
|
||||
}
|
||||
|
||||
// an instance method
|
||||
coordinates {
|
||||
^Point(x, y) // The "^" means to return the result. If not specified, then the object itself will be returned ("^this")
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
3
Task/Classes/SuperCollider/classes-2.supercollider
Normal file
3
Task/Classes/SuperCollider/classes-2.supercollider
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
SpecialObject.randomizeAll;
|
||||
a = SpecialObject(8);
|
||||
a.coordinates;
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
MyClass {
|
||||
classvar someVar, <another, <>thirdVar; // Class variables.
|
||||
var <>something, <>somethingElse; // Instance variables.
|
||||
// Note: variables are private by default. In the above, "<" enables getting, ">" enables setting
|
||||
|
||||
*new {
|
||||
^super.new.init // constructor is a class method. typically calls some instance method to set up, here "init"
|
||||
}
|
||||
|
||||
init {
|
||||
something = thirdVar.squared;
|
||||
somethingElse = this.class.name;
|
||||
}
|
||||
|
||||
*aClassMethod {
|
||||
^ someVar + thirdVar // The "^" means to return the result. If not specified, then the object itself will be returned ("^this")
|
||||
}
|
||||
|
||||
anInstanceMethod {
|
||||
something = something + 1;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue