說說你因為數據(代碼)潔癖,干過什麼奇怪的事情?

有沒有為了一點點無關緊要的數據冗餘,數據格式,折騰得翻天覆地?


寫出這樣的代碼,我一定病得不輕.

發現移動平台上的代碼排版是亂的,先發幾張切圖:

代碼如下:

/****************************************************************

File name : WhyColorDefines.h
Author : 葉飛影
Version : 2.0
Create Date : 2010/08/05
Description : 顏色相關宏定義

*****************************************************************/

#ifndef __WhyColorDefines_H__
#define __WhyColorDefines_H__

// INCLUDES -----------------------------------------------------------------------------

#include "WhyDefines.h"

// --------------------------------------------------------------------------------------

enum YePixelType
{
YE_PT_INVALID = 0,
YE_PT_GRAY_8 = 1,
YE_PT_A8R8G8B8 = 2,
YE_PT_R8G8B8 = 3,
YE_PT_A1R5G5B5 = 4,
YE_PT_R5G6B5 = 5,
YE_PT_A4R4G4B4 = 6,
};

// --------------------------------------------------------------------------------------

#define YD_INT_TO_BYTE(x) ( (x) &< 0 ? 0 : (((x) &> 255) ? 255 : (x)) )
#define YD_REAL_TO_BYTE(x) ( (x) &< 0 ? 0 : (((x) &> 1.0f) ? 255 : (Ybyte)((x) * 255)) )
#define YD_BYTE_TO_REAL(x) ( (x) * 0.00392156862745f ) // x / 255

// --------------------------------------------------------------------------------------

#define YD_GET_A(color) ( ((color) 0xff000000) &>&> 24L )
#define YD_GET_R(color) ( ((color) 0x00ff0000) &>&> 16L )
#define YD_GET_G(color) ( ((color) 0x0000ff00) &>&> 8L )
#define YD_GET_B(color) ( ((color) 0x000000ff) )

// --------------------------------------------------------------------------------------

// 色彩灰度化
#define YD_GET_GRAY(color, gray)
{
Ycolor r = YD_GET_R(color);
Ycolor g = YD_GET_G(color);
Ycolor b = YD_GET_B(color);
Yreal _r = YD_BYTE_TO_REAL(r) * 0.299f;
Yreal _g = YD_BYTE_TO_REAL(g) * 0.587f;
Yreal _b = YD_BYTE_TO_REAL(b) * 0.114f;
Yreal _gray = _r + _g + _b;
gray = YD_REAL_TO_BYTE(_gray);
}

// --------------------------------------------------------------------------------------

/*****A8R8G8B8*****/

// 通過R,G,B生成一整數表示顏色
#define YD_RGB(r,g,b)
( (Ycolor) ( (Ybyte)(b) |
( (Ycolor(Ybyte(g))) &<&< 8 ) | ( (Ycolor(Ybyte(r))) &<&< 16 ) | 0xff000000 ) ) // 通過R,G,B,A生成一整數表示顏色 #define YD_ARGB(a,r,g,b) ( (Ycolor) ( (Ybyte)(b) | ( (Ycolor(Ybyte(g))) &<&< 8 ) | ( (Ycolor(Ybyte(r))) &<&< 16 ) | ( (Ycolor(Ybyte(a))) &<&< 24 ) ) ) // 交換R分量與B分量 #define YD_SWITCH_R_B(color) { Ycolor a = YD_GET_A(color); Ycolor r = YD_GET_R(color); Ycolor g = YD_GET_G(color); Ycolor b = YD_GET_B(color); color = YD_ARGB(a,b,g,r); } // 修改A分量 #define YD_COLOR_ALPHA(color, alpha) { Yuint a = YD_GET_A(color); a = (Yuint)(a*alpha); color = 0x00ffffff; color |= (a &<&< 24); } #define YD_GET_ARGB(color, a, r, g, b) { a = YD_GET_A(color); r = YD_GET_R(color); g = YD_GET_G(color); b = YD_GET_B(color); } // 顏色各分量的平均值 #define YD_ARGB_AVERAGE(color1, color2, colorDest) { Ycolor a1, r1, g1, b1; Ycolor a2, r2, g2, b2; Ycolor ad, rd, gd, bd; YD_GET_ARGB(color1, a1, r1, g1, b1); YD_GET_ARGB(color2, a2, r2, g2, b2); ad = (a1 + a2) / 2; rd = (r1 + r2) / 2; gd = (g1 + g2) / 2; bd = (b1 + b2) / 2; colorDest = YD_ARGB(ad, rd, gd, bd); } // 顏色各分量的線性插值 #define YD_ARGB_LERP(color1, color2, colorDest, radio) { Ycolor a1, r1, g1, b1; Ycolor a2, r2, g2, b2; Ycolor ad, rd, gd, bd; YD_GET_ARGB(color1, a1, r1, g1, b1); YD_GET_ARGB(color2, a2, r2, g2, b2); ad = (Ycolor)YD_UNSIGNED_LERP(a1, a2, radio); rd = (Ycolor)YD_UNSIGNED_LERP(r1, r2, radio); gd = (Ycolor)YD_UNSIGNED_LERP(g1, g2, radio); bd = (Ycolor)YD_UNSIGNED_LERP(b1, b2, radio); colorDest = YD_ARGB(ad, rd, gd, bd); } #define YD_GET_RGB(color, r, g, b) { r = YD_GET_R(color); g = YD_GET_G(color); b = YD_GET_B(color); } #define YD_RGB_AVERAGE(color1, color2, colorDest) { Ycolor r1, g1, b1; Ycolor r2, g2, b2; Ycolor rd, gd, bd; YD_GET_RGB(color1, r1, g1, b1); YD_GET_RGB(color2, r2, g2, b2); rd = (r1 + r2) / 2; gd = (g1 + g2) / 2; bd = (b1 + b2) / 2; colorDest = YD_RGB(rd, gd, bd); } // 顏色各分量的線性插值 #define YD_RGB_LERP(color1, color2, colorDest, radio) { Yuint32 r1, g1, b1; Yuint32 r2, g2, b2; Yuint32 rd, gd, bd; YD_GET_RGB(color1, r1, g1, b1); YD_GET_RGB(color2, r2, g2, b2); rd = (Yuint32)YD_UNSIGNED_LERP(r1, r2, radio); gd = (Yuint32)YD_UNSIGNED_LERP(g1, g2, radio); bd = (Yuint32)YD_UNSIGNED_LERP(b1, b2, radio); colorDest = YD_RGB(rd, gd, bd); } // 顏色縮放 #define YD_COLOR_SCALE(colorDest, color, scale) { Yuint32 a, r, g, b; Yuint32 ad, rd, gd, bd; YD_GET_ARGB(color, a, r, g, b); rd = (Yuint32)(r*scale); gd = (Yuint32)(g*scale); bd = (Yuint32)(b*scale); ad = (Yuint32)(a*scale); colorDest = YD_ARGB(ad, rd, gd, bd); } #define YD_COLOR_RGB_SCALE(colorDest, color, scale) { Yuint32 a, r, g, b; Yuint32 rd, gd, bd; YD_GET_ARGB(color, a, r, g, b); rd = (Yuint32)(r*scale); gd = (Yuint32)(g*scale); bd = (Yuint32)(b*scale); colorDest = YD_ARGB(a, rd, gd, bd); } #define YD_COLOR_ALPHA_SCALE(colorDest, color, scale) { Yuint32 a, r, g, b; Yuint32 ad; YD_GET_ARGB(color, a, r, g, b); ad = (Yuint32)(a*scale); colorDest = YD_ARGB(ad, r, g, b); } // 顏色置反 #define YD_COLOR_INVERSE(colorDest, color) { Yuint32 a, r, g, b; Yuint32 ad, rd, gd, bd; YD_GET_ARGB(color, a, r, g, b); rd = 255 - r; gd = 255 - g; bd = 255 - b; ad = 255 - a; colorDest = YD_ARGB(ad, rd, gd, bd); } #define YD_COLOR_RGB_INVERSE(colorDest, color) { Yuint32 a, r, g, b; Yuint32 rd, gd, bd; YD_GET_ARGB(color, a, r, g, b); rd = 255 - r; gd = 255 - g; bd = 255 - b; colorDest = YD_ARGB(a, rd, gd, bd); } #define YD_COLOR_ALPHA_INVERSE(colorDest, color) { Yuint32 a, r, g, b; Yuint32 ad; YD_GET_ARGB(color, a, r, g, b); ad = 255 - a; colorDest = YD_ARGB(ad, r, g, b); } // -------------------------------------------------------------------------------------- /*****R5G6B5*****/ #define YD_R5G6B5(r,g,b) ( (YWord) ( ( (Ybyte(b) &>&> 3L) ) |
( (YWord(Ybyte(g)) &>&> 2L) &<&< 5L ) | ( (YWord(Ybyte(r)) &>&> 3L) &<&< 11L ) ) #define YD_GET_565_R(color) ( ((color) 0x0000f800) &>&> 8L )
#define YD_GET_565_G(color) ( ((color) 0x000007E0) &>&> 3L )
#define YD_GET_565_B(color) ( ((color) 0x0000001f) &<&< 3L ) #define YD_GET_565_RGB(color, r, g, b) { r = YD_GET_565_R(color); g = YD_GET_565_G(color); b = YD_GET_565_B(color); } // -------------------------------------------------------------------------------------- /*****A1R5G5B5*****/ #define YD_R5G5B5(r,g,b) ( (YWord) ( ( (Ybyte(b) &>&> 3L) ) |
( (YWord(Ybyte(g)) &>&> 3L) &<&< 5L ) | ( (YWord(Ybyte(r)) &>&> 3L) &<&< 10L ) ) #define YD_A1R5G5B5(a,r,g,b) ( (YWord) ( ( (Ybyte(b) &>&> 3L) ) |
( (YWord(Ybyte(g)) &>&> 3L) &<&< 5L ) | ( (YWord(Ybyte(r)) &>&> 3L) &<&< 10L ) | ( (YWord((a) 1L) &<&< 15L) ) ) #define YD_GET_1555_A(color) ( ((color) 0x00008000) ? 255 : 0 ) #define YD_GET_1555_R(color) ( ((color) 0x00007B00) &>&> 7L )
#define YD_GET_1555_G(color) ( ((color) 0x000003E0) &>&> 2L )
#define YD_GET_1555_B(color) ( ((color) 0x0000001f) &<&< 3L ) #define YD_GET_1555_RGB(color, a, r, g, b) { a = YD_GET_1555_A(color); r = YD_GET_1555_R(color); g = YD_GET_1555_G(color); b = YD_GET_1555_B(color); } // -------------------------------------------------------------------------------------- /*****A4R4G4B4*****/ #define YD_R4G4B4(r,g,b) ( (YWord) ( ( (Ybyte(b) &>&> 4L) ) |
( (YWord(Ybyte(g)) &>&> 4L) &<&< 4L ) | ( (YWord(Ybyte(r)) &>&> 4L) &<&< 8L ) ) ) #define YD_A4R4G4B4(a,r,g,b) ( (YWord) ( ( (Ybyte(b) &>&> 4L) ) |
( (YWord(Ybyte(g)) &>&> 4L) &<&< 4L ) | ( (YWord(Ybyte(r)) &>&> 4L) &<&< 8L ) | ( (YWord(Ybyte(a)) &>&> 4L) &<&< 12L ) ) ) #define YD_GET_4444_A(color) ( ((color) 0x0000f000) &>&> 8L )
#define YD_GET_4444_R(color) ( ((color) 0x00000f00) &>&> 4L )
#define YD_GET_4444_G(color) ( ((color) 0x000000f0) )
#define YD_GET_4444_B(color) ( ((color) 0x0000000f) &<&< 4L ) #define YD_GET_4444_RGB(color, a, r, g, b) { a = YD_GET_4444_A(color); r = YD_GET_4444_R(color); g = YD_GET_4444_G(color); b = YD_GET_4444_B(color); } // -------------------------------------------------------------------------------------- union YColorARGB { struct { Ybyte b; Ybyte g; Ybyte r; Ybyte a; }; Ycolor dwColor; }; struct YColorRGB { Ybyte b; Ybyte g; Ybyte r; }; struct YsFloatColor { Yreal fAlpha; Yreal fRed; Yreal fGreen; Yreal fBlue; }; #define YD_R5G6B5_TO_R8G8B8(src565, dest888) { Ycolor r, g, b; YD_GET_565_RGB(src565, r, g, b); dest888 = YD_RGB(r, g, b); } #define YD_R8G8B8_TO_R5G6B5(src888, dest565) { Ycolor r, g, b; YD_GET_RGB(src888, r, g, b); dest565 = YD_R5G6B5(r, g, b); } #define YD_A1R5G5B5_TO_A8R8G8B8(src1555, dest8888) { Ycolor a, r, g, b; YD_GET_1555_RGB(src1555, a, r, g, b); dest8888 = YD_ARGB(a, r, g, b); } #define YD_A8R8G8B8_TO_A1R5G5B5(src8888, dest1555) { Ycolor a, r, g, b; YD_GET_ARGB(src8888, a, r, g, b); dest1555 = YD_A1R5G5B5(a, r, g, b); } #define YD_A4R4G4B4_TO_A8R8G8B8(src4444, dest8888) { Ycolor a, r, g, b; YD_GET_4444_RGB(src4444, a, r, g, b); dest8888 = YD_ARGB(a, r, g, b); } #define YD_A8R8G8B8_TO_A4R4G4B4(src8888, dest4444) { Ycolor a, r, g, b; YD_GET_ARGB(src8888, a, r, g, b); dest4444 = YD_A4R4G4B4(a, r, g, b); } #define YD_R8G8B8_TO_A8R8G8B8(src888, dest8888) { dest8888 = YD_ARGB(255, src888.r, src888.g, src888.b); } #define YD_A8R8G8B8_TO_R8G8B8(src8888, dest888) { YD_GET_RGB(src8888, dest888.r, dest888.g, dest888.b); } #define YD_FLOATCOLOR_TO_A8R8G8B8(srcFloatColor, dest8888) { Ybyte a = YD_REAL_TO_BYTE(srcFloatColor.fAlpha); Ybyte r = YD_REAL_TO_BYTE(srcFloatColor.fRed); Ybyte g = YD_REAL_TO_BYTE(srcFloatColor.fGreen); Ybyte b = YD_REAL_TO_BYTE(srcFloatColor.fBlue); dest8888 = YD_ARGB(a, r, g, b); } #define YD_A8R8G8B8_TO_FLOATCOLOR(src8888, destFloatColor) { Ycolor a, r, g, b; YD_GET_ARGB(src8888, a, r, g, b); destFloatColor.fAlpha = YD_BYTE_TO_REAL(a); destFloatColor.fRed = YD_BYTE_TO_REAL(r); destFloatColor.fGreen = YD_BYTE_TO_REAL(g); destFloatColor.fBlue = YD_BYTE_TO_REAL(b); } // -------------------------------------------------------------------------------------- #define YD_COLOR_LIGHT_PINK YD_RGB(255, 182, 193) // 0 淺粉紅 #define YD_COLOR_PINK YD_RGB(255, 192, 203) // 1 粉紅 #define YD_COLOR_CRIMSON_RED YD_RGB(220, 20, 60) // 2 猩紅 (深紅) #define YD_COLOR_LAVENDER_BLUSH YD_RGB(255, 240, 245) // 3 淡紫紅 #define YD_COLOR_PALE_VIOLET_RED YD_RGB(219, 112, 147) // 4 弱紫羅蘭紅 #define YD_COLOR_HOT_PINK YD_RGB(255, 105, 180) // 5 熱情的粉紅 #define YD_COLOR_DEEP_PINK YD_RGB(255, 20, 147) // 6 深粉紅 #define YD_COLOR_MEDIUM_VIOLET_RED YD_RGB(199, 21, 133) // 7 中紫羅蘭紅 #define YD_COLOR_ORCHID YD_RGB(218, 112, 214) // 8 蘭花紫 #define YD_COLOR_THISTLE YD_RGB(216, 191, 216) // 9 薊 #define YD_COLOR_PLUM YD_RGB(221, 160, 221) // 10 李子紫 #define YD_COLOR_VIOLET YD_RGB(238, 130, 238) // 11 紫羅蘭 #define YD_COLOR_MAGENTA YD_RGB(255, 0, 255) // 12 洋紅 (品紅 玫瑰紅) #define YD_COLOR_FUCHSIA YD_RGB(244, 0, 161) // 13 燈籠海棠(紫紅色) #define YD_COLOR_DARK_MAGENTA YD_RGB(139, 0, 139) // 14 深洋紅 #define YD_COLOR_PURPLE YD_RGB(128, 0, 128) // 15 紫色 #define YD_COLOR_MEDIUM_ORCHID YD_RGB(186, 85, 211) // 16 中蘭花紫 #define YD_COLOR_DARK_VIOLET YD_RGB(148, 0, 211) // 17 暗紫羅蘭 #define YD_COLOR_DARK_ORCHID YD_RGB(153, 50, 204) // 18 暗蘭花紫 #define YD_COLOR_INDIGO YD_RGB( 75, 0, 130) // 19 靛青 (紫蘭色) #define YD_COLOR_BLUE_VIOLET YD_RGB(138, 43, 226) // 20 藍紫羅蘭 #define YD_COLOR_MEDIUM_PURPLE YD_RGB(147, 112, 219) // 21 中紫色 #define YD_COLOR_MEDIUM_SLATE_BLUE YD_RGB(123, 104, 238) // 22 中板岩藍 #define YD_COLOR_SLATE_BLUE YD_RGB(106, 90, 205) // 23 板岩藍 #define YD_COLOR_DARK_SLATE_BLUE YD_RGB( 72, 61, 139) // 24 暗板岩藍 #define YD_COLOR_LAVENDER YD_RGB(230, 230, 250) // 25 熏衣草淡紫 #define YD_COLOR_GHOST_WHITE YD_RGB(248, 248, 255) // 26 幽靈白 #define YD_COLOR_BLUE YD_RGB( 0, 0, 255) // 27 純藍 #define YD_COLOR_MEDIUM_BLUE YD_RGB( 0, 0, 205) // 28 中藍色 #define YD_COLOR_MIDNIGHT_BLUE YD_RGB( 25, 25, 112) // 29 午夜藍 #define YD_COLOR_DARK_BLUE YD_RGB( 0, 0, 139) // 30 暗藍色 #define YD_COLOR_NAVY_BLUE YD_RGB( 0, 0, 128) // 31 海軍藍 #define YD_COLOR_ROYAL_BLUE YD_RGB( 65, 105, 225) // 32 皇家藍 (寶藍) #define YD_COLOR_CORN_FLOWER_BLUE YD_RGB(100, 149, 237) // 33 矢車菊藍 #define YD_COLOR_LIGHT_STEEL_BLUE YD_RGB(176, 196, 222) // 34 亮鋼藍 #define YD_COLOR_LIGHT_SLATE_GRAY YD_RGB(119, 136, 153) // 35 亮石板灰 #define YD_COLOR_SLATE_GRAY YD_RGB(112, 128, 144) // 36 石板灰 #define YD_COLOR_DODGER_BLUE YD_RGB( 30, 144, 255) // 37 道奇藍 #define YD_COLOR_ALICE_BLUE YD_RGB(240, 248, 255) // 38 愛麗絲藍 #define YD_COLOR_STEEL_BLUE YD_RGB( 70, 130, 180) // 39 鋼藍 (鐵青) #define YD_COLOR_LIGHT_SKY_BLUE YD_RGB(135, 206, 250) // 40 亮天藍色 #define YD_COLOR_SKY_BLUE YD_RGB(135, 206, 235) // 41 天藍色 #define YD_COLOR_DEEP_SKY_BLUE YD_RGB( 0, 191, 255) // 42 深天藍 #define YD_COLOR_LIGHT_BLUE YD_RGB(173, 216, 230) // 43 亮藍 #define YD_COLOR_POWDER_BLUE YD_RGB(176, 224, 230) // 44 火藥青 #define YD_COLOR_CADET_BLUE YD_RGB( 95, 158, 160) // 45 軍服藍 #define YD_COLOR_AZURE YD_RGB(240, 255, 255) // 46 蔚藍色 #define YD_COLOR_LIGHT_CYAN YD_RGB(224, 255, 255) // 47 淡青色 #define YD_COLOR_PALE_TURQUOISE YD_RGB(175, 238, 238) // 48 弱綠寶石 #define YD_COLOR_CYAN YD_RGB( 0, 255, 255) // 49 青色 #define YD_COLOR_AQUA YD_RGB(175, 223, 228) // 50 水色 #define YD_COLOR_DARK_TURQUOISE YD_RGB( 0, 206, 209) // 51 暗綠寶石 #define YD_COLOR_DARK_SLATE_GRAY YD_RGB( 47, 79, 79) // 52 暗石板灰 #define YD_COLOR_DARK_CYAN YD_RGB( 0, 139, 139) // 53 暗青色 #define YD_COLOR_TEAL YD_RGB( 0, 128, 128) // 54 水鴨色 #define YD_COLOR_MEDIUM_TURQUOISE YD_RGB( 72, 209, 204) // 55 中綠寶石 #define YD_COLOR_LIGHT_SEA_GREEN YD_RGB( 32, 178, 170) // 56 淺海洋綠 #define YD_COLOR_TURQUOISE YD_RGB( 64, 224, 208) // 57 綠寶石 #define YD_COLOR_AQUAMARINE YD_RGB(127, 255, 212) // 58 寶石碧綠 #define YD_COLOR_MEDIUM_AQUAMARINE YD_RGB(102, 205, 170) // 59 中寶石碧綠 #define YD_COLOR_MEDIUM_SPRINGGREEN YD_RGB( 0, 250, 154) // 60 中春綠色 #define YD_COLOR_MINT_CREAM YD_RGB(245, 255, 250) // 61 薄荷奶油 #define YD_COLOR_SPRING_GREEN YD_RGB( 0, 255, 127) // 62 春綠色 #define YD_COLOR_MEDIUM_SEA_GREEN YD_RGB( 60, 179, 113) // 63 中海洋綠 #define YD_COLOR_SEA_GREEN YD_RGB( 46, 139, 87) // 64 海洋綠 #define YD_COLOR_HONEYDEW YD_RGB(240, 255, 240) // 65 蜜瓜色 #define YD_COLOR_LIGHT_GREEN YD_RGB(144, 238, 144) // 66 淡綠色 #define YD_COLOR_PALE_GREEN YD_RGB(152, 251, 152) // 67 弱綠色 #define YD_COLOR_DARK_SEA_GREEN YD_RGB(143, 188, 143) // 68 暗海洋綠 #define YD_COLOR_LIME_GREEN YD_RGB( 50, 205, 50) // 69 閃光深綠 #define YD_COLOR_LIME YD_RGB( 0, 255, 0) // 70 閃光綠 #define YD_COLOR_FOREST_GREEN YD_RGB( 34, 139, 34) // 71 森林綠 #define YD_COLOR_GREEN YD_RGB( 0, 128, 0) // 72 純綠 #define YD_COLOR_DARK_GREEN YD_RGB( 0, 100, 0) // 73 暗綠色 #define YD_COLOR_CHARTREUSE YD_RGB(127, 255, 0) // 74 查特酒綠 (黃綠色) #define YD_COLOR_LAWN_GREEN YD_RGB(124, 252, 0) // 75 草坪綠 #define YD_COLOR_GREEN_YELLOW YD_RGB(173, 255, 47) // 76 綠黃色 #define YD_COLOR_DARK_OLIVE_GREEN YD_RGB( 85, 107, 47) // 77 暗橄欖綠 #define YD_COLOR_YELLOW_GREEN YD_RGB(154, 205, 50) // 78 黃綠色 #define YD_COLOR_OLIVE_DRAB YD_RGB(107, 142, 35) // 79 橄欖褐色 #define YD_COLOR_BEIGE YD_RGB(245, 245, 220) // 80 米色(灰棕色) #define YD_COLOR_LIGHT_GOLDENROD_YELLOW YD_RGB(250, 250, 210) // 81 亮菊黃 #define YD_COLOR_IVORY YD_RGB(255, 255, 240) // 82 象牙 #define YD_COLOR_LIGHT_YELLOW YD_RGB(255, 255, 224) // 83 淺黃色 #define YD_COLOR_YELLOW YD_RGB(255, 255, 0) // 84 純黃 #define YD_COLOR_OLIVE YD_RGB(128, 128, 0) // 85 橄欖 #define YD_COLOR_DARK_KHAKI YD_RGB(189, 183, 107) // 86 深卡嘰布 #define YD_COLOR_LEMON_CHIFFON YD_RGB(255, 250, 205) // 87 檸檬綢 #define YD_COLOR_PALE_GOLDENROD YD_RGB(238, 232, 170) // 88 灰菊黃 #define YD_COLOR_KHAKI YD_RGB(240, 230, 140) // 89 卡嘰布 #define YD_COLOR_GOLD YD_RGB(255, 215, 0) // 90 金色 #define YD_COLOR_CORNSILK YD_RGB(255, 248, 220) // 91 玉米絲色 #define YD_COLOR_GOLDENROD YD_RGB(218, 165, 32) // 92 金菊黃 #define YD_COLOR_DARK_GOLDENROD YD_RGB(184, 134, 11) // 93 暗金菊黃 #define YD_COLOR_FLORAL_WHITE YD_RGB(255, 250, 240) // 94 花的白色 #define YD_COLOR_OLD_LACE YD_RGB(253, 245, 230) // 95 舊蕾絲 #define YD_COLOR_WHEAT YD_RGB(245, 222, 179) // 96 小麥色 #define YD_COLOR_MOCCASIN YD_RGB(255, 228, 181) // 97 鹿皮靴 #define YD_COLOR_ORANGE YD_RGB(255, 165, 0) // 98 橙色 #define YD_COLOR_PAPAYA_WHIP YD_RGB(255, 239, 213) // 99 番木瓜 #define YD_COLOR_BLANCHED_ALMOND YD_RGB(255, 235, 205) // 100 發白的杏仁色 #define YD_COLOR_NAVAJO_WHITE YD_RGB(255, 222, 173) // 101 土著白 #define YD_COLOR_ANTIQUE_WHITE YD_RGB(250, 235, 215) // 102 古董白 #define YD_COLOR_TAN YD_RGB(210, 180, 140) // 103 茶色 #define YD_COLOR_BURLY_WOOD YD_RGB(222, 184, 135) // 104 硬木色 #define YD_COLOR_BISQUE YD_RGB(255, 228, 196) // 105 陶坯黃 #define YD_COLOR_DARK_ORANGE YD_RGB(255, 140, 0) // 106 深橙色 #define YD_COLOR_LINEN YD_RGB(250, 240, 230) // 107 亞麻布 #define YD_COLOR_PERU YD_RGB(205, 133, 63) // 108 秘魯 #define YD_COLOR_PEACH_PUFF YD_RGB(255, 218, 185) // 109 桃肉色 #define YD_COLOR_SANDY_BROWN YD_RGB(244, 164, 96) // 110 沙棕色 #define YD_COLOR_CHOCOLATE YD_RGB(210, 105, 30) // 111 巧克力 #define YD_COLOR_SADDLE_BROWN YD_RGB(139, 69, 19) // 112 馬鞍棕色 #define YD_COLOR_SEASHELL YD_RGB(255, 245, 238) // 113 海貝殼 #define YD_COLOR_SIENNA YD_RGB(160, 82, 45) // 114 黃土赭色 #define YD_COLOR_LIGHT_SALMON YD_RGB(255, 160, 122) // 115 淺鮭魚肉色 #define YD_COLOR_CORAL YD_RGB(255, 127, 80) // 116 珊瑚 #define YD_COLOR_ORANGE_RED YD_RGB(255, 69, 0) // 117 橙紅色 #define YD_COLOR_DARK_SALMON YD_RGB(233, 150, 122) // 118 深鮮肉(鮭魚)色 #define YD_COLOR_TOMATO YD_RGB(255, 99, 71) // 129 番茄紅 #define YD_COLOR_MISTY_ROSE YD_RGB(255, 228, 225) // 120 薄霧玫瑰 #define YD_COLOR_SALMON YD_RGB(250, 128, 114) // 121 鮮肉(鮭魚)色 #define YD_COLOR_SNOW YD_RGB(255, 250, 250) // 122 雪 #define YD_COLOR_LIGHT_CORAL YD_RGB(240, 128, 128) // 123 淡珊瑚色 #define YD_COLOR_ROSY_BROWN YD_RGB(188, 143, 143) // 124 玫瑰棕色 #define YD_COLOR_INDIAN_RED YD_RGB(205, 92, 92) // 125 印度紅 #define YD_COLOR_RED YD_RGB(255, 0, 0) // 126 純紅 #define YD_COLOR_BROWN YD_RGB(165, 42, 42) // 127 棕色 #define YD_COLOR_FIRE_BRICK YD_RGB(178, 34, 34) // 128 耐火磚 #define YD_COLOR_DARK_RED YD_RGB(139, 0, 0) // 139 深紅色 #define YD_COLOR_MAROON YD_RGB(128, 0, 0) // 130 栗色 #define YD_COLOR_WHITE YD_RGB(255, 255, 255) // 131 純白 #define YD_COLOR_WHITE_SMOKE YD_RGB(245, 245, 245) // 132 白煙 #define YD_COLOR_GAINSBORO YD_RGB(220, 220, 220) // 133 庚斯博羅灰色 #define YD_COLOR_LIGHT_GREY YD_RGB(211, 211, 211) // 134 淺灰色 #define YD_COLOR_SILVER YD_RGB(192, 192, 192) // 135 銀灰色 #define YD_COLOR_DARK_GRAY YD_RGB(169, 169, 169) // 136 深灰色 #define YD_COLOR_GRAY YD_RGB(128, 128, 128) // 137 灰色 #define YD_COLOR_DIM_GRAY YD_RGB(105, 105, 105) // 138 暗淡的灰色 #define YD_COLOR_BLACK YD_RGB( 0, 0, 0) // 139 純黑 // -------------------------------------------------------------------------------------- #endif


是時候祭出這張圖了。

出處:https://twitter.com/thedirtycoder/status/569339014085517312


不好意思,我用python


我一半時間在想給每個變數起個好名字。


真正的碼農不會浪費時間在tab/space indent、trailing space、java/allman/stroustrup/kr style bracket這種細節上面的(逃

所以我都是用artistic style一鍵代碼格式化的(斜眼笑

鏈接http://astyle.sourceforge.net/

輕量,開源,支持C/C++/C#/OC/JAVA

自定義命令,方便集成到各種IDE/editor

倍兒爽


不管什麼語言的代碼,行尾有空白字元的都不能忍,見一個刪一個;

而且為了不給提交記錄添亂,這種格式修改的代碼通常都攢一塊再提交。

==========================================

話說,真搞不清楚那些行尾空格是怎麼敲出來的,複製?手抖?還是神馬。。。


放眼望去,全是沒意識到遵守 style guide 明明是基本需求以為自己做到了就了不得的,以及不會用各種格式化工具浪費不少時間還以為功勞多大的業餘程序員。


改tab,改空格,然後當年喜歡左花括弧放在函數名尾巴上,改預編譯(這條還比較靠譜),把所有的錯誤代碼設成自己喜歡的常量名。。。。。

也是各種醉人啊。。。。


每次看到這樣的代碼:

for(int i=0; i&

無論多少,我都會改成:

for(int i=0; i&


推薦閱讀:

對於編程思想和能力有重大提升的書有哪些?
前端新人工作中多造輪子對未來的發展是好是壞?
編程東西學得多是不是一定是壞事?
宅總用的這是什麼編輯器?
沒有基礎,想學python和玩樹莓派,請問我可以怎麼做?

TAG:編程 | 計算機科學 | 生活態度 |