~ubuntu-branches/ubuntu/karmic/python-scipy/karmic

« back to all changes in this revision

Viewing changes to Lib/xplt/src/play/mac/pals.m

  • Committer: Bazaar Package Importer
  • Author(s): Daniel T. Chen (new)
  • Date: 2005-03-16 02:15:29 UTC
  • Revision ID: james.westby@ubuntu.com-20050316021529-xrjlowsejs0cijig
Tags: upstream-0.3.2
ImportĀ upstreamĀ versionĀ 0.3.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * pals.m
 
3
 * p_palette for Mac OS X.
 
4
 *
 
5
 * Copyright (c) 2000.  See accompanying LEGAL file for details.
 
6
 */
 
7
 
 
8
#include "playm.h"
 
9
#include "pstdlib.h"
 
10
 
 
11
void
 
12
p_palette(p_win *w, unsigned long *colors, int n)
 
13
{
 
14
  p_scr *s = w->s;
 
15
  int i;
 
16
 
 
17
  if (n > 256) n = 256;
 
18
  if (n > 240) n = 240;    /* system reserves 20 colors -- may only get 236 */
 
19
 
 
20
  if (w->parent) w = w->parent;
 
21
 
 
22
  if (!p_signalling) {
 
23
    for (i=0 ; i<n ; i++) {
 
24
      w->pixels[i][0] = P_R(colors[i]) / 255.0;
 
25
      w->pixels[i][1] = P_G(colors[i]) / 255.0;
 
26
      w->pixels[i][2] = P_B(colors[i]) / 255.0;
 
27
      w->pixels[i][3] = 1.0;
 
28
    }
 
29
    for (; i<w->n_pixels ; i++)
 
30
    { w->pixels[i][0] = s->sys_colors[255-P_FG][0];
 
31
      w->pixels[i][1] = s->sys_colors[255-P_FG][1];
 
32
      w->pixels[i][2] = s->sys_colors[255-P_FG][2];
 
33
      w->pixels[i][3] = s->sys_colors[255-P_FG][3];
 
34
    }
 
35
    w->n_pixels = n;
 
36
  }
 
37
}