mirror of
https://github.com/readthedocs/sphinx-autoapi
synced 2024-11-08 07:10:31 +00:00
54 lines
1.2 KiB
JavaScript
54 lines
1.2 KiB
JavaScript
|
/**
|
||
|
* Creates an instance of Circle.
|
||
|
*
|
||
|
* @constructor
|
||
|
* @this {Circle}
|
||
|
* @param {number} r The desired radius of the circle.
|
||
|
*/
|
||
|
function Circle(r) {
|
||
|
/** @private */ this.radius = r;
|
||
|
/** @private */ this.circumference = 2 * Math.PI * r;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Creates a new Circle from a diameter.
|
||
|
*
|
||
|
* @param {number} d The desired diameter of the circle.
|
||
|
* @return {Circle} The new Circle object.
|
||
|
*/
|
||
|
Circle.fromDiameter = function (d) {
|
||
|
return new Circle(d / 2);
|
||
|
};
|
||
|
|
||
|
/**
|
||
|
* Calculates the circumference of the Circle.
|
||
|
*
|
||
|
* @deprecated
|
||
|
* @this {Circle}
|
||
|
* @return {number} The circumference of the circle.
|
||
|
*/
|
||
|
Circle.prototype.calculateCircumference = function () {
|
||
|
return 2 * Math.PI * this.radius;
|
||
|
};
|
||
|
|
||
|
/**
|
||
|
* Returns the pre-computed circumference of the Circle.
|
||
|
*
|
||
|
* @this {Circle}
|
||
|
* @return {number} The circumference of the circle.
|
||
|
*/
|
||
|
Circle.prototype.getCircumference = function () {
|
||
|
return this.circumference;
|
||
|
};
|
||
|
|
||
|
/**
|
||
|
* Find a String representation of the Circle.
|
||
|
*
|
||
|
* @override
|
||
|
* @this {Circle}
|
||
|
* @return {string} Human-readable representation of this Circle.
|
||
|
*/
|
||
|
Circle.prototype.toString = function () {
|
||
|
return "A Circle object with radius of " + this.radius + ".";
|
||
|
};
|