Frequently Asked Questions
оглавление | demo party в ex-СССР | infused bytes e-mag | новости от ib/news | другие проекты | письмо | win koi lat

следующий фpагмент (2)
- Usenet echoes (21:200/1) -------------------------- COMP.GRAPHICS.ALGORITHMS - Msg : 26 of 41 From : 4188-21922 2:5030/144.99 29 Aug 94 14:04:56 To : All 29 Sep 93 06:01:42 Subj : Re: T -> {R, G, B} -------------------------------------------------------------------------------- Here's a program that computes an array of (r,g,b) values that approximate the color of hot iron at various temperatures. From the simplicity of the formula it should be obvious that there is no physics here. Unless you're really interested in quantitative simulation of black-body radiators, this should do just fine. I did it the hard way once, starting with Planck's black-body radiation curve, the CIE matching functions and the gamma curves and phosphor chromaticities of the monitor I was using, and it wasn't worth the effort. #include <u.h> #include <libc.h> #define NCMAP 256 /* # of color map entries */ #define CRANGE 255 /* color map components range from 0 to this */ /* * Rescale a from 0-1 to 0-CRANGE, clamping at the ends of the range. */ int clamp(double a){ return a<0?0:a<=1.?CRANGE*a:CRANGE; } /* * Make a color map that approximates black-body * (hot iron) colors at increasing temperatures */ void ironmap(unsigned char cmap[256][3]){ int i; double alpha; for(i=0;i!=NCMAP;i++){ alpha=(double)i/(NCMAP-1); cmap[i][0]=clamp(3.*(alpha+.03)); cmap[i][1]=clamp(3.*(alpha-.333333)); cmap[i][2]=clamp(3.*(alpha-.666667)); } }

Всего 1 фpагмент(а/ов) |пpедыдущий фpагмент (1)

Если вы хотите дополнить FAQ - пожалуйста пишите.

design/collection/some content by Frog,
DEMO DESIGN FAQ (C) Realm Of Illusion 1994-2000,
При перепечатке материалов этой страницы пожалуйста ссылайтесь на источник: "DEMO.DESIGN FAQ,".