示例#1
0
object_ptr interpreter::make_polygon (parameters &command) {
   TRACE ('f', command);
   double thick = 2.0; //Default thickness of 2
   if (command.size() % 2 == 1){
      thick = from_string<double>(command.back());
      command.pop_back();
   }
   coordlist poly_points{};
   while(!command.empty()){
      double x = from_string<double>(shift(command));
      double y = from_string<double>(shift(command));
      poly_points.push_back({inches(x), inches(y)});
   }
   return make_shared<polygon> (poly_points, points(thick));
}
示例#2
0
void interpreter::do_draw (parameters &params) {
   TRACE ('i', params);
   string name = shift (params);
   object_map::const_iterator itor = objmap.find (name);
   if (itor == objmap.end()) {
      throw runtime_error (name + ": no such object");
   }
   degrees angle = degrees (0);
   if (params.size() == 3) {
      angle = degrees (from_string<double> (params.back()));
      params.pop_back();
   }
   if (params.size() != 2) throw runtime_error ("syntax error");
   xycoords coords (inches (from_string<double> (params.front())),
                    inches (from_string<double> (params.back())));
   itor->second->draw (outfile, coords, angle);
}