void DPI::ScaleRect(CRect &r) // // // { r.left = SX(r.left); r.right = SX(r.right); r.top = SY(r.top); r.bottom = SY(r.bottom); }
void do_alignment(FILE *file, int p0_beg, int p1_beg) { char line[MAX_STR], *bp; int score, s0_beg, s0_end, s1_beg, s1_end, percent; int have_line = 0; double bits; while (fgets(line, sizeof(line), file)!=NULL) { if ( strchr(line,'}') != NULL) { clsline(); return; } if ((bp=strchr(line,'s')) != NULL) sscanf(bp+1, "%d %lf", &score, &bits); else if ((bp=strchr(line,'b')) != NULL) sscanf(bp+1, "%d %d", &s0_beg, &s1_beg); else if ((bp=strchr(line, 'e')) != NULL) sscanf(bp+1, "%d %d", &s0_end, &s1_end); else if ((bp=strchr(line, 'l')) != NULL) { sscanf(bp+1, "%d %d %d %d %d", &s0_beg, &s1_beg, &s0_end, &s1_end, &percent); if (have_line) { draw(SX(s0_beg-p0_beg+1), SY(s1_beg-p1_beg+1)); draw(SX(s0_end-p0_beg+1), SY(s1_end-p1_beg+1)); } else { opnline(score, bits); move(SX(s0_beg - p0_beg + 1), SY(s1_beg - p1_beg + 1)); draw(SX(s0_end - p0_beg + 1), SY(s1_end - p1_beg + 1)); have_line = 1; } } } }
int encode_string(char *dst, size_t dst_len, argon2_context *ctx) { #define SS(str) \ do { \ size_t pp_len = strlen(str); \ if (pp_len >= dst_len) { \ return 0; \ } \ memcpy(dst, str, pp_len + 1); \ dst += pp_len; \ dst_len -= pp_len; \ } while (0) #define SX(x) \ do { \ char tmp[30]; \ sprintf(tmp, "%lu", (unsigned long)(x)); \ SS(tmp); \ } while (0); #define SB(buf, len) \ do { \ size_t sb_len = to_base64(dst, dst_len, buf, len); \ if (sb_len == (size_t)-1) { \ return 0; \ } \ dst += sb_len; \ dst_len -= sb_len; \ } while (0); SS("$argon2i$m="); SX(ctx->m_cost); SS(",t="); SX(ctx->t_cost); SS(",p="); SX(ctx->lanes); if (ctx->adlen > 0) { SS(",data="); SB(ctx->ad, ctx->adlen); } if (ctx->saltlen == 0) return 1; SS("$"); SB(ctx->salt, ctx->saltlen); if (ctx->outlen == 0) return 1; SS("$"); SB(ctx->out, ctx->outlen); return 1; #undef SS #undef SX #undef SB }
static void dw_gt_round(vd_trace_interface *I, double x, double y, int r) { HPEN h; get_window(); if (host.tw == NULL) return; h = (HPEN)SelectObject(I->host->hdc, GetStockObject(NULL_PEN)); Ellipse(I->host->hdc, SX(x)-r, SY(y)-r, SX(x)+r, SY(y)+r); SelectObject(I->host->hdc, h); }
Variable::Variable(const string& name, bool create_expression){ assignNode(new VariableInternal(name)); if(create_expression){ setExpression(SX(name)); setDerivative(SX("der_" + name)); setBinding(var(),false); setBinding(der(),true); } }
void vd_impl_bar(double x0, double y0, double x1, double y1, int w, unsigned long c) { NullRET; vd_trace1->setcolor(vd_trace1, c); vd_trace1->setlinewidth(vd_trace1, w); vd_trace1->beg_path(vd_trace1); vd_trace1->moveto(vd_trace1, SX(x0), SY(y0)); vd_trace1->lineto(vd_trace1, SX(x1), SY(y1)); vd_trace1->end_path(vd_trace1); vd_trace1->stroke(vd_trace1); }
static void dw_gt_curveto(vd_trace_interface *I, double x0, double y0, double x1, double y1, double x2, double y2) { POINT p[3]; get_window(); if (host.tw == NULL) return; p[0].x = SX(x0), p[0].y = SY(y0); p[1].x = SX(x1), p[1].y = SY(y1); p[2].x = SX(x2), p[2].y = SY(y2); PolyBezierTo(I->host->hdc, p, 3); }
static void dw_gt_moveto(vd_trace_interface *I, double x, double y) { POINT p; get_window(); if (host.tw == NULL) return; #ifdef __WIN32__ MoveToEx(I->host->hdc, SX(x), SY(y), &p); #else MoveTo(I->host->hdc, SX(x), SY(y)); #endif I->host->bx = x; I->host->by = y; }
void vd_impl_square(double x, double y, int w, unsigned int c) { NullRET; vd_trace1->setcolor(vd_trace1, c); vd_trace1->setlinewidth(vd_trace1, 1); vd_trace1->beg_path(vd_trace1); vd_trace1->moveto(vd_trace1, SX(x) - w, SY(y) - w); vd_trace1->lineto(vd_trace1, SX(x) + w, SY(y) - w); vd_trace1->lineto(vd_trace1, SX(x) + w, SY(y) + w); vd_trace1->lineto(vd_trace1, SX(x) - w, SY(y) + w); vd_trace1->lineto(vd_trace1, SX(x) - w, SY(y) - w); vd_trace1->end_path(vd_trace1); vd_trace1->stroke(vd_trace1); }
void vd_impl_quad(double x0, double y0, double x1, double y1, double x2, double y2, double x3, double y3, int w, unsigned int c) { NullRET; vd_trace1->setcolor(vd_trace1, c); vd_trace1->setlinewidth(vd_trace1, w); vd_trace1->beg_path(vd_trace1); vd_trace1->moveto(vd_trace1, SX(x0), SY(y0)); vd_trace1->lineto(vd_trace1, SX(x1), SY(y1)); vd_trace1->lineto(vd_trace1, SX(x2), SY(y2)); vd_trace1->lineto(vd_trace1, SX(x3), SY(y3)); vd_trace1->lineto(vd_trace1, SX(x0), SY(y0)); vd_trace1->end_path(vd_trace1); vd_trace1->stroke(vd_trace1); }
void vd_impl_curveto(double x1, double y1, double x2, double y2, double x3, double y3) { double p1x, p1y, p2x, p2y, p3x, p3y; NullRET; p1x = SX(x1), p1y = SY(y1); p2x = SX(x2), p2y = SY(y2); p3x = SX(x3), p3y = SY(y3); if (vd_trace1->curveto != NULL) vd_trace1->curveto(vd_trace1, p1x, p1y, p2x, p2y, p3x, p3y); else vd_flatten(px, py, p1x, p1y, p2x, p2y, p3x, p3y); px = p3x, py = p3y; }
/*----------------------------------------------------------------------------- Name : primRectSolid2 Description : Draw a solid 2d rectangle. Inputs : rect - pointer to rectangle structure containing coordinates. c - color to draw it in, xb - x offset, yb - y offset Outputs : .. Return : void ----------------------------------------------------------------------------*/ void primBeveledRectSolid(rectangle *rect, color c, uword xb, uword yb) { bool cull; if (glcActive()) { glcBeveledRectSolid2(rect, c, (sdword)xb, (sdword)yb); return; } cull = glIsEnabled(GL_CULL_FACE) ? TRUE : FALSE; glDisable(GL_CULL_FACE); glBegin(GL_POLYGON); glColor3ub(colRed(c), colGreen(c), colBlue(c)); glVertex2f(SX(X0+xb), SY(Y0)); glVertex2f(SX(X1-xb), SY(Y0)); glVertex2f(SX(X1), SY(Y0+yb)); glVertex2f(SX(X1), SY(Y1-yb)); glVertex2f(SX(X1-xb), SY(Y1)); glVertex2f(SX(X0+xb), SY(Y1)); glVertex2f(SX(X0), SY(Y1-yb)); glVertex2f(SX(X0), SY(Y0+yb)); glEnd(); if (cull) { glEnable(GL_CULL_FACE); } }
void openplt(long n0, long n1, int sq0off, int sq1off, char *xtitle, char *ytitle) { char *sptr; time_t tt; int tick = 6; tt = time(NULL); if (strlen(lvstr)>0) { sscanf(lvstr,"%lg %lg %lg",&elinval[0],&elinval[1],&elinval[2]); } else if ((sptr=getenv("LINEVAL"))!=NULL && strlen(sptr)>0) { sscanf(sptr,"%lg %lg %lg",&elinval[0],&elinval[1],&elinval[2]); } printf("<?xml version=\"1.0\" standalone=\"no\"?>\n"); printf("<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \n"); printf("\"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n\n"); printf("<svg width=\"564\" height=\"612\" version=\"1.1\"\n"); printf("xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n\n"); pmaxx = n0; pmaxy = n1; fxscal = (double)(max_x-1)/(double)(n1); fyscal = (double)(max_y-1)/(double)(n0); if (fxscal > fyscal) fxscal = fyscal; else fyscal = fxscal; if (fyscal * n0 < (double)max_y/5.0) fyscal = (double)(max_y-1)/((double)(n0)*5.0); fxscal *= 0.9; fxoff = (double)(max_x-1)/11.0; fyscal *= 0.9; fyoff = (double)(max_y-1)/11.0; /* printf("currentlinewidth 1.5 mul setlinewidth\n"); */ printf("<rect x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\"\n", SX(0),SY(n1+1), SX(n0+1)-SX(0), SY(0) - SY(n1+1)); printf("stroke=\"black\" stroke-width=\"2.0\" fill=\"none\" />\n"); xaxis(n0,sq1off, xtitle); yaxis(n1,sq0off, ytitle); legend(); }
static void dw_gt_closepath(vd_trace_interface *I) { get_window(); if (host.tw == NULL) return; LineTo(I->host->hdc, SX(I->host->bx), SY(I->host->by)); CloseFigure(I->host->hdc); }
AnyScalar pow(const AnyScalar&x, int i) { if (x.is_double()) return pow(x.as_double(), i); if (x.is_SX()) return pow(x.as_SX(), SX(i)); if (x.is_MX()) return pow(x.as_MX(), MX(i)); tensor_assert(false); return 0; }
static gmx_bool label_pp(t_x11 *x11, Window w, int npp, t_phipsi pp[], t_dih dih[], int mx, int my) { int d, md, x0, y0; int i, imin; imin = -1; md = 16; for (i = 0; (i < npp); i++) { x0 = SX(dih[pp[i].iphi].ang); y0 = SY(dih[pp[i].ipsi].ang); d = (mx-x0)*(mx-x0)+(my-y0)*(my-y0); if (d < md) { md = d; imin = i; } } if (imin != -1) { pp[imin].bShow = !pp[imin].bShow; return TRUE; } return FALSE; }
void vd_impl_lineto_multi(const struct gs_fixed_point_s *p, int n) { int i; NullRET; for (i = 0; i < n; i++) { px = SX(p[i].x), py = SY(p[i].y); vd_trace1->lineto(vd_trace1, px, py); } }
void vd_impl_curve(double x0, double y0, double x1, double y1, double x2, double y2, double x3, double y3, int w, unsigned long c) { NullRET; vd_trace1->setcolor(vd_trace1, c); vd_trace1->setlinewidth(vd_trace1, w); vd_trace1->beg_path(vd_trace1); vd_trace1->moveto(vd_trace1, SX(x0), SY(y0)); vd_impl_curveto(x1, y1, x2, y2, x3, y3); vd_trace1->end_path(vd_trace1); vd_trace1->stroke(vd_trace1); }
static void plot_pp(t_x11 *x11,Window w,t_phipsi *pp,t_dih dih[]) { int x0,y0; int th=(XTextHeight(x11->font)+6)/2; x0=SX(dih[pp->iphi].ang); y0=SY(dih[pp->ipsi].ang); XFillRectangle(x11->disp,w,x11->gc,x0-1,y0-1,4,4); /* Draw Label ? */ if (pp->bShow) TextInRect(x11,w,pp->label,x0+6,y0-th,30,2*th,eXLeft,eYCenter); }
static gmx_bool xrCallBack(struct t_x11 *x11, XEvent *event, Window w, void *data) { t_app *app; t_xrama *xr; char buf[256]; int i; (void)XTextHeight(x11->font); app = (t_app *)data; xr = app->xr; scx = app->xrwd.width/(2.0*M_PI); scy = app->xrwd.height/(2.0*M_PI); switch (event->type) { case Expose: XClearWindow(x11->disp, app->xrwd.self); XDrawLine(x11->disp, app->xrwd.self, x11->gc, SX(0), SY(-M_PI)+1, SX(0), SY(M_PI)-1); XDrawLine(x11->disp, app->xrwd.self, x11->gc, SX(-M_PI)+1, SY(0), SX(M_PI)-1, SY(0)); TextInRect(x11, app->xrwd.self, "Phi", SX(M_PI)-50, SY(0)+4, 46, 20, eXRight, eYTop); TextInRect(x11, app->xrwd.self, "Psi", SX(0)+4, 4, 46, 20, eXLeft, eYTop); for (i = 0; (i < xr->npp); i++) { if (app->bShowGly || !app->bIsGly[i]) { plot_pp(x11, app->xrwd.self, &(xr->pp[i]), xr->dih); } } break; case ButtonPress: if (label_pp(x11, app->xrwd.self, xr->npp, xr->pp, xr->dih, event->xbutton.x, event->xbutton.y)) { ExposeWin(x11->disp, app->xrwd.self); } break; case ConfigureNotify: app->xrwd.width = event->xconfigure.width; app->xrwd.height = event->xconfigure.height; break; } if (app->status == esGo) { if (!new_data(app->xr)) { app->status = ebStop; } else { ExposeWin(x11->disp, app->xrwd.self); sprintf(buf, "Rama: t=%.2f", app->xr->t); XSetStandardProperties(x11->disp, app->wd.self, buf, "Rama", 0, NULL, 0, NULL); } } return FALSE; }
void NewsScreenInterface::Create ( ComputerScreen *newcs ) { if ( !IsVisible () ) { UplinkAssert ( newcs ); cs = newcs; int numRows = SY(260) / 40; int itemWidth = SX(390); EclRegisterButton ( 20, 34, 104, 15, "Date", "This column shows the date the story was posted", "news_date" ); EclRegisterButton ( 125, 34, itemWidth - 105 + 15, 15, "Subject", "This column shows the subject of the story", "news_subject" ); for ( int i = 0; i < numRows; ++i ) { char name [128]; UplinkSnprintf ( name, sizeof ( name ), "news_story %d", i ); EclRegisterButton ( 20, i * 40 + 50, itemWidth, 39, "", "Read this News story", name ); EclRegisterButtonCallbacks ( name, DrawNewsButton, ClickNewsButton, MousedownNewsButton, HighlightNewsButton ); } create_stextbox ( 20, 50 + numRows * 40, itemWidth + 16, SY(105), "", "news_details" ); EclRegisterButtonCallbacks ( "news_details box", DrawDetails, NULL, NULL, NULL); EclRegisterButton ( 20 + itemWidth + 16 - SX(70), 51 + numRows * 40 + SY(105), SX(70), 15, "Exit News", "Close the News screen and return to the main menu", "news_exit" ); EclRegisterButtonCallback ( "news_exit", ExitClick ); CompanyUplink *cu = (CompanyUplink *) game->GetWorld ()->GetCompany ( "Uplink" ); UplinkAssert ( cu ); ScrollBox::CreateScrollBox( "news_scroll", itemWidth + 21, 50, 15, numRows * 40, cu->news.Size(), numRows, 0, ScrollChange ); baseoffset = 0; currentselect = -1; } }
void CInstrumentEditDlg::InsertPane(CInstrumentEditPanel *pPanel, bool Show) { CRect Rect, ParentRect; CTabCtrl *pTabControl = static_cast<CTabCtrl*>(GetDlgItem(IDC_INST_TAB)); pTabControl->GetWindowRect(&ParentRect); pTabControl->InsertItem(m_iPanels, pPanel->GetTitle()); pPanel->Create(pPanel->GetIDD(), this); pPanel->GetWindowRect(&Rect); Rect.MoveToXY(ParentRect.left - Rect.left + SX(1), ParentRect.top - Rect.top + SY(21)); Rect.bottom -= SY(2); Rect.right += SX(1); pPanel->MoveWindow(Rect); pPanel->ShowWindow(Show ? SW_SHOW : SW_HIDE); if (Show) { pTabControl->SetCurSel(m_iPanels); pPanel->SetFocus(); m_pFocusPanel = pPanel; } m_pPanels[m_iPanels++] = pPanel; }
/*----------------------------------------------------------------------------- Name : primBeveledRectOutline Description : Draw an outline 2d beveled rectangle. Inputs : rect - pointer to rectangle structure containing coordinates. thickness - thickness of the lines c - color to draw it in, xb - x offset, yb - y offset Outputs : .. Return : void ----------------------------------------------------------------------------*/ void primBeveledRectOutline(rectangle *rect, sdword thickness, color c, uword xb, uword yb) { glColor3ub(colRed(c), colGreen(c), colBlue(c)); glPushAttrib(GL_LINE_BIT); glLineWidth((GLfloat)thickness); glBegin(GL_LINE_LOOP); glVertex2f(SX(X0+xb), SY(Y0)); glVertex2f(SX(X1-xb), SY(Y0)); glVertex2f(SX(X1), SY(Y0+yb)); glVertex2f(SX(X1), SY(Y1-yb)); glVertex2f(SX(X1-xb), SY(Y1)); glVertex2f(SX(X0+xb), SY(Y1)); glVertex2f(SX(X0), SY(Y1-yb)); glVertex2f(SX(X0), SY(Y0+yb)); glEnd(); glPopAttrib(); }
/*----------------------------------------------------------------------------- Name : primRoundRectOutline Description : Draw an outline 2d rounded rectangle. Inputs : rect - pointer to rectangle structure containing coordinates. thickness - thickness of the lines c - color to draw it in, xb - x offset, yb - y offset Outputs : .. Return : void ----------------------------------------------------------------------------*/ void primRoundRectOutline(rectangle *rect, sdword thickness, color c, uword xb, uword yb) { oval o; sdword segs = SEGS; glColor3ub(colRed(c), colGreen(c), colBlue(c)); glPushAttrib(GL_LINE_BIT); glLineWidth((GLfloat)thickness); glBegin(GL_LINES); glVertex2f(SX(X0+xb), SY(Y0)); glVertex2f(SX(X1-xb), SY(Y0)); glVertex2f(SX(X1), SY(Y0+yb)); glVertex2f(SX(X1), SY(Y1-yb)); glVertex2f(SX(X1-xb), SY(Y1)); glVertex2f(SX(X0+xb), SY(Y1)); glVertex2f(SX(X0), SY(Y1-yb)); glVertex2f(SX(X0), SY(Y0+yb)); glEnd(); glPopAttrib(); // if (xb > 4 || yb > 4) // segs *= 2; // upper left o.centreX = X0+xb; o.centreY = Y0+yb; o.radiusX = xb; o.radiusY = yb; primOvalArcOutline2(&o, 3*PI/2, TWOPI, 2, segs, c); // upper right o.centreX = X1-xb; primOvalArcOutline2(&o, (real32)0, PI/2, 2, segs, c); // lower right o.centreY = Y1-yb; primOvalArcOutline2(&o, PI/2, PI, 2, segs, c); // lower left o.centreX = X0+xb; primOvalArcOutline2(&o, PI, 3*PI/2, 2, segs, c); }
void DPI::ScaleMouse(CPoint &pt) { pt.x = SX(pt.x); pt.y = SY(pt.y); }
void vd_impl_lineto(double x, double y) { NullRET; px = SX(x), py = SY(y); vd_trace1->lineto(vd_trace1, px, py); }
void vd_impl_text(double x, double y, char *s, unsigned long c) { NullRET; vd_trace1->setcolor(vd_trace1, c); vd_trace1->text(vd_trace1, SX(x), SY(y), s); }
void vd_impl_pixel(double x, double y, unsigned long c) { NullRET; vd_trace1->pixel(vd_trace1, SX(x), SY(y), c); }
void vd_impl_round(double x, double y, int r, unsigned long c) { NullRET; vd_trace1->setcolor(vd_trace1, c); vd_trace1->setlinewidth(vd_trace1, 1); vd_trace1->round(vd_trace1, SX(x), SY(y), r); }
CRect DPI::Rect(int x, int y, int w, int h) { return CRect {SX(x), SY(y), SX(x + w), SY(y + h)}; }