⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wzcolor.cxx

📁 Delaunay三角形的网格剖分程序
💻 CXX
字号:
#include "wzcolor.hxx"#include <string.h>typedef struct{  wzByte r;  wzByte g;  wzByte b;  wzString name;}wzcolorname;static const wzcolorname wzcolornamelist[]={/* the following include file was created automatically from /usr/lib/X11/rgb.txt using the following perl script:**********************************************************************#! /usr/local/bin/perl$|=1;     # immediate output without buffering;open(OUT,">wzcolornames.hxx");open(RGB,"/usr/lib/X11/rgb.txt");print OUT "// you can include your own color names here, like{1,1,1,\"really really dark gray\"\}\,// this file was automatically created from /usr/lib/X11/rgb.txt// for inclusion into wzcolor.cxx.";while(<RGB>){             # loop over the lines of the file    s/(\!.*)//;    s/(\d+)\s+(\d+)\s+(\d+)\s+(.*)/ \{$1,$2,$3,\"$4\"\}\,/;    print OUT;}close(OUT); close(RGB); **********************************************************************/#include "wzcolornames.hxx"{0,0,0,0}};static char hexa[]= {'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'};void wzColor::get(wzString s) const{s[0]='#'; s[1]=hexa[R>>4]; s[2]=hexa[R&0xf]; s[3]=hexa[R&0xf]; s[4]=hexa[G>>4]; s[5]=hexa[G&0xf]; s[6]=hexa[G&0xf]; s[7]=hexa[B>>4]; s[8]=hexa[B&0xf]; s[9]=hexa[B&0xf]; s[10]='\0';}static void findColorInRGB(wzByte *R,wzByte *G,wzByte *B,wzString s);void wzColor::set(wzString s){ if(s[0]!='#') {findColorInRGB(&R,&G,&B,s); return;} unsigned int p[13], i=1; while(s[i]){	if     ((s[i]>='0') && (s[i] <='9')){ p[i] = (s[i]-'0');}	else if((s[i]>='a') && (s[i] <='f')){ 	  p[i] = ((unsigned)s[i]-(unsigned)'a')+10;	}	else {break;}	i++; } if(i<=3){        R=G=B=0; return; }else if(i<=6){	R = (p[1])<<4;	G = (p[2])<<4;	B = (p[3])<<4; }else if(i<=9){	R = ((p[1])<<4)+(p[2]);	G = ((p[3])<<4)+(p[4]);	B = ((p[5])<<4)+(p[6]); }else if(i<=12){	R = ((p[1])<<4)+(p[2]);	G = ((p[4])<<4)+(p[5]);	B = ((p[7])<<4)+(p[8]); }else{	R = ((p[1])<<4)+(p[2]);	G = ((p[5])<<4)+(p[6]);	B = ((p[9])<<4)+(p[10]); }}static const int zeroIsWater = 1;void wzColor::getElevation(wzShort &i) const{ i = ((int)(*(signed char *)&B + (R/0x10)))*0x100 + G + zeroIsWater;}void wzColor::setElevation(wzShort m){int mm, up; mm  = m - zeroIsWater; up  = mm / 0x100; if(mm<0) {up = -up;} G   = mm % 0x100; R   = (up%0x10)*0x10; B  = (up/0x10)*0x10; if(mm<0) {B = 0xff-B;}/*	up  = mm / 0x100;	G   = mm % 0x100;	R   = (up%0x10)*0x10;	*(signed char *)&B  = (up/0x10)*0x10;*/}static void findColorInRGB(wzByte *R,wzByte *G,wzByte *B,wzString s){  const wzcolorname *item;  int n = strlen(s);  item = &wzcolornamelist[0];  wzString c;  while(c=item->name){    if(strncmp(c,s,n)){      item++;    }else{      *R = item->r;      *G = item->g;      *B = item->b;      return;    }  }  *R=*G=*B=0;}    /*#include <iostream.h>ostream& operator<<(ostream& o, wzColor c){char b[20]; c.get(b); o<<b; return o;} */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -