void concater_rep::ghost (string s, path ip, color col) { if ((N(s)>2) && (s[0]=='<') && (s[N(s)-1]=='>')) { ghost ("<", ip, col); ghost (s (1,N(s)-1), ip, col); ghost (">", ip, col); return; } string fn_name= "cmr"; if (N(s)==1) { if (s[0] == '<') { fn_name= "cmsy"; s= "h"; } else if (s[0] == '>') { fn_name= "cmsy"; s= "i"; } else if (s[0] == '|') { fn_name= "cmsy"; s= "j"; } else if (s[0] == '\\') { fn_name= "cmsy"; s= "n"; } else if (s[0] == '{') { fn_name= "cmsy"; s= "f"; } else if (s[0] == '}') { fn_name= "cmsy"; s= "g"; } } int sz= script (env->fn_size, env->index_level); font gfn (tex_font (fn_name, sz, (int) (env->magn*env->dpi))); box b= text_box (decorate (ip), 0, s, gfn, col); array<box> bs (1); bs[0]= b; a << line_item (STD_ITEM, OP_SKIP, composite_box (decorate (ip), bs), HYPH_INVALID); }
box pager_rep::make_footer (bool empty_flag) { if (!show_hf || empty_flag) return empty_box (decorate ()); env->write (PAGE_NR, as_string (N(pages)+1+page_offset)); env->write (PAGE_THE_PAGE, style[PAGE_THE_PAGE]); tree old= env->local_begin (PAR_COLUMNS, "1"); string which= (N(pages)&1)==0? PAGE_ODD_FOOTER: PAGE_EVEN_FOOTER; if (style [PAGE_THIS_FOOTER] != "") which= PAGE_THIS_FOOTER; box b= typeset_as_concat (env, attach_here (tree (PARA, style[which]), decorate())); style (PAGE_THIS_FOOTER) = ""; env->local_end (PAR_COLUMNS, old); return b; }
void bridge_ornament_rep::my_typeset (int desired_status) { ornament_parameters ps= env->get_ornament_parameters (); SI l = env->get_length (PAR_LEFT ) + ps->lpad; SI r = env->get_length (PAR_RIGHT) + ps->rpad; with = tuple (PAR_LEFT , tree (TMLEN, as_string (l))) * tuple (PAR_RIGHT, tree (TMLEN, as_string (r))); box b = typeset_ornament (desired_status); box xb; if (N(st) == 2) xb= typeset_as_concat (env, st[1], descend (ip, 1)); box hb= highlight_box (ip, b, xb, ps); box mb= move_box (decorate (ip), hb, -l, 0); insert_ornament (remember_box (decorate (ip), mb)); }
void grid_box_rep::display (renderer ren) { int i; if (first_time || ren->pixel!=ren_pixel) { point p1= f [point (x1, y1)]; point p2= f [point (x2, y2)]; point l1= point (min (p1[0], p2[0]), min (p1[1], p2[1])); point l2= point (max (p1[0], p2[0]), max (p1[1], p2[1])); point e1= l1, e2= point (l1[0], l2[1]); point e3= l2, e4= point (l2[0], l1[1]); point e1t= f (e1), e2t= f (e2); point e3t= f (e3), e4t= f (e4); double L1t, L2t, L3t, L4t; L1t= norm (e2t - e1t); L2t= norm (e3t - e2t); L3t= norm (e4t - e3t); L4t= norm (e1t - e4t); ASSERT (!fnull (L1t, 1e-6) && !fnull (L2t, 1e-6) && !fnull (L3t, 1e-6) && !fnull (L4t, 1e-6), "one side of the grid has length zero"); array<grid_curve> grads= g->get_curves (l1, l2); for (i=0; i<N(grads); i++) { curve c= f (grads[i]->c); bs << curve_box (decorate (ip), c, pencil (named_color (grads[i]->col), ren->pixel), array<bool> (0), 0, brush (false), array<box> (0)); } first_time= false; ren_pixel= ren->pixel; } for (i=0; i<N(bs); i++) bs[i]->display (ren); }
// This implements the pyqtSignature decorator. PyObject *qpycore_pyqtsignature(PyObject *args, PyObject *kwds) { const char *sig_str; PyObject *res_obj = 0; static const char *kwlist[] = {"signature", "result", 0}; if (!PyArg_ParseTupleAndKeywords(args, kwds, #if PY_VERSION_HEX >= 0x02050000 "s|O:pyqtSignature", #else const_cast<char *>("s|O:pyqtSignature"), #endif const_cast<char **>(kwlist), &sig_str, &res_obj)) return 0; // Parse the signature. QByteArray sig(sig_str); // Make sure the signature has parentheses before normalising it. if (!sig.contains('(')) { sig.prepend('('); sig.append(')'); } sig = QMetaObject::normalizedSignature(sig); Chimera::Signature *parsed_sig = Chimera::parse(sig, "a pyqtSlot signature argument"); if (!parsed_sig) return 0; return decorate(parsed_sig, res_obj, "a pyqtSignature result"); }
// This implements the pyqtSlot decorator. PyObject *qpycore_pyqtslot(PyObject *args, PyObject *kwds) { const char *name_str = 0; PyObject *res_obj = 0; static const char *kwlist[] = {"name", "result", 0}; static PyObject *no_args = 0; if (!no_args) { no_args = PyTuple_New(0); if (!no_args) return 0; } if (!PyArg_ParseTupleAndKeywords(no_args, kwds, #if PY_VERSION_HEX >= 0x02050000 "|sO:pyqtSlot", #else const_cast<char *>("|sO:pyqtSlot"), #endif const_cast<char **>(kwlist), &name_str, &res_obj)) return 0; Chimera::Signature *parsed_sig = Chimera::parse(args, name_str, "a pyqtSlot type argument"); if (!parsed_sig) return 0; return decorate(parsed_sig, res_obj, "a pyqtSlot result"); }
void bridge_canvas_rep::my_typeset (int desired_status) { canvas_properties props= get_canvas_properties (env, st); SI delta= 0; string type= props->type; if (type != "plain") { SI hpad= props->hpadding; SI w = props->bar_width; SI pad = props->bar_padding; SI bor = props->border; if (ends (type, "w") || ends (type, "e")) delta= max (0, w + pad); delta += 2 * bor + 2 * hpad; } SI l= env->get_length (PAR_LEFT); SI r= env->get_length (PAR_RIGHT) + delta; with= tuple (PAR_LEFT, tree (TMLEN, as_string (0))) * tuple (PAR_RIGHT, tree (TMLEN, as_string (l + r))); box b = typeset_ornament (desired_status); SI x1, y1, x2, y2, scx, scy; get_canvas_horizontal (props, b->x1, b->x2, x1, x2, scx); get_canvas_vertical (props, b->y1, b->y2, y1, y2, scy); path dip= (type == "plain"? ip: decorate (ip)); box cb= clip_box (dip, b, x1, y1, x2, y2, props->xt, props->yt, scx, scy); if (type != "plain") cb= put_scroll_bars (props, cb, ip, b, scx, scy); insert_ornament (cb); //insert_ornament (remember_box (decorate (ip), cb)); }
void Client::activate() { // fprintf(stderr, "Client::activate (this = %p, window = %x, parent = %x)\n", // this, m_window, parent()); if (parent() == root()) { fprintf(stderr, "wm2: warning: bad parent in Client::activate\n"); return; } if (!m_managed || isHidden() || isWithdrawn()) return; if (isActive()) { decorate(True); if (CONFIG_AUTO_RAISE || CONFIG_RAISE_ON_FOCUS) mapRaised(); return; } if (activeClient()) { activeClient()->deactivate(); // & some other-screen business } XUngrabButton(display(), AnyButton, AnyModifier, parent()); XSetInputFocus(display(), m_window, RevertToPointerRoot, windowManager()->timestamp(False)); if (m_protocol & PtakeFocus) { sendMessage(Atoms::wm_protocols, Atoms::wm_takeFocus); } // now set revert of window that reverts to this one so as to // revert to the window this one used to revert to (huh?) windowManager()->skipInRevert(this, m_revert); m_revert = activeClient(); while (m_revert && !m_revert->isNormal()) m_revert = m_revert->revertTo(); windowManager()->setActiveClient(this); // if (CONFIG_AUTO_RAISE || CONFIG_RAISE_ON_FOCUS) mapRaised(); decorate(True); installColormap(); // new! }
void MessageSession::sendMessage(const Message &message) { if(!m_manager) return; Message msg = message; msg.setThread(m_thread); decorate(msg); m_manager->send(msg); }
QString DecorateBase::Decorate(QTextStream *ts) { QString result; for (;;) { QString line = ts->readLine(); if (line.length() == 0) break; result += decorate(line); } return result; }
/** * @brief DecorateBase::Decorate * * @param sl splitted strings by QString::split("\n"). * the last element will not be processed to concatenate the next input. * * @return decorated string. */ QString DecorateBase::Decorate(QStringList *sl) { QString result; for (int i = 0 ; i < sl->size()-1 ; ++i) { QString line = sl->at(i); if (line.length() == 0) continue; result += decorate(line); } return result; }
static box make_ornament_body (path ip, array<page_item> l) { int i, n= N(l); array<box> lines_bx (n); array<SI> lines_ht (n); for (i=0; i<n; i++) { page_item item= copy (l[i]); lines_bx[i]= item->b; lines_ht[i]= item->spc->def; } box b= stack_box (ip, lines_bx, lines_ht); SI dy= n==0? 0: b[0]->y2; return move_box (decorate (ip), stack_box (ip, lines_bx, lines_ht), 0, dy); }
void Client::deactivate() // called from wm? { // fprintf(stderr, // "Client::deactivate (this = %p, window = %x, parent = %x)\n", // this, m_window, parent()); if (parent() == root()) { fprintf(stderr, "wm2: warning: bad parent in Client::deactivate\n"); return; } XGrabButton(display(), AnyButton, AnyModifier, parent(), False, ButtonPressMask | ButtonReleaseMask, GrabModeAsync, GrabModeSync, None, None); decorate(False); }
void decorateBatch() { if (m_tc.isNull()) return; QElapsedTimer t; t.start(); do { m_tc = m_tc.document()->find(m_re, m_tc, QTextDocument::FindBackward); if (m_tc.isNull()) return; decorate(&m_tc); } while ( t.elapsed() < 20 ); m_timerDecorate.start(); }
void MessageSession::send( const std::string& message, const std::string& subject, const StanzaExtensionList& sel ) { if( !m_hadMessages ) { m_thread = "gloox" + m_parent->getID(); m_hadMessages = true; } Message m( Message::Chat, m_target.full(), message, subject, m_thread ); m.setID( m_parent->getID() ); decorate( m ); if( sel.size() ) { StanzaExtensionList::const_iterator it = sel.begin(); for( ; it != sel.end(); ++it ) m.addExtension( (*it)); } m_parent->send( m ); }
void concater_rep::flag_ok (string s, path ip, color col) { path dip = decorate_right (ip); SI h= 4*env->fn->wfn/5; int r, g, b, a; get_rgb_color (col, r, g, b, a); //r= 255- (255 - r)/6; //g= 255- (255 - g)/6; //b= 255- (255 - b)/6; a= a/6; color light= rgb_color (r, g, b, a); int info= env->info_level; if (info == INFO_MINIMAL || info == INFO_SHORT || info == INFO_SHORT_PAPER) { box infob= info_box (dip, h, pencil (col, env->fn->wline), light); if (info == INFO_SHORT_PAPER) { box b= resize_box (ip, infob, 0, 0, 0, env->fn->yx); print (b); } else { box specb= specific_box (ip, infob, "screen", env->fn); print (specb); } } else if (info == INFO_DETAILED || info == INFO_PAPER) { int sz= script (env->fn_size, env->index_level+2); font gfn (tex_font ("ecrm", sz, (int) (env->magn*env->dpi))); box textb= text_box (decorate (ip), 0, s, gfn, col); box flagb= flag_box (dip, textb, h, pencil (col, env->fn->wline), light); if (info == INFO_DETAILED) { box specb= specific_box (ip, flagb, "screen", env->fn); print (specb); } else { box b= resize_box (ip, flagb, 0, 0, 0, env->fn->yx); print (b); } } }
void MessageSession::send( const std::string& message, const std::string& subject ) { if( !m_hadMessages ) { m_thread = "gloox" + m_parent->getID(); m_hadMessages = true; } Tag *m = new Tag( "message" ); m->addAttribute( "type", "chat" ); new Tag( m, "body", message ); if( !subject.empty() ) new Tag( m, "subject", subject ); m->addAttribute( "from", m_parent->jid().full() ); m->addAttribute( "to", m_target.full() ); m->addAttribute( "id", m_parent->getID() ); new Tag( m, "thread", m_thread ); decorate( m ); m_parent->send( m ); }
int compiler::SemanticAnalyzer::analyze(AST *ast) { Node *root = ast->getRoot(); std::stringstream ss; exception *e; try { #ifdef DEBUG std::cerr << "\n\n---------SEMANTIC ANALYZER---------\n\n"; #endif decorate(root); fillTable(root, 0); /*Token resultant = descend(root); if(resultant.type==30 || resultant.type==22 || resultant.type==36) { std::vector<Token> expression = {resultant}; ss << "Unable to handle expression."; e = new exception(expression, ss.str()); throw *e; }*/ } catch (compiler::exception &e) { std::cerr << e.what() << std::endl; return 1; } }
void idol() { stile(player->y, player->x, TL_IDOL_BASE); if (psel("YOU FIND THE BLOOD-STAINED IDOL\n" "OF A DARK AND NAMELESS GOD\n" "\n" "<- SMASH IT#SACRIFICE ->") == 0) { decorate(player->y, player->x, DEC_BROKEN_IDOL); game->piety += IDOL_SMASH_PIETY + rand() % IDOL_SMASH_PIETY; game->sacrifice -= IDOL_SACRIFICE_PEN; } else { stile(player->y - 3, player->x, TL_IDOL_HEAD_LIT); player->hp--; draw_bars(); draw_board(); pwait("YOU DRAW A SINGLE DROP\n" "OF BLOOD AS TRIBUTE"); game->sacrifice += IDOL_SACRIFICE_GAIN; game->piety -= IDOL_SMASH_PIETY + rand() % IDOL_SMASH_PIETY; if (player->hp <= 0) { draw_board(); pwait("YOU HAVE GIVEN YOUR LIFE!!!"); draw_board(); game_over("YOU SACRIFICED YOURSELF\n" "TO A DARK AND NAMELESS GOD", false); } else if (rand() % MAX(1, game->sacrifice) > IDOL_SACRIFICE_LIMIT) { draw_board(); game->sacrifice -= IDOL_SACRIFICE_LIMIT; draw_board(); switch(rand() % 2) { case 0: pwait("YOU HAVE BEEN REWARDED"); refill_hp(IDOL_HP_REFILL); break; case 1: pwait("YOU HEAR A MOCKING LAUGHTER"); refill_hp(5); player->strength = MAX(1, player->strength - 4 + rand() % 9); player->speed = MAX(1, player->speed - 4 + rand() % 9); break; } } } return; }
void test_macro_args() { int i = 0; int *Ptr; IS_EQ(static_cast<int*>(0), Ptr); // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: use nullptr // CHECK-FIXES: IS_EQ(static_cast<int*>(nullptr), Ptr); IS_EQ(0, Ptr); // literal // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: use nullptr // CHECK-FIXES: IS_EQ(nullptr, Ptr); IS_EQ(NULL, Ptr); // macro // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: use nullptr // CHECK-FIXES: IS_EQ(nullptr, Ptr); // These are ok since the null literal is not spelled within a macro. #define myassert(x) if (!(x)) return; myassert(0 == Ptr); // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use nullptr // CHECK-FIXES: myassert(nullptr == Ptr); myassert(NULL == Ptr); // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use nullptr // CHECK-FIXES: myassert(nullptr == Ptr); // These are bad as the null literal is buried in a macro. #define BLAH(X) myassert(0 == (X)); #define BLAH2(X) myassert(NULL == (X)); BLAH(Ptr); BLAH2(Ptr); // Same as above but testing extra macro expansion. #define EXPECT_NULL(X) IS_EQ(0, X); #define EXPECT_NULL2(X) IS_EQ(NULL, X); EXPECT_NULL(Ptr); EXPECT_NULL2(Ptr); // Almost the same as above but now null literal is not in a macro so ok // to transform. #define EQUALS_PTR(X) IS_EQ(X, Ptr); EQUALS_PTR(0); // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: use nullptr // CHECK-FIXES: EQUALS_PTR(nullptr); EQUALS_PTR(NULL); // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: use nullptr // CHECK-FIXES: EQUALS_PTR(nullptr); // Same as above but testing extra macro expansion. #define EQUALS_PTR_I(X) EQUALS_PTR(X) EQUALS_PTR_I(0); // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: use nullptr // CHECK-FIXES: EQUALS_PTR_I(nullptr); EQUALS_PTR_I(NULL); // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: use nullptr // CHECK-FIXES: EQUALS_PTR_I(nullptr); // Ok since null literal not within macro. However, now testing macro // used as arg to another macro. #define decorate(EXPR) side_effect(); EXPR; decorate(IS_EQ(NULL, Ptr)); // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: use nullptr // CHECK-FIXES: decorate(IS_EQ(nullptr, Ptr)); decorate(IS_EQ(0, Ptr)); // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: use nullptr // CHECK-FIXES: decorate(IS_EQ(nullptr, Ptr)); // This macro causes a NullToPointer cast to happen where 0 is assigned to z // but the 0 literal cannot be replaced because it is also used as an // integer in the comparison. #define INT_AND_PTR_USE(X) do { int *z = X; if (X == 4) break; } while(false) INT_AND_PTR_USE(0); // Both uses of X in this case result in NullToPointer casts so replacement // is possible. #define PTR_AND_PTR_USE(X) do { int *z = X; if (X != z) break; } while(false) PTR_AND_PTR_USE(0); // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: use nullptr // CHECK-FIXES: PTR_AND_PTR_USE(nullptr); PTR_AND_PTR_USE(NULL); // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: use nullptr // CHECK-FIXES: PTR_AND_PTR_USE(nullptr); #define OPTIONAL_CODE(...) __VA_ARGS__ #define NOT_NULL dummy(0) #define CALL(X) X OPTIONAL_CODE(NOT_NULL); CALL(NOT_NULL); #define ENTRY(X) {X} struct A { int *Ptr; } a[2] = {ENTRY(0), {0}}; // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: use nullptr // CHECK-MESSAGES: :[[@LINE-2]]:24: warning: use nullptr // CHECK-FIXES: a[2] = {ENTRY(nullptr), {nullptr}}; #undef ENTRY }
void compiler::SemanticAnalyzer::decorate(Node *root) { // Decorate tree with node kinds and content for(auto &i : root->children) // Descend tree to decorate children first decorate(i); if(root->tk) { // if node has a token it's a leaf node #ifdef DEBUG std::cerr << "decorating leaf node of token: " << root->tk->lexema << std::endl; #endif switch (root->tk->type) { // map each token type to a node kind case 1: root->kind = 2; break; case 2: root->kind = 15; break; case 3: root->kind = 1; break; case 4: root->kind = 1; break; case 5: root->kind = 0; break; case 6: root->kind = 5; break; case 7: root->kind = 0; break; case 8: root->kind = 18; break; case 9: root->kind = 1; break; case 10: root->kind = 17; break; case 11: root->kind = 20; /*!!!!!*/ break; case 12: root->kind = 14; break; case 13: root->kind = 5; break; case 14: root->kind = 5; break; case 15: root->kind = 10; break; case 16: root->kind = 19; break; case 17: root->kind = 5; break; case 18: root->kind = 5; break; case 19: root->kind = 15; break; case 20: root->kind = 16; break; case 21: root->kind = -1; break; case 22: root->kind = 4; break; case 23: root->kind = 5; break; case 24: root->kind = 5; break; case 25: root->kind = 10; break; case 26: root->kind = 15; break; case 27: root->kind = 4; break; case 28: root->kind = 9; break; case 29: root->kind = 13; break; case 30: root->kind = 4; break; case 31: root->kind = 13; break; case 32: root->kind = 3; break; case 33: root->kind = 13; break; case 34: root->kind = 1; break; case 35: root->kind = 3; break; case 36: root->kind = 4; break; case 37: root->kind = 20; break; case 38: root->kind = 1; break; case 39: root->kind = 2; break; case 40: root->kind = 5; break; case 41: root->kind = 2; break; } root->content += root->tk->lexema; // fill the node content with its token lexema } else { for (unsigned i = root->children.size(); i-- > 0; ) // fill the node content with its children contents root->content += root->children[i]->content; #ifdef DEBUG std::cerr << "Decorating node of children: "; for (unsigned i = root->children.size(); i-- > 0; ) std::cerr << root->children[i]->content << " "; std::cerr << std::endl; #endif root->kind = concat(root->regra, root->children); /*switch (root->children.size()) { // initial break down of simple expressions up to 3 elements and more complex ones case 1: root->kind = root->children[0]->kind; break; case 2: if(root->children[1]->kind==20) // can only be a '+' or a '-', pending for unary or binary operator attribution root->children[1]->kind = 0; // in this case (root->children.size()==2) there is only one operand, so it will be an unary operator root->kind = concat(root->children); if(root->kind==21) // in this case the node corresponds for a whole expression and won't concatenate with others anymore root->content = ""; // it's content is cleared break; case 3: if(root->children[1]->kind==20) // can only be a '+' or a '-', pending for unary or binary operator attribution root->children[1]->kind = 1; // in this case (root->children.size()==3) there is two operands, so it will be a binary operator root->kind = concat(root->children); break; default: root->kind = concat(root->children); break; }*/ } #ifdef DEBUG std::cerr << "\tdecorated with kind: " << root->getKindName() << "\n\n"; #endif }
void concater_rep::typeset (tree t, path ip) { // cout << "Typeset " << t << "\n"; // cout << "Typeset " << t << ", " << ip << ", " << obtain_ip (t) << "\n"; /* if (obtain_ip (t) != ip) cout << "TeXmacs] Wrong ip: " << t << "\n" << " ] " << obtain_ip (t) << " -> " << ip << "\n"; */ if (!is_accessible (ip)) { path ip2= obtain_ip (t); //if (ip2 != ip) cout << t << ", " << ip << " -> " << ip2 << "\n"; if (ip2 != path (DETACHED)) ip= ip2; } if (env->hl_lan != 0) env->lan->highlight (t); if (is_atomic (t)) { if (env->mode == 1) typeset_text_string (t, ip, 0, N(t->label)); else if (env->mode == 2) typeset_math_string (t, ip, 0, N(t->label)); else if (env->mode == 3) typeset_prog_string (t, ip, 0, N(t->label)); else typeset_text_string (t, ip, 0, N(t->label)); return; } switch (L (t)) { case UNINIT: case ERROR: typeset_error (t, ip); break; case RAW_DATA: typeset_inactive (t, ip); break; case DOCUMENT: typeset_document (t, ip); break; case PARA: typeset_paragraph (t, ip); break; case SURROUND: typeset_surround (t, ip); break; case CONCAT: typeset_concat (t, ip); break; case RIGID: typeset_rigid (t, ip); break; case HIDDEN: //(void) env->exec (t); if (N(t) != 1) typeset_error (t, ip); else (void) typeset_as_concat (env, t[0], descend (ip, 0)); break; case FREEZE: if (N(t) != 1) typeset_error (t, ip); else typeset (attach_middle (t[0], ip)); //typeset (freeze (t[0]), decorate_middle (ip)); break; case UNFREEZE: if (N(t) != 1) typeset_error (t, ip); else typeset (t[0], descend (ip, 0)); break; case HSPACE: t= env->exec (t); typeset_hspace (t, ip); break; case VAR_VSPACE: flag (env->drd->get_name (L(t)), ip, brown); t= tree (VAR_VSPACE, env->exec (tree (TMLEN, A(t)))); control (t, ip); break; case VSPACE: flag (env->drd->get_name (L(t)), ip, brown); t= tree (VSPACE, env->exec (tree (TMLEN, A(t)))); control (t, ip); break; case SPACE: t= env->exec (t); typeset_space (attach_here (t, ip)); break; case HTAB: if (N(t) != 1 && N(t) != 2) { typeset_error (t, ip); break; } if (N(a)==0) print (empty_box (ip, 0, 0, 0, env->fn->yx)); print (space (env->as_length (t[0]))); control (t, ip); break; case MOVE: typeset_move (t, ip); break; case SHIFT: typeset_shift (t, ip); break; case RESIZE: typeset_resize (t, ip); break; case CLIPPED: typeset_clipped (t, ip); break; case REPEAT: typeset_repeat (t, ip); break; case _FLOAT: typeset_float (t, ip); break; case DATOMS: typeset_formatting (t, ip, ATOM_DECORATIONS); break; case DLINES: typeset_formatting (t, ip, LINE_DECORATIONS); break; case DPAGES: typeset_formatting (t, ip, PAGE_DECORATIONS); break; case DBOX: typeset_decorated_box (t, ip); break; case LINE_NOTE: typeset_line_note (t, ip); break; case PAGE_NOTE: typeset_page_note (t, ip); break; case WITH_LIMITS: with_limits (LIMITS_DISPLAY); flag ("with-limits", ip, brown); control (t, ip); break; case LINE_BREAK: if (N(a)>0) a[N(a)-1]->penalty = 0; flag ("line-break", ip, brown); control (t, ip); break; case NEW_LINE: case NEXT_LINE: { string name= env->drd->get_name (L(t)); flag (name, ip, brown); control (t, ip); break; } case NO_BREAK: if (N(a)>0) a[N(a)-1]->penalty = HYPH_INVALID; if ((N(a)>1) && (a[N(a)-1]->type == STRING_ITEM) && (a[N(a)-1]->b->get_leaf_string () == "")) a[N(a)-2]->penalty = HYPH_INVALID; flag ("no line break", ip, brown); control (t, ip); break; case YES_INDENT: flag ("yes-first-indent", ip, brown); control (tuple ("env_par", PAR_FIRST, env->read (PAR_FIRST)), ip); break; case NO_INDENT: flag ("no-first-indent", ip, brown); control (tuple ("env_par", PAR_FIRST, "0cm"), ip); break; case VAR_YES_INDENT: flag ("yes-first-indent-after", ip, brown); control (tuple ("env_par", PAR_NO_FIRST, "false"), ip); break; case VAR_NO_INDENT: flag ("no-first-indent-after", ip, brown); control (tuple ("env_par", PAR_NO_FIRST, "true"), ip); break; case VAR_PAGE_BREAK: case PAGE_BREAK: case VAR_NO_PAGE_BREAK: case NO_PAGE_BREAK: case VAR_NO_BREAK_HERE: case NO_BREAK_HERE: case NO_BREAK_START: case NO_BREAK_END: case VAR_NEW_PAGE: case NEW_PAGE: case VAR_NEW_DPAGE: case NEW_DPAGE: { string name= env->drd->get_name (L(t)); flag (name, ip, brown); control (t, ip); break; } case AROUND: case VAR_AROUND: case BIG_AROUND: typeset_around (t, ip, env->get_string (MATH_NESTING_MODE) != "off"); break; case LEFT: typeset_large (t, ip, LEFT_BRACKET_ITEM, OP_OPENING_BRACKET, "<left-"); break; case MID: typeset_large (t, ip, MIDDLE_BRACKET_ITEM, OP_MIDDLE_BRACKET, "<mid-"); break; case RIGHT: typeset_large (t, ip, RIGHT_BRACKET_ITEM, OP_CLOSING_BRACKET, "<right-"); break; case BIG: typeset_bigop (t, ip); break; case LONG_ARROW: typeset_long_arrow (t, ip); break; case LPRIME: typeset_lprime (t, ip); break; case RPRIME: typeset_rprime (t, ip); break; case BELOW: typeset_below (t, ip); break; case ABOVE: typeset_above (t, ip); break; case LSUB: case LSUP: typeset_script (t, ip, false); break; case RSUB: case RSUP: typeset_script (t, ip, true); break; case FRAC: typeset_frac (t, ip); break; case SQRT: typeset_sqrt (t, ip); break; case WIDE: typeset_wide (t, ip, true); break; case VAR_WIDE: typeset_wide (t, ip, false); break; case NEG: typeset_neg (t, ip); break; case TREE: typeset_tree (t, ip); break; case SYNTAX: typeset_syntax (t, ip); break; case TFORMAT: if ((N(t)>0) && is_table (t[N(t)-1])) typeset_table (t, ip); else typeset_formatting (t, ip, CELL_FORMAT); break; case TWITH: case CWITH: case TMARKER: typeset_inactive (t, ip); break; case TABLE: typeset_table (t, ip); break; case ROW: case CELL: case SUBTABLE: break; case ASSIGN: typeset_assign (t, ip); break; case WITH: typeset_with (t, ip); break; case PROVIDES: typeset_executable (t, ip); break; case QUOTE_VALUE: typeset_inactive (t, ip); break; case VALUE: typeset_value (t, ip); break; case MACRO: typeset_inactive (t, ip); break; case DRD_PROPS: typeset_drd_props (t, ip); break; case ARG: typeset_argument (t, ip); break; case QUOTE_ARG: typeset_inactive (t, ip); break; case COMPOUND: typeset_compound (t, ip); break; case XMACRO: typeset_inactive (t, ip); break; case GET_LABEL: typeset_executable (t, ip); break; case GET_ARITY: typeset_executable (t, ip); break; case MAP_ARGS: typeset_rewrite (t, ip); break; case EVAL_ARGS: typeset_eval_args (t, ip); break; case MARK: typeset_mark (t, ip); break; case EXPAND_AS: typeset_expand_as (t, ip); break; case EVAL: typeset_eval (t, ip); break; case QUOTE: typeset_inactive (t, ip); break; case QUASI: typeset_eval (tree (EVAL, tree (QUASIQUOTE, t[0])), ip); break; case QUASIQUOTE: case UNQUOTE: case VAR_UNQUOTE: case COPY: typeset_executable (t, ip); break; case IF: typeset_if (t, ip); break; case VAR_IF: typeset_var_if (t, ip); break; case CASE: typeset_case (t, ip); break; case WHILE: case FOR_EACH: typeset_executable (t, ip); break; case EXTERN: typeset_rewrite (t, ip); break; case VAR_INCLUDE: typeset_include (t, ip); break; case INCLUDE: typeset_compound (t, ip); break; case USE_PACKAGE: case USE_MODULE: typeset_executable (t, ip); break; case OR: case XOR: case AND: case NOT: case PLUS: case MINUS: case TIMES: case OVER: case DIV: case MOD: case MINIMUM: case MAXIMUM: case MATH_SQRT: case EXP: case LOG: case POW: case COS: case SIN: case TAN: case MERGE: case LENGTH: typeset_executable (t, ip); break; case RANGE: typeset_range (t, ip); break; case NUMBER: case _DATE: case TRANSLATE: case CHANGE_CASE: case FIND_FILE: case FIND_FILE_UPWARDS: case IS_TUPLE: case LOOK_UP: case EQUAL: case UNEQUAL: case LESS: case LESSEQ: case GREATER: case GREATEREQ: case BLEND: case BOX_INFO: case FRAME_DIRECT: case FRAME_INVERSE: typeset_executable (t, ip); break; case CM_LENGTH: case MM_LENGTH: case IN_LENGTH: case PT_LENGTH: case BP_LENGTH: case DD_LENGTH: case PC_LENGTH: case CC_LENGTH: case FS_LENGTH: case FBS_LENGTH: case EM_LENGTH: case LN_LENGTH: case SEP_LENGTH: case YFRAC_LENGTH: case EX_LENGTH: case FN_LENGTH: case FNS_LENGTH: case BLS_LENGTH: case SPC_LENGTH: case XSPC_LENGTH: case PAR_LENGTH: case PAG_LENGTH: case GW_LENGTH: case GH_LENGTH: case GU_LENGTH: case TMPT_LENGTH: case PX_LENGTH: typeset_executable (t, ip); break; case STYLE_ONLY: case VAR_STYLE_ONLY: case ACTIVE: case VAR_ACTIVE: case INACTIVE: case VAR_INACTIVE: typeset_compound (t, ip); break; case REWRITE_INACTIVE: typeset_rewrite (t, ip); break; case INLINE_TAG: case OPEN_TAG: case MIDDLE_TAG: case CLOSE_TAG: typeset_src_tag (t, ip); break; case SYMBOL: case LATEX: case HYBRID: typeset_inactive (t, ip); break; case LOCUS: typeset_locus (t, ip); break; case ID: typeset_inactive (t, ip); break; case HARD_ID: typeset_executable (t, ip); break; case LINK: case URL: case SCRIPT: case OBSERVER: case FIND_ACCESSIBLE: typeset_inactive (t, ip); break; case HLINK: case ACTION: typeset_compound (t, ip); break; case SET_BINDING: typeset_set_binding (t, ip); break; case GET_BINDING: typeset_executable (t, ip); break; case LABEL: case REFERENCE: case PAGEREF: typeset_compound (t, ip); break; case GET_ATTACHMENT: typeset_executable (t, ip); break; case WRITE: typeset_write (t, ip); break; case TOC_NOTIFY: typeset_toc_notify (t, ip); break; case TUPLE: case ATTR: case TMLEN: case COLLECTION: case ASSOCIATE: case BACKUP: typeset_inactive (t, ip); break; case PATTERN: case GRADIENT: marker (descend (ip, 0)); typeset_inactive (env->exec (t), decorate (ip)); marker (descend (ip, 1)); break; case SPECIFIC: typeset_specific (t, ip); break; case FLAG: typeset_flag (t, ip); break; case HYPHENATE_AS: typeset_hyphenate_as (t, ip); break; case ANIM_STATIC: case ANIM_DYNAMIC: case MORPH: case ANIM_TIME: case ANIM_PORTION: typeset_executable (t, ip); break; case ANIM_COMPOSE: typeset_anim_compose (t, ip); break; case ANIM_REPEAT: typeset_anim_repeat (t, ip); break; case ANIM_CONSTANT: typeset_anim_constant (t, ip); break; case ANIM_ACCELERATE: typeset_anim_accelerate (t, ip); break; case ANIM_TRANSLATE: typeset_anim_translate (t, ip); break; case ANIM_PROGRESSIVE: typeset_anim_progressive (t, ip); break; case VIDEO: typeset_video (t, ip); break; case SOUND: typeset_sound (t, ip); break; case GRAPHICS: typeset_graphics (t, ip); break; case SUPERPOSE: typeset_superpose (t, ip); break; case GR_GROUP: typeset_gr_group (t, ip); break; case GR_TRANSFORM: typeset_gr_transform (t, ip); break; case GR_EFFECT: typeset_gr_effect (t, ip); break; case TEXT_AT: typeset_text_at (t, ip); break; case MATH_AT: typeset_math_at (t, ip); break; case DOCUMENT_AT: typeset_document_at (t, ip); break; case _POINT: typeset_point (t, ip); break; case LINE: typeset_line (t, ip, false); break; case CLINE: typeset_line (t, ip, true); break; case ARC: typeset_arc (t, ip, false); break; case CARC: typeset_arc (t, ip, true); break; case SPLINE: typeset_spline (t, ip, false); break; case VAR_SPLINE: typeset_var_spline (t, ip); break; case CSPLINE: typeset_cspline (t, ip); break; case BEZIER: case CBEZIER: case SMOOTH: case CSMOOTH: typeset_bezier (t, ip); break; case FILL: typeset_fill (t, ip); break; case IMAGE: typeset_image (t, ip); break; case TRANSFORM_3D: case OBJECT_3D: case TRIANGLE_3D: case LIGHT_3D: typeset_graphics_3d (t, ip); break; case LIGHT_DIFFUSE: case LIGHT_SPECULAR: typeset_inactive (t, ip); break; case EFF_MOVE: case EFF_MAGNIFY: case EFF_BUBBLE: case EFF_TURBULENCE: case EFF_FRACTAL_NOISE: case EFF_GAUSSIAN: case EFF_OVAL: case EFF_RECTANGULAR: case EFF_MOTION: case EFF_BLUR: case EFF_OUTLINE: case EFF_THICKEN: case EFF_ERODE: case EFF_DEGRADE: case EFF_DISTORT: case EFF_GNAW: case EFF_SUPERPOSE: case EFF_ADD: case EFF_SUB: case EFF_MUL: case EFF_MIN: case EFF_MAX: case EFF_MIX: case EFF_NORMALIZE: case EFF_MONOCHROME: case EFF_COLOR_MATRIX: case EFF_MAKE_TRANSPARENT: case EFF_MAKE_OPAQUE: typeset_inactive (t, ip); break; case CANVAS: typeset_canvas (t, ip); break; case ORNAMENT: typeset_ornament (t, ip); break; default: if (L(t) < START_EXTENSIONS) print (test_box (ip)); else typeset_compound (t, ip); break; } }
box pager_rep::pages_format (pagelet pg) { // cout << "Formatting pagelet " << (N(pages)+1) // << " stretch " << pg->stretch // << " height " << stretch_space (pg->ht, pg->stretch) << LF << INDENT; if (N (pg->ins) == 0) { if (N(pages) == 0) return dummy_box (decorate_middle (ip)); return dummy_box (decorate_middle (pages [N(pages)-1] -> find_rip ())); } else if (N (pg->ins) == 1) { insertion ins= pg->ins[0]; // cout << ins << " stretch " << ins->stretch // << " height " << stretch_space (ins->ht, ins->stretch) << LF; // << UNINDENT << "Formatted pagelet " << (N(pages)+1) << LF << LF; return pages_format (ins); } else { int i, n= N(pg->ins); array<box> bs (n); array<SI> bx (n); array<SI> by (n); SI y= 0, fnote_y= MAX_SI; for (i=0; i<n; i++) { insertion ins= pg->ins[i]; // cout << ins << " at " << y << " stretch " << ins->stretch // << " height " << stretch_space (ins->ht, ins->stretch) << LF; bs[i]= pages_format (ins); bx[i]= 0; by[i]= y; y -= bs[i]->h(); if (i < n-1) { insertion next= pg->ins[i+1]; if (ins->type != next->type) { if (is_tuple (next->type, "footnote")) { // cout << "sep " << stretch_space (fnote_sep, ins->stretch) << LF; y -= stretch_space (fnote_sep, ins->stretch); fnote_y= y; } else if (is_tuple (ins->type, "float")) { if (!is_tuple (next->type, "float")) { // cout << "sep " << stretch_space(float_sep, ins->stretch) << LF; y -= stretch_space (float_sep, ins->stretch); } } else if (is_tuple (ins->type, "multi-column") || is_tuple (next->type, "multi-column")) { page_item item= access (l, path_dec (ins->end)); // cout << "sep " << stretch_space (item->spc, ins->stretch) << LF; y -= stretch_space (item->spc, ins->stretch); } } if (is_tuple (ins->type, "footnote")) if (is_tuple (next->type, "footnote")) { page_item item= access (l, path_dec (ins->end)); SI sep= stretch_space (item->spc + fn_sep, ins->stretch); // cout << "sep " << sep << LF; y -= sep; } if (is_tuple (next->type, "float")) { // cout << "sep " << stretch_space (float_sep, ins->stretch) << LF; y -= stretch_space (float_sep, ins->stretch); } } } if (fnote_y != MAX_SI) { pencil pen= env->pen->set_width (env->fn->wline); bs << line_box (decorate(), 0, 0, fnote_bl, 0, pen); bx << 0; by << (fnote_y + env->fn->sep); } // cout << UNINDENT << "Formatted pagelet " << (N(pages)+1) << LF << LF; return scatter_box (ip, bs, bx, by); } }
void simplePlot2D(){ ///gROOT->ProcessLine(".x paperStyle.C"); gStyle->SetCanvasDefH(600); //Height of canvas gStyle->SetCanvasDefW(640); //Width of canvas gStyle->SetCanvasDefX(0); //POsition on screen gStyle->SetCanvasDefY(0); gStyle->SetPadLeftMargin(0.125);//0.16); gStyle->SetPadRightMargin(0.165);//0.02); gStyle->SetPadTopMargin(0.085);//0.02); gStyle->SetPadBottomMargin(0.12);//0.02); // For g axis titles: gStyle->SetTitleColor(1, "XYZ"); gStyle->SetTitleFont(42, "XYZ"); gStyle->SetTitleSize(0.045, "Z"); gStyle->SetTitleSize(0.055, "XY"); gStyle->SetTitleXOffset(1.0);//0.9); gStyle->SetTitleYOffset(1.12); // => 1.15 if exponents // For g axis labels: gStyle->SetLabelColor(1, "XYZ"); gStyle->SetLabelFont(42, "XYZ"); gStyle->SetLabelOffset(0.007, "XYZ"); gStyle->SetLabelSize(0.04, "XYZ"); // Legends gStyle->SetLegendBorderSize(0); gStyle->SetLegendFillColor(kWhite); gStyle->SetLegendFont(42); gStyle->SetOptStat(0); //gStyle->SetPalette(51); /* // Fewer colors, one band per 0.1 // ************************************************************* int ncontours = 10; double stops[6] = {0.0 , .2, .4, .6, .8, 1}; double blue[6] = {1.0 , 1, 1, 1, 1, 1}; double green[6] = {0.1, 0.3, 0.5, 0.72, 0.82, 1}; double red [6] = {0.1, 0.2, 0.24, 0.45, 0.7, 1}; int npoints = 6; TColor::CreateGradientColorTable(npoints, stops, red, green, blue, ncontours); gStyle->SetNumberContours(ncontours); //gStyle->SetPalette(kCherry); // ************************************************************* */ // ************************************************************* int ncontours = 15; double stops[5] = {0.0 , .1, .25 , .5 , 1 }; double blue[5] = {1.0 , 1. , 1 , 1 , 1.00 }; double green[5] = {0.25 , 0.3 , 0.5 , 0.75 , 1.00 }; double red [5] = {0.1, 0.15 , 0.4 , 0.6 , 1.00 }; int npoints = 5; TColor::CreateGradientColorTable(npoints, stops, red, green, blue, ncontours); gStyle->SetNumberContours(ncontours); // ************************************************************* TFile *fi = TFile::Open("allpoints.root"); TTree *tree = (TTree*)fi->Get("limit"); TH2D expected(grKappa(tree,-1)); TH2D dummyK("dummyK","dummy",1,KVMIN,KVMAX,1,KFMIN,KFMAX); dummyK.SetTitle(""); dummyK.GetZaxis()->SetTitleOffset(1.2); dummyK.GetYaxis()->SetTitle("#it{#kappa}_{F}"); dummyK.GetXaxis()->SetTitle("#it{#kappa}_{V}"); //dummyK.GetXaxis()->SetRangeUser(KVMIN,KVMAX); //dummyK.GetYaxis()->SetRangeUser(KFMIN,KFMAX); dummyK.GetZaxis()->SetTitle("B(H #rightarrow inv.) - 95% CL upper limit"); //dummyK.GetXaxis()->SetLimits(KVMIN,KVMAX); //dummyK.GetYaxis()->SetLimits(KFMIN,KFMAX); //dummyK.SetMaximum(0.8); //dummyK.SetMinimum(0.1); TCanvas *can = new TCanvas("cc","c",800,720); can->cd(); //expected.GetXaxis()->SetRangeUser(KVMIN,KVMAX); //expected.GetYaxis()->SetRangeUser(KFMIN,KFMAX); TFile *flhc = TFile::Open("scan2d_kappa_V_kappa_F_exp.root"); TGraph *grlhc_68 = (TGraph*) flhc->Get("graph68_comb_0"); TGraph *grlhc_95 = (TGraph*) flhc->Get("graph95_comb_0"); TGraph *grlhc_bf = (TGraph*) flhc->Get("comb_best"); grlhc_68->SetLineColor(kWhite); grlhc_95->SetLineColor(kWhite); grlhc_bf->SetMarkerStyle(34); grlhc_bf->SetMarkerSize(1.8); grlhc_bf->SetMarkerColor(kWhite); grlhc_68->SetLineWidth(2); grlhc_95->SetLineWidth(2); grlhc_95->SetLineStyle(2); TH2D *histocomb = (TH2D*)flhc->Get("comb_hist_processed"); double xmin =expected.GetXaxis()->GetXmin(); double xmax =expected.GetXaxis()->GetXmax(); double ymin =expected.GetYaxis()->GetXmin(); double ymax =expected.GetYaxis()->GetXmax(); TLine SMH(KVMIN,1,KVMAX,1); TLine SMV(1,KFMIN,1,KFMAX); // TLine SMH(xmin,1,xmax,1); // TLine SMV(1,ymin,1,ymax); SMH.SetLineColor(2); SMH.SetLineStyle(2); SMV.SetLineColor(2); SMV.SetLineStyle(2); //dummyK.Draw("AXIS"); expected.Draw("colz"); grlhc_68->Draw("Lsame"); grlhc_95->Draw("Lsame"); grlhc_bf->Draw("Psame"); SMH.Draw("L"); SMV.Draw("L"); decorate(can,expected); printRanges(&expected,histocomb); can->SaveAs("couplings_limits.pdf"); TFile *fiMU = TFile::Open("allpoints_mu.root"); TTree *treeMU = (TTree*)fiMU->Get("limit"); TH2D expectedmu(grMu(treeMU,-1)); TH2D dummyMu("dummyMu","dummy",1,MUVMIN,MUVMAX,1,MUFMIN,MUFMAX); dummyMu.SetTitle(""); dummyMu.GetZaxis()->SetTitleOffset(1.2); dummyMu.GetYaxis()->SetTitle("#it{#mu}_{ggH}"); dummyMu.GetXaxis()->SetTitle("#it{#mu}_{qqH,VH}"); dummyMu.GetZaxis()->SetTitle("B(H #rightarrow inv.) - 95% CL upper limit"); //dummyMu.GetXaxis()->SetRangeUser(MUVMIN,MUVMAX); //dummyMu.GetYaxis()->SetRangeUser(MUFMIN,MUFMAX); //dummyMu.GetXaxis()->SetLimits(MUVMIN,MUVMAX); //dummyMu.GetYaxis()->SetLimits(MUFMIN,MUFMAX); //dummyMu.SetMaximum(0.8); //dummyMu.SetMinimum(0.1); //expectedmu.GetXaxis()->SetRangeUser(KVMIN,KVMAX); //expectedmu.GetYaxis()->SetRangeUser(KFMIN,KFMAX); xmin =expectedmu.GetXaxis()->GetXmin(); xmax =expectedmu.GetXaxis()->GetXmax(); ymin =expectedmu.GetYaxis()->GetXmin(); ymax =expectedmu.GetYaxis()->GetXmax(); TLine SM2H(MUVMIN,1,MUVMAX,1); TLine SM2V(1,MUFMIN,1,MUFMAX); //TLine SM2H(xmin,1,xmax,1); //TLine SM2V(1,ymin,1,ymax); SM2H.SetLineColor(2); SM2H.SetLineStyle(2); SM2V.SetLineColor(2); SM2V.SetLineStyle(2); //dummyMu.Draw("axis"); expectedmu.Draw("colz"); TH2D *expectedmuCont = (TH2D*)expectedmu.Clone(); //expectedmuCont->SetName("contours"); //expectedmuCont->SetContour(15); //expectedmuCont->Draw("cont2 same"); SM2H.Draw("L"); SM2V.Draw("L"); decorate(can,expectedmu,false); can->SaveAs("mu_limits.pdf"); }
void camp() { int dish; int meat; char food[100]; strcpy(food, "YOU SPEND AN HOUR EATING\n"); meat = rand() % 7; dish = rand() % 8; switch (dish) { case 0: strcat(food, "DEEP FRIED "); break; default: switch (rand() % 15) { case 0: strcat(food, "SALTY "); break; case 1: strcat(food, "SPICY "); break; case 2: strcat(food, "PEPPERED "); break; } break; } switch (meat) { case 0: strcat(food, "GNOBLIN"); break; case 1: strcat(food, "SPIDER"); break; case 2: strcat(food, "BLURK"); break; case 3: strcat(food, "SNAKE"); break; case 4: strcat(food, "MIMIC"); break; case 5: strcat(food, "IMP"); break; case 6: strcat(food, "GHOUL"); break; } switch (dish) { case 0: break; case 1: strcat(food, "-ON-A-STICK"); break; case 2: strcat(food, " RAGU"); break; case 3: strcat(food, " ROAST"); break; case 4: strcat(food, " STEW"); break; case 5: strcat(food, " SOUP"); break; case 6: strcat(food, " GUMBO"); break; case 7: strcat(food, " NUGGETS"); break; } switch (rand() % 20) { case 0: strcat(food, " WITH BEANS"); break; case 1: strcat(food, " WITH BROCCOLI"); break; case 2: strcat(food, " WITH CHEESE"); break; case 3: strcat(food, " WITH PICKLES"); break; case 4: strcat(food, " WITH ONION RINGS"); break; default: break; } strcat(food, "\n\n"); switch (rand() % 4) { case 0: strcat(food, "IT WAS DELICIOUS!"); break; case 1: strcat(food, "YOU'VE HAD BETTER"); break; case 2: strcat(food, "YOU FEEL SLIGHTLY NAUSEOUS"); break; case 3: strcat(food, "THAT HIT THE SPOT!"); break; } pwait(food); decorate(player->y, player->x, DEC_SPENTCAMP); draw_board(); refill_hp(CAMP_HEAL); return; }
void borders(void) { int i,j,k,ks1,ks2,ks3; int k2min[6],k2max[6],k3min[6],k3max[6]; real r11,r12,r13,r14,r21,r22,r23,r24,r31,r32,r33,r34,x,y,z; real rmin1,rmax1,rmin2,rmax2,rmin3,rmax3,rmin,rmax; /* through all grid directions */ for (i=0;i<4;i++) for (j=i+1;j<5;j++) for (k=j+1;k<6;k++) { /* first grid */ for (ks1=k1min[i];ks1<k1max[i]+1;ks1++) { kf[i]=ks1; if (gx[i] != 0) { r11=r2(gx[i],gx[j],gy[i],gy[j],lmin.y,gz[i],gz[j],lmin.z, ks1,gam[i],gam[j]); r12=r2(gx[i],gx[j],gy[i],gy[j],lmin.y,gz[i],gz[j],lmax.z, ks1,gam[i],gam[j]); r13=r2(gx[i],gx[j],gy[i],gy[j],lmax.y,gz[i],gz[j],lmin.z, ks1,gam[i],gam[j]); r14=r2(gx[i],gx[j],gy[i],gy[j],lmax.y,gz[i],gz[j],lmax.z, ks1,gam[i],gam[j]); rmin1=MIN(MIN(r11,r12),MIN(r13,r14)); rmax1=MAX(MAX(r11,r12),MAX(r13,r14)); } else { rmin1=k1min[j]; rmax1=k1max[j]; } if (gy[i] != 0) { r21=r2(gy[i],gy[j],gz[i],gz[j],lmin.z,gx[i],gx[j],lmin.x, ks1,gam[i],gam[j]); r22=r2(gy[i],gy[j],gz[i],gz[j],lmin.z,gx[i],gx[j],lmax.x, ks1,gam[i],gam[j]); r23=r2(gy[i],gy[j],gz[i],gz[j],lmax.z,gx[i],gx[j],lmin.x, ks1,gam[i],gam[j]); r24=r2(gy[i],gy[j],gz[i],gz[j],lmax.z,gx[i],gx[j],lmax.x, ks1,gam[i],gam[j]); rmin2=MIN(MIN(r21,r22),MIN(r23,r24)); rmax2=MAX(MAX(r21,r22),MAX(r23,r24)); } else { rmin2=k1min[j]; rmax2=k1max[j]; } if (gz[i] != 0) { r31=r2(gz[i],gz[j],gx[i],gx[j],lmin.x,gy[i],gy[j],lmin.y, ks1,gam[i],gam[j]); r32=r2(gz[i],gz[j],gx[i],gx[j],lmin.x,gy[i],gy[j],lmax.y, ks1,gam[i],gam[j]); r33=r2(gz[i],gz[j],gx[i],gx[j],lmax.x,gy[i],gy[j],lmin.y, ks1,gam[i],gam[j]); r34=r2(gz[i],gz[j],gx[i],gx[j],lmax.x,gy[i],gy[j],lmax.y, ks1,gam[i],gam[j]); rmin3=MIN(MIN(r31,r32),MIN(r33,r34)); rmax3=MAX(MAX(r31,r32),MAX(r33,r34)); } else { rmin3=k1min[j]; rmax3=k1max[j]; } rmin=MAX(MAX(rmin1,rmin2),rmin3); rmax=MIN(MIN(rmax1,rmax2),rmax3); k2min[j]=floor(rmin+0.5); k2max[j]=floor(rmax+0.5); /* second grid */ for (ks2=k2min[j];ks2<k2max[j]+1;ks2++) { kf[j]=ks2; if (gx[i]*gz[j]-gx[j]*gz[i] != 0) { r11=r3(gx[i],gx[j],gx[k],gy[i],gy[j],gy[k],lmin.y, gz[i],gz[j],gz[k],ks1,ks2,gam[i],gam[j], gam[k]); r12=r3(gx[i],gx[j],gx[k],gy[i],gy[j],gy[k],lmax.y, gz[i],gz[j],gz[k],ks1,ks2,gam[i],gam[j], gam[k]); rmin1=MIN(r11,r12); rmax1=MAX(r11,r12); } else { rmin1=k1min[k]; rmax1=k1max[k]; } if (gx[i]*gy[j]-gx[j]*gy[i] != 0) { r21=r3(gy[i],gy[j],gy[k],gz[i],gz[j],gz[k],lmin.z, gx[i],gx[j],gx[k],ks1,ks2,gam[i],gam[j], gam[k]); r22=r3(gy[i],gy[j],gy[k],gz[i],gz[j],gz[k],lmax.z, gx[i],gx[j],gx[k],ks1,ks2,gam[i],gam[j], gam[k]); rmin2=MIN(r21,r22); rmax2=MAX(r21,r22); } else { rmin2=k1min[k]; rmax2=k1max[k]; } if (gy[i]*gz[j]-gy[j]*gz[i] != 0) { r31=r3(gz[i],gz[j],gz[k],gx[i],gx[j],gx[k],lmin.x, gy[i],gy[j],gy[k],ks1,ks2,gam[i],gam[j], gam[k]); r32=r3(gz[i],gz[j],gz[k],gx[i],gx[j],gx[k],lmax.x, gy[i],gy[j],gy[k],ks1,ks2,gam[i],gam[j], gam[k]); rmin3=MIN(r31,r32); rmax3=MAX(r31,r32); } else { rmin3=k1min[k]; rmax3=k1max[k]; } rmin=MAX(MAX(rmin1,rmin2),rmin3); rmax=MIN(MIN(rmax1,rmax2),rmax3); k3min[k]=floor(rmin+0.5); k3max[k]=floor(rmax+0.5); /* third grid */ for (ks3=k3min[k];ks3<k3max[k]+1;ks3++) { kf[k]=ks3; /* compute the intersection point */ z=det(gx[i],gx[j],gx[k],gy[i],gy[j],gy[k], ks1+gam[i],ks2+gam[j],ks3+gam[k])/ det(gx[i],gx[j],gx[k],gy[i],gy[j],gy[k], gz[i],gz[j],gz[k]); y=det(gx[i],gx[j],gx[k],ks1+gam[i],ks2+gam[j], ks3+gam[k],gz[i],gz[j],gz[k])/ det(gx[i],gx[j],gx[k],gy[i],gy[j],gy[k], gz[i],gz[j],gz[k]); x=det(ks1+gam[i],ks2+gam[j],ks3+gam[k], gy[i],gy[j],gy[k],gz[i],gz[j],gz[k])/ det(gx[i],gx[j],gx[k],gy[i],gy[j],gy[k], gz[i],gz[j],gz[k]); /* compute the six-dimensional coordinates */ locate(x,y,z,i,j,k); /* generate the quasilattice */ decorate(i,j,k); } } } } }