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

« back to all changes in this revision

Viewing changes to Lib/xplt/src/play/x11/points.c

  • 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
 * points.c -- $Id: points.c,v 1.1 2003/03/08 15:26:51 travo Exp $
 
3
 * p_i_pnts, p_d_pnts, p_d_map for X11
 
4
 *
 
5
 * Copyright (c) 1998.  See accompanying LEGAL file for details.
 
6
 */
 
7
 
 
8
#include "config.h"
 
9
#include "playx.h"
 
10
 
 
11
XPoint x_pt_list[2050];
 
12
int x_pt_count = 0;
 
13
static double x_pt_xa=1., x_pt_xb=0., x_pt_ya=1., x_pt_yb=0.;
 
14
 
 
15
/* ARGSUSED */
 
16
void
 
17
p_d_map(p_win *w, double xt[], double yt[], int set)
 
18
{
 
19
  if (set) {
 
20
    x_pt_xa = xt[0];
 
21
    x_pt_xb = xt[1];
 
22
    x_pt_ya = yt[0];
 
23
    x_pt_yb = yt[1];
 
24
  } else {
 
25
    xt[0] = x_pt_xa;
 
26
    xt[1] = x_pt_xb;
 
27
    yt[0] = x_pt_ya;
 
28
    yt[1] = x_pt_yb;
 
29
  }
 
30
}
 
31
 
 
32
void
 
33
p_i_pnts(p_win *w, const int *x, const int *y, int n)
 
34
{
 
35
  if (n == -1) {
 
36
    if (x_pt_count < 2048) {
 
37
      n = x_pt_count++;
 
38
      x_pt_list[n].x = x[0];
 
39
      x_pt_list[n].y = y[0];
 
40
    } else {
 
41
      x_pt_count = 0;
 
42
    }
 
43
  } else {
 
44
    XPoint *wrk = x_pt_list;
 
45
    if (n >= 0) {
 
46
      x_pt_count = n;
 
47
    } else {
 
48
      wrk += x_pt_count;
 
49
      n = -n;
 
50
      x_pt_count += n;
 
51
    }
 
52
    if (x_pt_count <= 2048) {
 
53
      while (n--) {
 
54
        wrk[0].x = *x++;
 
55
        wrk[0].y = *y++;
 
56
        wrk++;
 
57
      }
 
58
    } else {
 
59
      x_pt_count = 0;
 
60
    }
 
61
  }
 
62
}
 
63
 
 
64
/* ARGSUSED */
 
65
void
 
66
p_d_pnts(p_win *w, const double *x, const double *y, int n)
 
67
{
 
68
  if (n == -1) {
 
69
    if (x_pt_count < 2048) {
 
70
      n = x_pt_count++;
 
71
      x_pt_list[n].x = (short)(x_pt_xa*x[0] + x_pt_xb);
 
72
      x_pt_list[n].y = (short)(x_pt_ya*y[0] + x_pt_yb);
 
73
    } else {
 
74
      x_pt_count = 0;
 
75
    }
 
76
  } else {
 
77
    XPoint *wrk = x_pt_list;
 
78
    if (n >= 0) {
 
79
      x_pt_count = n;
 
80
    } else {
 
81
      wrk += x_pt_count;
 
82
      n = -n;
 
83
      x_pt_count += n;
 
84
    }
 
85
    if (x_pt_count <= 2048) {
 
86
      while (n--) {
 
87
        wrk[0].x = (short)(x_pt_xa*(*x++) + x_pt_xb);
 
88
        wrk[0].y = (short)(x_pt_ya*(*y++) + x_pt_yb);
 
89
        wrk++;
 
90
      }
 
91
    } else {
 
92
      x_pt_count = 0;
 
93
    }
 
94
  }
 
95
}