diff options
author | scuri <scuri> | 2009-06-23 03:18:33 +0000 |
---|---|---|
committer | scuri <scuri> | 2009-06-23 03:18:33 +0000 |
commit | 0610dd4f3064220a2e8fb1d8dc120044eb6c64a8 (patch) | |
tree | a5d0d3b6c79e967cd4e80c7668b906e8b422f902 /src/cd_util.c | |
parent | 09be96e0606d05b056f82b5f9254208a2d0e4c88 (diff) |
*** empty log message ***
Diffstat (limited to 'src/cd_util.c')
-rw-r--r-- | src/cd_util.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/src/cd_util.c b/src/cd_util.c index 033fac6..dadb6f4 100644 --- a/src/cd_util.c +++ b/src/cd_util.c @@ -223,6 +223,21 @@ int cdfCheckBoxSize(double *xmin, double *xmax, double *ymin, double *ymax) return 1; } +void cdMovePoint(int *x, int *y, double dx, double dy, double sin_theta, double cos_theta) +{ + double t; + t = cos_theta*dx - sin_theta*dy; + *x += _cdRound(t); + t = sin_theta*dx + cos_theta*dy; + *y += _cdRound(t); +} + +void cdfMovePoint(double *x, double *y, double dx, double dy, double sin_theta, double cos_theta) +{ + *x += cos_theta*dx - sin_theta*dy; + *y += sin_theta*dx + cos_theta*dy; +} + void cdRotatePoint(cdCanvas* canvas, int x, int y, int cx, int cy, int *rx, int *ry, double sin_theta, double cos_theta) { double t; @@ -283,3 +298,38 @@ int cdStrEqualNoCase(const char* str1, const char* str2) return 0; } +/* Copied from IUP3, simply ignore line breaks other than '\n' for CD */ + +int cdStrLineCount(const char* str) +{ + int num_lin = 1; + + if (!str) + return num_lin; + + while(*str != 0) + { + while(*str!=0 && *str!='\n') + str++; + + if (*str=='\n') /* UNIX line end */ + { + num_lin++; + str++; + } + } + + return num_lin; +} + +char* cdStrDup(const char *str) +{ + if (str) + { + int size = strlen(str)+1; + char *newstr = malloc(size); + if (newstr) memcpy(newstr, str, size); + return newstr; + } + return NULL; +} |