#ifndef __CCTYPES_H__

#define __CCTYPES_H__

#include <string>

#include "cocoa/CCGeometry.h"

#include "CCGL.h"

NS_CC_BEGIN

/** RGB color composed(组成) of bytes 3 bytes

@since v0.8

*/

typedef struct _ccColor3B

{

GLubyte r;

/

typedef unsigned char   GLubyte;

GLubyte g;

GLubyte b;

} ccColor3B;

//! helper macro(宏) that creates an ccColor3B type  //ccc3 用于创建一个ccColor3B type的宏

static inline ccColor3B

ccc3(const GLubyte r, const GLubyte g, const GLubyte b)

{

ccColor3B c = {r, g, b};

return c;

}

/** returns true if both ccColor3B are equal. Otherwise it returns false.

*/

static inline bool ccc3BEqual(const ccColor3B &col1, const ccColor3B &col2)  //判断两个cccolor3b是否相同

{

return col1.r == col2.r && col1.g == col2.g && col1.b == col2.b;

}

//ccColor3B predefined(预先定义的) colors

//! White color (255,255,255)

static const ccColor3B ccWHITE={255,255,255};

//! Yellow color (255,255,0)

static const ccColor3B ccYELLOW={255,255,0};

//! Blue color (0,0,255)

static const ccColor3B ccBLUE={0,0,255};

//! Green Color (0,255,0)

static const ccColor3B ccGREEN={0,255,0};

//! Red Color (255,0,0,)

static const ccColor3B ccRED={255,0,0};

//! Magenta Color (255,0,255)

static const ccColor3B ccMAGENTA={255,0,255};

//! Black Color (0,0,0)

static const ccColor3B ccBLACK={0,0,0};

//! Orange Color (255,127,0)

static const ccColor3B ccORANGE={255,127,0};

//! Gray Color (166,166,166)

static const ccColor3B ccGRAY={166,166,166};

/** RGBA color composed(组成) of 4 bytes

*/

typedef struct _ccColor4B

{

GLubyte r;

GLubyte g;

GLubyte b;

GLubyte a;

} ccColor4B;

//! helper macro that creates an ccColor4B type  //ccc4 用于创建一个ccColor3B type的宏

static inline ccColor4B

ccc4(const GLubyte r, const GLubyte g, const GLubyte b, const GLubyte o)

{

ccColor4B c = {r, g, b, o};

return c;

}

/** RGBA color composed of 4 floats

@since v0.8

*/

typedef struct _ccColor4F {

GLfloat r;

GLfloat g;

GLfloat b;

GLfloat a;

} ccColor4F;

/** Returns a ccColor4F from a ccColor3B. Alpha will be 1.

@since v0.99.1

*/

static inline ccColor4F ccc4FFromccc3B(ccColor3B c)

{

ccColor4F c4 = {c.r/255.f, c.g/255.f, c.b/255.f, 1.f};

return c4;

}

//! helper that creates a ccColor4f type

static inline ccColor4F

ccc4f(const GLfloat r, const GLfloat g, const GLfloat b, const GLfloat a)

{

ccColor4F c4 = {r, g, b, a};

return c4;

}

/** Returns a ccColor4F from a ccColor4B.

@since v0.99.1

*/

static inline ccColor4F ccc4FFromccc4B(ccColor4B c)

{

ccColor4F c4 = {c.r/255.f, c.g/255.f, c.b/255.f, c.a/255.f};

return c4;

}

static inline ccColor4B ccc4BFromccc4F(ccColor4F c)

{

ccColor4B ret = {(GLubyte)(c.r*255), (GLubyte)(c.g*255), (GLubyte)(c.b*255), (GLubyte)(c.a*255)};

return ret;

}

/** returns YES if both ccColor4F are equal. Otherwise it returns NO.

@since v0.99.1

*/

static inline bool ccc4FEqual(ccColor4F a, ccColor4F b)

{

return a.r == b.r && a.g == b.g && a.b == b.b && a.a == b.a;

}

/** A vertex composed of 2 floats: x, y

@since v0.8

*/

typedef struct _ccVertex2F  //向量

{

GLfloat x;

GLfloat y;

} ccVertex2F;

static inline ccVertex2F vertex2(const float x, const float y)  //vertex2 创建向量

{

ccVertex2F c = {x, y};

return c;

}

/** A vertex composed of 2 floats: x, y

@since v0.8

*/

typedef struct _ccVertex3F //三维向量

{

GLfloat x;

GLfloat y;

GLfloat z;

} ccVertex3F;

static inline ccVertex3F vertex3(const float x, const float y, const float z) //vertex3创建三维向量

{

ccVertex3F c = {x, y, z};

return c;

}

/** A texcoord composed of 2 floats: u, y

@since v0.8

*/

typedef struct _ccTex2F {   //纹理坐标

GLfloat u;

GLfloat v;

} ccTex2F;

static inline ccTex2F tex2(const float u, const float v)//tex2 创建纹理坐标

{

ccTex2F t = {u , v};

return t;

}

//! Point Sprite component

typedef struct _ccPointSprite

{

ccVertex2F    pos;        // 8 bytes

ccColor4B    color;        // 4 bytes

GLfloat        size;        // 4 bytes

} ccPointSprite;

//!    A 2D Quad. 4 * 2 floats    //图块 4个顶点(ccVertex2F)组成

typedef struct _ccQuad2 {

ccVertex2F        tl;

ccVertex2F        tr;

ccVertex2F        bl;

ccVertex2F        br;

} ccQuad2;

//!    A 3D Quad. 4 * 3 floats

typedef struct _ccQuad3 {     //3d图块 4个顶点(ccVertex3F)组成

ccVertex3F        bl;

ccVertex3F        br;

ccVertex3F        tl;

ccVertex3F        tr;

} ccQuad3;

//! a Point with a vertex point, a tex coord point and a color 4B

typedef struct _ccV2F_C4B_T2F     //采用2维向量 4b颜色 的ccpoint

{

//! vertices (2F)

ccVertex2F        vertices;

//! colors (4B)

ccColor4B        colors;

//! tex coords (2F)

ccTex2F            texCoords;

} ccV2F_C4B_T2F;

//! a Point with a vertex point, a tex coord point and a color 4F

typedef struct _ccV2F_C4F_T2F     //采用2维向量 4f颜色 的ccpoint

{

//! vertices (2F)

ccVertex2F        vertices;

//! colors (4F)

ccColor4F        colors;

//! tex coords (2F)

ccTex2F            texCoords;

} ccV2F_C4F_T2F;

//! a Point with a vertex point, a tex coord point and a color 4B

typedef struct _ccV3F_C4B_T2F    //采用3维向量 4b颜色 的ccpoint

{

//! vertices (3F)

ccVertex3F        vertices;            // 12 bytes

//    char __padding__[4];

//! colors (4B)

ccColor4B        colors;                // 4 bytes

//    char __padding2__[4];

// tex coords (2F)

ccTex2F            texCoords;            // 8 bytes

} ccV3F_C4B_T2F;

//! A Triangle(三角形) of ccV2F_C4B_T2F

typedef struct _ccV2F_C4B_T2F_Triangle   //采用ccV2F_C4B_T2F的三角形

{

//! Point A

ccV2F_C4B_T2F a;

//! Point B

ccV2F_C4B_T2F b;

//! Point B

ccV2F_C4B_T2F c;

} ccV2F_C4B_T2F_Triangle;

//! A Quad of ccV2F_C4B_T2F

typedef struct _ccV2F_C4B_T2F_Quad    //采用ccV2F_C4B_T2F的图块

{

//! bottom left

ccV2F_C4B_T2F    bl;

//! bottom right

ccV2F_C4B_T2F    br;

//! top left

ccV2F_C4B_T2F    tl;

//! top right

ccV2F_C4B_T2F    tr;

} ccV2F_C4B_T2F_Quad;

//! 4 ccVertex3FTex2FColor4B

typedef struct _ccV3F_C4B_T2F_Quad   //采用ccV3F_C4B_T2F的图块

{

//! top left

ccV3F_C4B_T2F    tl;

//! bottom left

ccV3F_C4B_T2F    bl;

//! top right

ccV3F_C4B_T2F    tr;

//! bottom right

ccV3F_C4B_T2F    br;

} ccV3F_C4B_T2F_Quad;

//! 4 ccVertex2FTex2FColor4F Quad

typedef struct _ccV2F_C4F_T2F_Quad  //采用ccV2F_C4F_T2F的图块

{

//! bottom left

ccV2F_C4F_T2F    bl;

//! bottom right

ccV2F_C4F_T2F    br;

//! top left

ccV2F_C4F_T2F    tl;

//! top right

ccV2F_C4F_T2F    tr;

} ccV2F_C4F_T2F_Quad;

//! Blend(混合) Function used for textures

typedef struct _ccBlendFunc      //用于纹理的混合函数

{

//! source blend function

GLenum src;    //资源函数

///

typedef unsigned int    GLenum;

//

//! destination blend function

GLenum dst;  //目标函数

} ccBlendFunc;

static const ccBlendFunc kCCBlendFuncDisable = {GL_ONE, GL_ZERO};

//

#define GL_ONE                                           1

#define GL_ZERO                                          0

///

// XXX: If any of these enums(枚举) are edited(编辑的) and/or reordered(再订购;重新整理), update CCTexture2D.m

//! Vertical(垂直的) text(文本) alignment(队列) type

typedef enum

{

kCCVerticalTextAlignmentTop,

kCCVerticalTextAlignmentCenter,

kCCVerticalTextAlignmentBottom,

} CCVerticalTextAlignment;

// XXX: If any of these enums are edited and/or reordered, update CCTexture2D.m

//! Horizontal(水平的) text alignment type

typedef enum

{

kCCTextAlignmentLeft,

kCCTextAlignmentCenter,

kCCTextAlignmentRight,

} CCTextAlignment;

// types for animation in particle systems  粒子系统动画类型

// texture coordinates for a quad

typedef struct _ccT2F_Quad

{

//! bottom left

ccTex2F    bl;

//! bottom right

ccTex2F    br;

//! top left

ccTex2F    tl;

//! top right

ccTex2F    tr;

} ccT2F_Quad;

// struct that holds the size in pixels, texture coordinates and delays for animated CCParticleSystemQuad

typedef struct

{

ccT2F_Quad texCoords;

float delay;

CCSize size;

} ccAnimationFrameData;

/**

types used for defining fonts properties (i.e. font name, size, stroke or shadow(阴影 渐变)) 用于定义字体属性的类型(字体名 大小、、、)

*/

// shadow attributes (阴影 渐变)属性

typedef struct _ccFontShadow

{

public:

// shadow is not enabled by default 默认情况阴影不使用

_ccFontShadow(): m_shadowEnabled(false) {}

// true if shadow enabled

bool   m_shadowEnabled;

// shadow x and y offset

CCSize m_shadowOffset;   //偏移量

// shadow blurrines

float  m_shadowBlur; //模糊值

// shadow opacity

float  m_shadowOpacity; //透明值

} ccFontShadow;

// stroke attributes

typedef struct _ccFontStroke

{

public:

// stroke is disabled by default

_ccFontStroke(): m_strokeEnabled(false) {}

// true if stroke enabled

bool        m_strokeEnabled;

// stroke color

ccColor3B   m_strokeColor;

// stroke size

float       m_strokeSize;

} ccFontStroke;

// font attributes

typedef struct _ccFontDefinition   //字体定义

{

public:

_ccFontDefinition():  m_alignment(kCCTextAlignmentCenter),

m_vertAlignment(kCCVerticalTextAlignmentTop),

m_fontFillColor(ccWHITE)

{ m_dimensions = CCSizeMake(0,0); }

// font name

std::string             m_fontName;

// font size

int                     m_fontSize;

// horizontal alignment

CCTextAlignment         m_alignment;

// vertical alignment

CCVerticalTextAlignment m_vertAlignment;

// renering box

CCSize                  m_dimensions;

// font color

ccColor3B               m_fontFillColor;

// font shadow

ccFontShadow            m_shadow;

// font stroke

ccFontStroke            m_stroke;

} ccFontDefinition;

NS_CC_END

#endif //__CCTYPES_H__

转载于:https://blog.51cto.com/2309998/1620223

cocos2d 字体颜色相关推荐

  1. Linux改变输出字体颜色,linux下 C编程改变输出字体颜色

    格式: echo "\033[字背景颜色;字体颜色m字符串\033[0m" 例如: echo "\033[41;36m something here \033[0m&qu ...

  2. vba 字体颜色_多掌握一些VBA语句,让自己书写代码更加顺畅

    VBA 是好东西,对于身在职场的人员,或者是积极打拼的创业者,是数据分析的首选,他可以实现量身定做,解决一些规律性强的问题.或者代替人处理一些可以描述出有逻辑关系的数据分析.多掌握一些VBA语句,让自 ...

  3. VS2010 MFC中改变static字体颜色、大小、背景颜色(自定义类),及手动关联变量的方法...

    在MFC的Dialog工程中生成一个CStatic的自定义类,类名例如为:CColorStatic 定义必要的变量: protected:COLORREF m_crText; // 字体颜色COLOR ...

  4. java字体颜色编程_java Applet 程序设计讲解2 字体,颜色的使用

    java Applet 程序设计讲解2 字体,颜色的使用 关键词: 字体    颜色 图形界面输出用到的字体,颜色的使用 1.字体类 (Font类) 构造方法: Font(String fontnam ...

  5. Python使用matplotlib函数subplot可视化多个不同颜色的折线图、为多个子图添加总标题(main title)、自定义设置主标题字体类型、字体大小、字体颜色等

    Python使用matplotlib函数subplot可视化多个不同颜色的折线图.为多个子图添加总标题(main title).自定义设置主标题字体类型.字体大小.字体颜色等 目录

  6. python使用matplotlib可视化、使用rcParams参数调整可视化图像中线条宽度、线条类型、文本字体、字体大小、字体颜色、字体类型、文本颜色等

    python使用matplotlib可视化.使用rcParams参数调整可视化图像中线条宽度.线条类型.文本字体.字体大小.字体颜色.字体类型.文本颜色等 目录

  7. python使用matplotlib可视化、为可视化图像添加标题(title)、自定义标题的字体格式、字体大小、字体颜色等

    python使用matplotlib可视化.为可视化图像添加标题(title).自定义标题的字体格式.字体大小.字体颜色等 目录

  8. python使用matplotlib可视化、为可视化图像添加图例(legend)、自定义图例的字体格式、字体大小、字体颜色等

    python使用matplotlib可视化.为可视化图像添加图例(legend).自定义图例的字体格式.字体大小.字体颜色等 目录

  9. R语言应用calibrate包的textxy函数向R原生绘图结果中添加文本标签:添加多个文本标签、改变文本标签的字体、改变文本标签的字体颜色

    R语言应用calibrate包的textxy函数向R原生绘图结果中添加文本标签:添加多个文本标签.改变文本标签的字体.改变文本标签的字体颜色 目录

  10. 验证码实现(随机背景色及字体颜色,带扰乱线条)

    验证码实现(随机背景色及字体颜色,带扰乱线条) 此实现工分三个文件,即:CreatImage.java 生成图像流的类,提供用于生成图片流的方法:images.jsp 图片包装,用于将图片加入到res ...

最新文章

  1. linux并发控制之自旋锁
  2. 数据结构(C语言版) 第 六 章 图 知识梳理 + 习题详解
  3. 报名丨西山金融科技产业创新论坛邀您参会
  4. GitLab: 开源免费的git管理工具
  5. php+mysql+pdo连接数据库
  6. 《淘宝店铺 大数据营销+SEO+爆款打造 一册通》一一2.2 实时直播抢占生意先机...
  7. mysqlnd--的说明
  8. jsp学习之包含——include
  9. 【C#/WPF】用Thumb做可拖拽的UI控件
  10. 数据挖掘:实用案例分析 下载_【实用干货】17 种服装印花工艺(图文案例分析)...
  11. myeclipse 中解决Hibernate 和Struts 2的冲突
  12. 2016级算法第五次上机-E.AlvinZH的学霸养成记IV
  13. java期末考试工程项目_java web 期末项目实验源码20套,自用学习非常不错!
  14. 自动开关机软件哪个好?自动开关机软件盘点
  15. SPSS学习笔记(一)
  16. Verilog时钟n分频
  17. 从罗京、张艺谋看CCTV的知识管理
  18. 深度linux12.12安装,深度Linux 12.12 Alpha发布
  19. 项目进度控制的主要任务是什么?
  20. 青轩桃李能几何,流光欺人忽蹉跎。 poll

热门文章

  1. 如何打造一款可靠的WAF(Web应用防火墙)
  2. VS2010插件 - NuGet
  3. 简单使用Idea创建三层架构项目和数据库连接(使用原生ajax进行访问+ajax)
  4. Leetcode961. N-Repeated Element in Size 2N Array重复N次的元素
  5. wust2012级软件工程新生经验交流会草稿
  6. Windows Phone 7将加入复制粘贴功能
  7. 099 元类( 控制对象产生和控制类产生)模板
  8. WebStorm2018.2 破解 激活
  9. 登录首页时报错:java.lang.IllegalArgumentException (不合法的参数异常)
  10. flask-session组件