X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=cmds.cc;h=24fae4ebd1685033f09787a53a401bb5a2ca202f;hb=33a127c6d1e89d83af157f260fb26f475603df6b;hp=4f6fd1d27df6429111f878c91224ea75f003b92d;hpb=ec4ada7cd4150f10ba26566aab706fecc7f6927d;p=paperjam.git diff --git a/cmds.cc b/cmds.cc index 4f6fd1d..24fae4e 100644 --- a/cmds.cc +++ b/cmds.cc @@ -61,8 +61,8 @@ static const arg_def move_args[] = { static cmd_exec *move_ctor(cmd *c) { move_cmd *m = new move_cmd; - m->x = c->args.at(0)->double_default(0); - m->y = c->args.at(1)->double_default(0); + m->x = c->args.at(0)->as_double(0); + m->y = c->args.at(1)->as_double(0); return m; } @@ -95,16 +95,50 @@ static const arg_def scale_args[] = { static cmd_exec *scale_ctor(cmd *c) { scale_cmd *s = new scale_cmd; - s->x_factor = c->args.at(0)->double_default(1); - s->y_factor = c->args.at(1)->double_default(s->x_factor); + s->x_factor = c->args.at(0)->as_double(1); + s->y_factor = c->args.at(1)->as_double(s->x_factor); return s; } +/*** rotate ***/ + +class rotate_cmd : public cmd_exec { +public: + int deg; + vector process(vector &pages); +}; + +vector rotate_cmd::process(vector &pages) +{ + vector out; + for (auto p: pages) + { + xform_page *q = new xform_page(p, p->width, p->height); + // FIXME: This does not work yet + q->xform.rotate_deg(90); + out.push_back(q); + } + return out; +} + +static const arg_def rotate_args[] = { + { "angle", AT_INT | AT_MANDATORY | AT_POSITIONAL }, + { NULL, 0 } +}; + +static cmd_exec *rotate_ctor(cmd *c) +{ + rotate_cmd *r = new rotate_cmd; + r->deg = c->args.at(0)->as_int(0); + return r; +} + /*** Command table ***/ const cmd_def cmd_table[] = { { "move", move_args, 0, move_ctor }, { "scale", scale_args, 0, scale_ctor }, + { "rotate", rotate_args, 0, rotate_ctor }, { "null", null_args, 0, null_ctor }, { NULL, NULL, 0, NULL } };