Skip to content
Browse files

Merge pull request #376 from dingpinglv/iss1306_addcomments

issue #1306 add comments to cc.Image
  • Loading branch information...
2 parents 9f85710 + 8d98afe commit 7e1a45d40a2b2dd3f3a9defdfb672aea64dedb66 @linshun linshun committed Jun 14, 2012
Showing with 258 additions and 72 deletions.
  1. +132 −40 cocos2d/platform/CCImage.js
  2. +25 −32 cocos2d/platform/gzip.js
  3. +101 −0 tools/jsdoc_toolkit/build.xml
View
172 cocos2d/platform/CCImage.js
@@ -23,27 +23,110 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
-var cc = cc = cc || {};
+/**
+ * Image Format:JPG
+ * @constant
+ * @type Number
+ */
cc.FMT_JPG = 0;
+
+/**
+ * Image Format:PNG
+ * @constant
+ * @type Number
+ */
cc.FMT_PNG = 1;
+
+/**
+ * Image Format:RAWDATA
+ * @constant
+ * @type Number
+ */
cc.FMT_RAWDATA = 2;
+
+/**
+ * Image Format:UNKNOWN
+ * @constant
+ * @type Number
+ */
cc.FMT_UNKNOWN = 3;
-cc.ALIGN_CENTER = 0x33; ///< Horizontal center and vertical center.
-cc.ALIGN_TOP = 0x13; ///< Horizontal center and vertical top.
-cc.ALIGN_TOP_RIGHT = 0x12; ///< Horizontal right and vertical top.
-cc.ALIGN_RIGHT = 0x32; ///< Horizontal right and vertical center.
-cc.ALIGN_BOTTOM_RIGHT = 0x22; ///< Horizontal right and vertical bottom.
-cc.ALIGN_BOTTOM = 0x23; ///< Horizontal center and vertical bottom.
-cc.ALIGN_BOTTOM_LEFT = 0x21; ///< Horizontal left and vertical bottom.
-cc.ALIGN_LEFT = 0x31; ///< Horizontal left and vertical center.
-cc.ALIGN_TOP_LEFT = 0x11; ///< Horizontal left and vertical top.
+/**
+ * Horizontal center and vertical center.
+ * @constant
+ * @type Number
+ */
+cc.ALIGN_CENTER = 0x33;
+
+/**
+ * Horizontal center and vertical top.
+ * @constant
+ * @type Number
+ */
+cc.ALIGN_TOP = 0x13;
+
+/**
+ * Horizontal right and vertical top.
+ * @constant
+ * @type Number
+ */
+cc.ALIGN_TOP_RIGHT = 0x12;
+
+/**
+ * Horizontal right and vertical center.
+ * @constant
+ * @type Number
+ */
+cc.ALIGN_RIGHT = 0x32;
+
+/**
+ * Horizontal right and vertical bottom.
+ * @constant
+ * @type Number
+ */
+cc.ALIGN_BOTTOM_RIGHT = 0x22;
+
+/**
+ * Horizontal center and vertical bottom.
+ * @constant
+ * @type Number
+ */
+cc.ALIGN_BOTTOM = 0x23;
+
+/**
+ * Horizontal left and vertical bottom.
+ * @constant
+ * @type Number
+ */
+cc.ALIGN_BOTTOM_LEFT = 0x21;
+
+/**
+ * Horizontal left and vertical center.
+ * @constant
+ * @type Number
+ */
+cc.ALIGN_LEFT = 0x31;
+
+/**
+ * Horizontal left and vertical top.
+ * @constant
+ * @type Number
+ */
+cc.ALIGN_TOP_LEFT = 0x11;
function cc.RGB_PREMULTIPLY_APLHA(vr, vg, vb, va) {
return ((vr * (va + 1)) >> 8) | ((vg * (va + 1) >> 8) << 8) | ((vb * (va + 1) >> 8) << 16) | ((va) << 24)
}
+/**
+ * image source
+ * @Class
+ * @Construct
+ * @param {String} data
+ * @param {Number} size
+ * @param {Number} offset
+ */
function tImageSource(data, size, offset) {
this.data = data;
this.size = size;
@@ -63,7 +146,12 @@ cc.pngReadCallback = function (png_ptr, data, length) {
}
};
-cc.Image = cc.Class.extend({
+/**
+ * Image
+ * @class
+ * @extends cc.Class
+ */
+cc.Image = cc.Class.extend(/** @lends cc.Image# */{
_width:0,
_height:0,
_bitsPerComponent:0,
@@ -72,36 +160,37 @@ cc.Image = cc.Class.extend({
_preMulti:false,
/**
- @brief Load the image from the specified path.
- @param strPath the absolute file path
- @param imageType the type of image, now only support tow types.
- @return true if load correctly
+ * Load the image from the specified path.
+ * @param {String} strPath the absolute file path
+ * @param {Number} eImgFmt the type of image, now only support tow types.
+ * @return {Boolean} true if load correctly
*/
initWithImageFile:function (strPath, eImgFmt) {
var data = new cc.FileData(cc.FileUtils.fullPathFromRelativePath(strPath), "rb");
return this.initWithImageData(data.getBuffer(), data.getSize(), eImgFmt);
},
- /*
- @brief The same meaning as initWithImageFile, but it is thread safe. It is casued by
- loadImage() in CCTextureCache.cpp.
- @param fullpath full path of the file
- @param imageType the type of image, now only support tow types.
- @return true if load correctly
+ /**
+ * The same meaning as initWithImageFile, but it is thread safe. It is casued by loadImage() in cc.TextureCache.
+ * @param {String} fullpath full path of the file
+ * @param {Number} imageType the type of image, now only support tow types.
+ * @return {Boolean} true if load correctly
*/
initWithImageFileThreadSafe:function (fullpath, imageType) {
var data = new cc.FileData(fullpath, "rb");
return this.initWithImageData(data.getBuffer(), data.getSize(), imageType);
},
/**
- @brief Load image from stream buffer.
-
- @warning FMT_RAWDATA only support RGBA8888
- @param pBuffer stream buffer that hold the image data
- @param nLength the length of data(managed in byte)
- @param width, height, nBitsPerComponent are used for FMT_RAWDATA
- @return true if load correctly
+ * Load image from stream buffer.
+ * @warning FMT_RAWDATA only support RGBA8888
+ * @param {Array} pData stream buffer that hold the image data
+ * @param {Number} nDataLen the length of data(managed in byte)
+ * @param {Number} eFmt
+ * @param {Number} width
+ * @param {Number} height
+ * @param {Number} nBitsPerComponent
+ * @return {Boolean} true if load correctly
*/
initWithImageData:function (pData, nDataLen, eFmt, width, height, nBitsPerComponent) {
var ret = false;
@@ -145,10 +234,12 @@ cc.Image = cc.Class.extend({
getBitsPerComponent:function () {
return this._bitsPerComponent;
},
+
/**
- @brief Save the CCImage data to specified file with specified format.
- @param filePath the file's absolute path, including file subfix
- @param isToRGB if the image is saved as RGB format
+ * Save the CCImage data to specified file with specified format.
+ * @param {String} filePath the file's absolute path, including file subfix
+ * @param {Boolean} isToRGB if the image is saved as RGB format
+ * @return {Boolean}
*/
saveToFile:function (filePath, isToRGB) {
var ret = false;
@@ -243,6 +334,7 @@ cc.Image = cc.Class.extend({
return ret;
},
+
_initWithPngData:function (pData, nDatalen) {
var ret = false, header = [0], png_ptr = 0, info_ptr = 0, imateData = 0;
@@ -328,7 +420,7 @@ cc.Image = cc.Class.extend({
return ret;
},
-// @warning FMT_RAWDATA only support RGBA8888
+ // @warning FMT_RAWDATA only support RGBA8888
_initWithRawData:function (data, datalen, width, height, bitsPerComponent) {
var ret = false;
do
@@ -470,6 +562,7 @@ cc.Image = cc.Class.extend({
} while (0);
return ret;
},
+
_saveImageToJPG:function (pszFilePath) {
var ret = false;
do
@@ -545,15 +638,14 @@ cc.Image = cc.Class.extend({
},
/**
- @brief Create image with specified string.
- @param text the text which the image show, nil cause init fail
- @param width the image width, if 0, the width match the text's width
- @param height the image height, if 0, the height match the text's height
- @param eAlignMask the test Alignment
- @param pFontName the name of the font which use to draw the text. If nil, use the default system font.
- @param nSize the font size, if 0, use the system default size.
+ * Create image with specified string.
+ * @param {cc.Texture2D} text the text which the image show, nil cause init fail
+ * @param {Number} width the image width, if 0, the width match the text's width
+ * @param {Number} height the image height, if 0, the height match the text's height
+ * @param {Number} eAlignMask the test Alignment
+ * @param {String} pFontName the name of the font which use to draw the text. If nil, use the default system font.
+ * @param {Number} nSize the font size, if 0, use the system default size.
*/
initWithString:function (text, width, height, eAlignMask, pFontName, nSize) {
-
}
});
View
57 cocos2d/platform/gzip.js
@@ -4,6 +4,11 @@
You can choose between MIT and BSD-3-Clause license. License file will be added later.
--*/
+/**
+ * See cc.Codec.GZip.gunzip.
+ * @param {Array | String} data The bytestream to decompress
+ * @constructor
+ */
cc.Codec.GZip = function Jacob__GZip(data) {
this.data = data;
@@ -28,25 +33,20 @@ cc.Codec.GZip = function Jacob__GZip(data) {
this.fpos[0] = 0;
this.flens = undefined;
this.fmax = undefined;
-}
-
+};
/**
- * cc.Codec.GZip.gunzip(data) -> String
- * - data (Array | String): The bytestream to decompress. Either an array of
- * Integers between 0 and 255, or a String.
- *
- * ## Summary
- *
- * Unzips the gzipped data of the 'data' argument.
- **/
+ * Unzips the gzipped data of the 'data' argument.
+ * @param string The bytestream to decompress. Either an array of Integers between 0 and 255, or a String.
+ * @return {String}
+ */
cc.Codec.GZip.gunzip = function (string) {
if (string.constructor === Array) {
} else if (string.constructor === String) {
}
var gzip = new cc.Codec.GZip(string);
return gzip.gunzip()[0][0];
-}
+};
cc.Codec.GZip.HufNode = function () {
this.b0 = 0;
@@ -55,8 +55,15 @@ cc.Codec.GZip.HufNode = function () {
this.jumppos = -1;
};
-/* Constants */
+/**
+ * @constant
+ * @type Number
+ */
cc.Codec.GZip.LITERALS = 288;
+/**
+ * @constant
+ * @type Number
+ */
cc.Codec.GZip.NAMEMAX = 256;
cc.Codec.GZip.bitReverse = [
@@ -117,7 +124,10 @@ cc.Codec.GZip.cpdext = [
cc.Codec.GZip.border = [16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15];
-/* Instance methods */
+/**
+ * gunzip
+ * @return {Array}
+ */
cc.Codec.GZip.prototype.gunzip = function () {
this.outputArr = [];
@@ -126,7 +136,7 @@ cc.Codec.GZip.prototype.gunzip = function () {
this.nextFile();
return this.unzipped;
-}
+};
cc.Codec.GZip.prototype.readByte = function () {
this.bits += 8;
@@ -222,7 +232,7 @@ cc.Codec.GZip.prototype.Rec = function () {
}
this.len--;
return 0;
-}
+};
cc.Codec.GZip.prototype.CreateTree = function (currentTree, numval, lengths, show) {
var i;
@@ -294,23 +304,6 @@ cc.Codec.GZip.prototype.DeflateLoop = function () {
do {
last = this.readBit();
type = this.readBits(2);
- // switch(type) {
- // case 0:
- // // if (this.debug) alert("Stored\n");
- // break;
- // case 1:
- // // if (this.debug) alert("Fixed Huffman codes\n");
- // break;
- // case 2:
- // // if (this.debug) alert("Dynamic Huffman codes\n");
- // break;
- // case 3:
- // // if (this.debug) alert("Reserved block type!!\n");
- // break;
- // default:
- // // if (this.debug) alert("Unexpected value %d!\n", type);
- // break;
- // }
if (type == 0) {
var blockLen, cSum;
View
101 tools/jsdoc_toolkit/build.xml
@@ -0,0 +1,101 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project name="Test-JsDoc" default="jsdoc" basedir=".">
+
+ <property name="src.dir" location="${basedir}/../../../cocos2d"/>
+
+ <property name="jsdoc.dir" location="${basedir}"/>
+ <property name="rhino.dir" location="${basedir}/java/classes"/>
+ <property name="out.dir" location="${basedir}/out/jsdoc"/>
+
+ <!-- Define the classpath for the Apache Ant task - needs Rhino as well. -->
+ <path id="jsdoc.classpath">
+ <pathelement path="${rhino.dir}/js.jar"/>
+ <pathelement path="${rhino.dir}/jsdoc-toolkit-ant-task-1.1.2.jar"/>
+ </path>
+
+ <!-- Define the Ant Task -->
+ <taskdef name="jsdoctoolkit" classname="uk.co.darrenhurley.ant.tasks.JsDocToolkit" classpathref="jsdoc.classpath"/>
+
+ <!-- This is the default target - it generates the JsDoc documents -->
+ <target name="jsdoc" depends="" description="Generate JsDoc.">
+ <jsdoctoolkit jsdochome="${jsdoc.dir}/" template="jsdoc" outputdir="${out.dir}" includeprivate="false">
+ <source file="${src.dir}/platform/CCClass.js"/>
+ <source file="${src.dir}/platform/CCCommon.js"/>
+ <source file="${src.dir}/platform/platform.js"/>
+ <source file="${src.dir}/platform/ZipUtils.js"/>
+ <source file="${src.dir}/platform/base64.js"/>
+ <source file="${src.dir}/platform/gzip.js"/>
+ <source file="${src.dir}/platform/CCMacro.js"/>
+ <source file="${src.dir}/platform/CCConfig.js"/>
+ <source file="${src.dir}/platform/CCFileUtils.js"/>
+ <source file="${src.dir}/platform/CCTypes.js"/>
+ <source file="${src.dir}/cocoa/CCGeometry.js"/>
+ <source file="${src.dir}/cocoa/CCSet.js"/>
+ <source file="${src.dir}/cocoa/CCNS.js"/>
+ <source file="${src.dir}/cocoa/CCAffineTransform.js"/>
+ <source file="${src.dir}/support/CCPointExtension.js"/>
+ <source file="${src.dir}/base_nodes/CCNode.js"/>
+ <source file="${src.dir}/base_nodes/CCAtlasNode.js"/>
+ <source file="${src.dir}/textures/CCTexture2D.js"/>
+ <source file="${src.dir}/textures/CCTextureCache.js"/>
+ <source file="${src.dir}/textures/CCTextureAtlas.js"/>
+ <source file="${src.dir}/misc_nodes/CCRenderTexture.js"/>
+ <source file="${src.dir}/misc_nodes/CCProgressTimer.js"/>
+ <source file="${src.dir}/actions/CCAction.js"/>
+ <source file="${src.dir}/actions/CCActionInterval.js"/>
+ <source file="${src.dir}/actions/CCActionInstant.js"/>
+ <source file="${src.dir}/actions/CCActionManager.js"/>
+ <source file="${src.dir}/actions/CCActionProgressTimer.js"/>
+ <source file="${src.dir}/actions/CCActionCamera.js"/>
+ <source file="${src.dir}/actions/CCActionEase.js"/>
+ <source file="${src.dir}/actions/CCActionGrid.js"/>
+ <source file="${src.dir}/actions/CCActionTiledGrid.js"/>
+ <source file="${src.dir}/layers_scenes_transitions_nodes/CCScene.js"/>
+ <source file="${src.dir}/layers_scenes_transitions_nodes/CCLayer.js"/>
+ <source file="${src.dir}/layers_scenes_transitions_nodes/CCTransition.js"/>
+ <source file="${src.dir}/layers_scenes_transitions_nodes/CCTransitionRadial.js"/>
+ <source file="${src.dir}/layers_scenes_transitions_nodes/CCTransitionPageTurn.js"/>
+ <source file="${src.dir}/sprite_nodes/CCSprite.js"/>
+ <source file="${src.dir}/sprite_nodes/CCAnimation.js"/>
+ <source file="${src.dir}/sprite_nodes/CCAnimationCache.js"/>
+ <source file="${src.dir}/sprite_nodes/CCSpriteFrame.js"/>
+ <source file="${src.dir}/sprite_nodes/CCSpriteFrameCache.js"/>
+ <source file="${src.dir}/sprite_nodes/CCSpriteBatchNode.js"/>
+ <source file="${src.dir}/label_nodes/CCLabelAtlas.js"/>
+ <source file="${src.dir}/label_nodes/CCLabelTTF.js"/>
+ <source file="${src.dir}/label_nodes/CCLabelBMFont.js"/>
+ <source file="${src.dir}/particle_nodes/CCParticleSystem.js"/>
+ <source file="${src.dir}/particle_nodes/CCParticleSystemQuad.js"/>
+ <source file="${src.dir}/particle_nodes/CCParticleSystemPoint.js"/>
+ <source file="${src.dir}/particle_nodes/CCParticleExamples.js"/>
+ <source file="${src.dir}/touch_dispatcher/CCTouchDelegateProtocol.js"/>
+ <source file="${src.dir}/touch_dispatcher/CCTouchHandler.js"/>
+ <source file="${src.dir}/touch_dispatcher/CCTouchDispatcher.js"/>
+ <source file="${src.dir}/keypad_dispatcher/CCKeypadDelegate.js"/>
+ <source file="${src.dir}/keypad_dispatcher/CCKeypadDispatcher.js"/>
+ <source file="${src.dir}/text_input_node/CCIMEDispatcher.js"/>
+ <source file="${src.dir}/text_input_node/CCTextFieldTTF.js"/>
+ <source file="${src.dir}/CCDirector.js"/>
+ <source file="${src.dir}/CCCamera.js"/>
+ <source file="${src.dir}/CCScheduler.js"/>
+ <source file="${src.dir}/CCLoader.js"/>
+ <source file="${src.dir}/CCDrawingPrimitives.js"/>
+ <source file="${src.dir}/platform/CCApplication.js"/>
+ <source file="${src.dir}/platform/CCSAXParser.js"/>
+ <source file="${src.dir}/platform/AppControl.js"/>
+ <source file="${src.dir}/menu_nodes/CCMenuItem.js"/>
+ <source file="${src.dir}/menu_nodes/CCMenu.js"/>
+ <source file="${src.dir}/tileMap_parallax_nodes/CCTMXTiledMap.js"/>
+ <source file="${src.dir}/tileMap_parallax_nodes/CCTMXXMLParser.js"/>
+ <source file="${src.dir}/tileMap_parallax_nodes/CCTMXObjectGroup.js"/>
+ <source file="${src.dir}/tileMap_parallax_nodes/CCTMXLayer.js"/>
+ <source file="${src.dir}/tileMap_parallax_nodes/CCParallaxNode.js"/>
+ <source file="${src.dir}/../CocosDenshion/SimpleAudioEngine.js"/>
+ </jsdoctoolkit>
+ </target>
+
+ <!-- Neat and Tidy, Tidy and Neat - best to clean up afterwards... -->
+ <target name="clean" description="Cleanup everything this build script creates.">
+ <delete dir="${out.dir}"/>
+ </target>
+</project>

0 comments on commit 7e1a45d

Please sign in to comment.
Something went wrong with that request. Please try again.