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

« back to all changes in this revision

Viewing changes to Lib/xplt/src/play/win/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:49 travo Exp $
 
3
 * p_i_pnts, p_d_pnts, p_d_map for MS Windows
 
4
 *
 
5
 * Copyright (c) 1998.  See accompanying LEGAL file for details.
 
6
 */
 
7
 
 
8
#include "playw.h"
 
9
 
 
10
POINT w_pt_list[2050];
 
11
int w_pt_count = 0;
 
12
static double w_pt_xa=1., w_pt_xb=0., w_pt_ya=1., w_pt_yb=0.;
 
13
 
 
14
/* ARGSUSED */
 
15
void
 
16
p_d_map(p_win *w, double xt[], double yt[], int set)
 
17
{
 
18
  if (set) {
 
19
    w_pt_xa = xt[0];
 
20
    w_pt_xb = xt[1];
 
21
    w_pt_ya = yt[0];
 
22
    w_pt_yb = yt[1];
 
23
  } else {
 
24
    xt[0] = w_pt_xa;
 
25
    xt[1] = w_pt_xb;
 
26
    yt[0] = w_pt_ya;
 
27
    yt[1] = w_pt_yb;
 
28
  }
 
29
}
 
30
 
 
31
void
 
32
p_i_pnts(p_win *w, const int *x, const int *y, int n)
 
33
{
 
34
  if (n == -1) {
 
35
    if (w_pt_count < 2048) {
 
36
      n = w_pt_count++;
 
37
      w_pt_list[n].x = x[0];
 
38
      w_pt_list[n].y = y[0];
 
39
    } else {
 
40
      w_pt_count = 0;
 
41
    }
 
42
  } else {
 
43
    POINT *wrk = w_pt_list;
 
44
    if (n >= 0) {
 
45
      w_pt_count = n;
 
46
    } else {
 
47
      wrk += w_pt_count;
 
48
      n = -n;
 
49
      w_pt_count += n;
 
50
    }
 
51
    if (w_pt_count <= 2048) {
 
52
      while (n--) {
 
53
        wrk[0].x = *x++;
 
54
        wrk[0].y = *y++;
 
55
        wrk++;
 
56
      }
 
57
    } else {
 
58
      w_pt_count = 0;
 
59
    }
 
60
  }
 
61
}
 
62
 
 
63
/* ARGSUSED */
 
64
void
 
65
p_d_pnts(p_win *w, const double *x, const double *y, int n)
 
66
{
 
67
  if (n == -1) {
 
68
    if (w_pt_count < 2048) {
 
69
      n = w_pt_count++;
 
70
      w_pt_list[n].x = (long)(w_pt_xa*x[0] + w_pt_xb);
 
71
      w_pt_list[n].y = (long)(w_pt_ya*y[0] + w_pt_yb);
 
72
    } else {
 
73
      w_pt_count = 0;
 
74
    }
 
75
  } else {
 
76
    POINT *wrk = w_pt_list;
 
77
    if (n >= 0) {
 
78
      w_pt_count = n;
 
79
    } else {
 
80
      wrk += w_pt_count;
 
81
      n = -n;
 
82
      w_pt_count += n;
 
83
    }
 
84
    if (w_pt_count <= 2048) {
 
85
      while (n--) {
 
86
        wrk[0].x = (long)(w_pt_xa*(*x++) + w_pt_xb);
 
87
        wrk[0].y = (long)(w_pt_ya*(*y++) + w_pt_yb);
 
88
        wrk++;
 
89
      }
 
90
    } else {
 
91
      w_pt_count = 0;
 
92
    }
 
93
  }
 
94
}