hey Christopher, your code was good. It didnt get exactly the same from example (cause the near values are a bit pinky, and not red) but I just want the color changing effect.
Thanks to all :D 2012/7/13 Christopher Night <[email protected]> > Oh okay. You don't want to go from red straight to violet, you want to go > through the colors of the rainbow, ie, go around the color wheel the long > way. Here's one quick, approximate way to pull it off. You can tweak it as > you like: > > norm = lambda x: min(max(int((x+1)*128),0),255) > s = lambda t: math.sin(2*math.pi*t) > spec = lambda t: (norm(s(t*0.9+0.2)), norm(s(t*0.9+0.9)), > norm(s(t*0.9+0.5))) > palette = tuple(spec(x/256.) for x in range(256)) > > to test: > > screen = pygame.display.set_mode((256,100)) > for x in range(256): > pygame.draw.line(screen, palette[x], (x,0), (x,100)) > pygame.display.flip() > > -Christopher > > > On Fri, Jul 13, 2012 at 12:55 PM, Ricardo Franco > <[email protected]>wrote: > >> I dont know if I'm understanding well .. What I want is this: >> >> "Building a colormap containing 256 colors is quite a chore, but the >> ColorUtils library >> (http://code.google.com/p/colorutils/) can generate several predefined >> maps. Figure 20 >> employs the colormap returned by ColorUtils.getSpectrum(), which >> colorizes the >> white to black range *using the red-to-violet spectrum*. This means that >> objects in the >> depth map close to the Kinect will be rendered *red or orange*, while >> those further >> away will be *green, blue, or violet*. Those without depth measures >> (perhaps because >> they are too close to the Kinect) will be rendered as red." >> >> (the example I took from pdf is in JAVA) >> >> It says values near (the first values) are red or orange and the values >> far (the last values) will be green, blue or violet. >> By near and far, I mean the iterations of i (0 to 255) >> >> 2012/7/13 Christopher Night <[email protected]> >> >>> According to Wikipedia, violet is (127, 0, 255), so this should work: >>> >>> tuple((255-(i+1)//2, 0, i) for i in range(256)) >>> >>> -Christopher >>> >>> >>> On Fri, Jul 13, 2012 at 12:20 PM, Ricardo Franco < >>> [email protected]> wrote: >>> >>>> I would like to know how to build a specifc color palette, its the >>>> red-to-violet color palette. >>>> To build the grayscale color palette I use: >>>> >>>> grayscale_palette = tuple([(i, i, i) for i in range(256)]) >>>> >>>> How do to get the red-to-violet color palette? >>>> >>>> -- >>>> Ricardo Franco Andrade @ricardokrieg >>>> >>>> ( Game | Desktop | Web ) Developer >>>> >>>> email: [email protected] >>>> contact: +55 (86) 9958 9725 >>>> +55 (86) 9436 0830 >>>> twitter: twitter.com/ricardokrieg >>>> facebooK: https://www.facebook.com/krieg.ricardo >>>> github: https://github.com/ricardokrieg >>>> >>>> >>> >> >> >> -- >> Ricardo Franco Andrade @ricardokrieg >> >> ( Game | Desktop | Web ) Developer >> >> email: [email protected] >> contact: +55 (86) 9958 9725 >> +55 (86) 9436 0830 >> twitter: twitter.com/ricardokrieg >> facebooK: https://www.facebook.com/krieg.ricardo >> github: https://github.com/ricardokrieg >> >> > -- Ricardo Franco Andrade @ricardokrieg ( Game | Desktop | Web ) Developer email: [email protected] contact: +55 (86) 9958 9725 +55 (86) 9436 0830 twitter: twitter.com/ricardokrieg facebooK: https://www.facebook.com/krieg.ricardo github: https://github.com/ricardokrieg
