123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324 |
- #include "sys-defines.h"
- #include "extern.h"
- int
- _API_linemod (R___(Plotter *_plotter) const char *s)
- {
- bool matched = false;
- char *line_mode;
- int i;
- if (!_plotter->data->open)
- {
- _plotter->error (R___(_plotter)
- "linemod: invalid operation");
- return -1;
- }
- _API_endpath (S___(_plotter));
-
- if ((!s) || !strcmp(s, "(null)"))
- s = _default_drawstate.line_mode;
- free ((char *)_plotter->drawstate->line_mode);
- line_mode = (char *)_pl_xmalloc (strlen (s) + 1);
- strcpy (line_mode, s);
- _plotter->drawstate->line_mode = line_mode;
-
- if (strcmp (s, "disconnected") == 0)
-
- {
- _plotter->drawstate->line_type = PL_L_SOLID;
- _plotter->drawstate->points_are_connected = false;
- matched = true;
- }
-
- else
- for (i = 0; i < PL_NUM_LINE_TYPES; i++)
- {
- if (strcmp (s, _pl_g_line_styles[i].name) == 0)
- {
- _plotter->drawstate->line_type =
- _pl_g_line_styles[i].type;
- _plotter->drawstate->points_are_connected = true;
- matched = true;
- break;
- }
- }
-
- if (matched == false)
-
- _API_linemod (R___(_plotter) _default_drawstate.line_mode);
-
- _plotter->drawstate->dash_array_in_effect = false;
- return 0;
- }
- int
- _API_capmod (R___(Plotter *_plotter) const char *s)
- {
- char *cap_mode;
- if (!_plotter->data->open)
- {
- _plotter->error (R___(_plotter)
- "capmod: invalid operation");
- return -1;
- }
- _API_endpath (S___(_plotter));
-
- if ((!s) || !strcmp(s, "(null)"))
- s = _default_drawstate.cap_mode;
- free ((char *)_plotter->drawstate->cap_mode);
- cap_mode = (char *)_pl_xmalloc (strlen (s) + 1);
- strcpy (cap_mode, s);
- _plotter->drawstate->cap_mode = cap_mode;
-
- if (strcmp( s, "butt") == 0)
- _plotter->drawstate->cap_type = PL_CAP_BUTT;
- else if (strcmp( s, "round") == 0)
- _plotter->drawstate->cap_type = PL_CAP_ROUND;
- else if (strcmp( s, "projecting") == 0)
- _plotter->drawstate->cap_type = PL_CAP_PROJECT;
- else if (strcmp( s, "triangular") == 0)
- _plotter->drawstate->cap_type = PL_CAP_TRIANGULAR;
- else
-
- return _API_capmod (R___(_plotter) _default_drawstate.cap_mode);
-
- return 0;
- }
- int
- _API_joinmod (R___(Plotter *_plotter) const char *s)
- {
- char *join_mode;
- if (!_plotter->data->open)
- {
- _plotter->error (R___(_plotter)
- "joinmod: invalid operation");
- return -1;
- }
- _API_endpath (S___(_plotter));
-
- if ((!s) || !strcmp(s, "(null)"))
- s = _default_drawstate.join_mode;
- free ((char *)_plotter->drawstate->join_mode);
- join_mode = (char *)_pl_xmalloc (strlen (s) + 1);
- strcpy (join_mode, s);
- _plotter->drawstate->join_mode = join_mode;
-
- if (strcmp( s, "miter") == 0)
- _plotter->drawstate->join_type = PL_JOIN_MITER;
- else if (strcmp( s, "mitre") == 0)
- _plotter->drawstate->join_type = PL_JOIN_MITER;
- else if (strcmp( s, "round") == 0)
- _plotter->drawstate->join_type = PL_JOIN_ROUND;
- else if (strcmp( s, "bevel") == 0)
- _plotter->drawstate->join_type = PL_JOIN_BEVEL;
- else if (strcmp( s, "triangular") == 0)
- _plotter->drawstate->join_type = PL_JOIN_TRIANGULAR;
- else
-
- return _API_joinmod (R___(_plotter) _default_drawstate.join_mode);
-
- return 0;
- }
- int
- _API_fmiterlimit (R___(Plotter *_plotter) double new_miter_limit)
- {
- if (!_plotter->data->open)
- {
- _plotter->error (R___(_plotter)
- "flinewidth: invalid operation");
- return -1;
- }
- _API_endpath (S___(_plotter));
- if (new_miter_limit < 1.0)
- new_miter_limit = PL_DEFAULT_MITER_LIMIT;
-
- _plotter->drawstate->miter_limit = new_miter_limit;
-
- return 0;
- }
- int
- _API_orientation (R___(Plotter *_plotter) int direction)
- {
- if (!_plotter->data->open)
- {
- _plotter->error (R___(_plotter)
- "orientation: invalid operation");
- return -1;
- }
- if (direction != 1 && direction != -1)
-
- direction = _default_drawstate.orientation;
- _plotter->drawstate->orientation = direction;
-
- return 0;
- }
- int
- _API_fillmod (R___(Plotter *_plotter) const char *s)
- {
- const char *default_s;
- char *fill_rule;
- if (!_plotter->data->open)
- {
- _plotter->error (R___(_plotter)
- "fillmod: invalid operation");
- return -1;
- }
- _API_endpath (S___(_plotter));
-
- default_s = _default_drawstate.fill_rule;
- if (strcmp (default_s, "even-odd") == 0
- && _plotter->data->have_odd_winding_fill == 0)
- default_s = "nonzero-winding";
- else if (strcmp (default_s, "nonzero-winding") == 0
- && _plotter->data->have_nonzero_winding_fill == 0)
- default_s = "even-odd";
-
-
- if ((!s) || !strcmp(s, "(null)"))
- s = default_s;
- free ((char *)_plotter->drawstate->fill_rule);
- fill_rule = (char *)_pl_xmalloc (strlen (s) + 1);
- strcpy (fill_rule, s);
- _plotter->drawstate->fill_rule = fill_rule;
- if ((strcmp (s, "even-odd") == 0 || strcmp (s, "alternate") == 0)
- && _plotter->data->have_odd_winding_fill)
- _plotter->drawstate->fill_rule_type = PL_FILL_ODD_WINDING;
- else if ((strcmp (s, "nonzero-winding") == 0 || strcmp (s, "winding") == 0)
- && _plotter->data->have_nonzero_winding_fill)
- _plotter->drawstate->fill_rule_type = PL_FILL_NONZERO_WINDING;
- else
-
- _API_fillmod (R___(_plotter) default_s);
- return 0;
- }
|