Ejemplo n.º 1
0
void DrawBuffer::RectOutline(float x, float y, float w, float h, uint32_t color, int align) {
	hLine(x, y, x + w + pixel_in_dps, color);
	hLine(x, y + h, x + w + pixel_in_dps, color);

	vLine(x, y, y + h + pixel_in_dps, color);
	vLine(x + w, y, y + h + pixel_in_dps, color);
}
Ejemplo n.º 2
0
void Dialog::draw() {
	assert(_widthChars != 0);

	// Set up the palette for this view
	_palette = new RGBList(8, NULL);
	_palette->setRange(0, 8, DIALOG_PALETTE);
	_vm->_palette->addRange(_palette);

	// Calculate bounds
	int dlgWidth = _dialogWidth;
	int dlgHeight = _lines.size() * (_vm->_font->current()->getHeight() + 1) + 10;
	int dialogX = (_vm->_screen->width() - dlgWidth) / 2;
	int dialogY = (_vm->_screen->height() - dlgHeight) / 2;

	// Create the surface for the dialog
	create(dlgWidth, dlgHeight, 1);
	_coords.left = dialogX;
	_coords.top = dialogY;
	_coords.right = dialogX + dlgWidth + 1;
	_coords.bottom = dialogY + dlgHeight + 1;

	// Set up the dialog
	fillRect(Common::Rect(0, 0, width(), height()), 3);
	setColour(2);
	hLine(1, width() - 1, height() - 2);	// Bottom edge
	hLine(0, width(), height() - 1);
	vLine(width() - 2, 2, height());		// Right edge
	vLine(width() - 1, 1, height());

	// Render dialog interior
	uint16 seed = 0xb78e;
	for (int yp = 2; yp < (height() - 2); ++yp) {
		byte *destP = this->getBasePtr(2, yp);

		for (int xp = 2; xp < (width() - 2); ++xp) {
			// Adjust the random seed
			uint16 v = seed;
			seed += 0x181D;
			v = ROR16(v, 9);
			seed = (seed ^ v) + ROR16(v, 3);

			*destP++ = ((seed & 0x10) != 0) ? 1 : 0;
		}
	}

	// If an ask position is set, create the input area frame
	if (_askPosition.y > 0) {

	}

	// Handle drawing the text contents
	_vm->_font->current()->setColours(7, 7, 7);
	setColour(7);

	for (uint lineCtr = 0, yp = 5; lineCtr < _lines.size(); ++lineCtr, yp += _vm->_font->current()->getHeight() + 1) {

		if (_lines[lineCtr].barLine) {
			// Bar separation line
			hLine(5, width() - 6, ((_vm->_font->current()->getHeight() + 1) >> 1) + yp);
		} else {
Ejemplo n.º 3
0
void DrawTable(const struct CGUIConstItem *Table)
{
	assert(Table);
	assert(Table->Kind==IDK_TABLE);

	TableCtrlSpec=((struct CTableCtrl *)(Table->Specific));

	tLeft   = Table->Left;
	tTop    = Table->Top;
	tWidth  = Table->Width;
	tHeight = Table->Height;

	ClearBox(tLeft,tTop,tWidth,tHeight);
	RectangleSet(tLeft,tTop,tWidth,tHeight);
	hLine(tLeft+1,tTop+tHeight-2,tWidth-2);
	vLine(tLeft+tWidth-2,tTop+1,tHeight-3);


	Cols = TableCtrlSpec->ColCount;
	Rows = TableCtrlSpec->RowCount;

	Cell = Table->Contained;
	AddToDequeTail((void *)Cell,&DrawQueue);
	// Заголовок таблиці
	vLine(Cell->Width+Cell->Left-4,tTop+1,tHeight-3);

	for (i=1;i<Cols;i++)
	{
		++Cell;
		vLine(Cell->Left-2,tTop+1,tHeight-3);
	}

	++Cell;
	hLine(tLeft+1,Cell->Top-3,tWidth-3);

	// друк по рядках
	for (j=1;j<Rows;j++)
	{
		hLine(tLeft+1,Cell->Top-2,tWidth-3);
		Cell+=Cols;
/*		for (i=1;i<Cols;i++)
		{
			++Cell;
			if (Cell->Additional->IsEnabled)
				DrawLimitedString(Cell->Left+4,Cell->Top+2,Cell->Width-4,Cell->Height-2,
					((struct CEditBoxItem *)(Cell->Specific))->Text,guiNormalFont);
			else
				DrawLimitedString(Cell->Left+4,Cell->Top+2,Cell->Width-4,Cell->Height-2,
					((struct CEditBoxItem *)(Cell->Specific))->Text,guiDisabledFont);

		}
		++Cell;*/
	}
}
Ejemplo n.º 4
0
void lvlIntro(Game *game, Level *level) {
	
	char levelNumber[50];
	int row,col,xPos, j = 0;
	sprintf(levelNumber, "LEVEL %d", game->levelNum);
	playMusic(intro, FALSE);
	
	// Draw stars, increasing length (speeding up)
	for ( j = 0; j < 30; j++ ) {
		
		lcd_fillScreen(BLACK);
		
		for (row = level->stars.y; row < DISPLAY_HEIGHT; row += STAR_SPACING_HEIGHT) { 
			for (col = level->stars.x; col < DISPLAY_WIDTH; col++) { 
				if (xPos%STAR_SPACING_WIDTH == 0) { 
					vLine(col,row, row + j, WHITE); 
				} 
				xPos++; 
			}
		}
		xPos=0; // reset xPos
		
		lcd_putString(100, 50, (unsigned char *)levelNumber);
		drawShip(level->player.currPos.x, -3*j + INIT_SHIP_POS_Y, level->player.type);
		memcpy((char*)LCD_FRAME_BUFFER,(char*)LCD_TEMP_BUFFER, 153600); // write temp buffer to fram buffer
	}		
	
	lcd_fillScreen(WHITE);
	playMusic(RainPizz,FALSE);
	memcpy((char*)LCD_FRAME_BUFFER,(char*)LCD_TEMP_BUFFER, 153600); // write temp buffer to fram buffer
	mdelay(150);
	// Draw stars, decreasing length (slowing down)
	
	for ( j = 15; j > 0; j-- ) {
		
		lcd_fillScreen(BLACK);
		
		for (row = level->stars.y; row < DISPLAY_HEIGHT; row += STAR_SPACING_HEIGHT) { 
			for (col = level->stars.x; col < DISPLAY_WIDTH; col++) { 
				if (xPos%STAR_SPACING_WIDTH == /*(row%2)*/ 0) { 
					vLine(col,row, row + j, WHITE); 
				} 
				xPos++; 
			}
		}
		xPos=0; // reset xPos
		
		lcd_putString(100, 50, (unsigned char *)levelNumber);
		drawShip(level->player.currPos.x, level->player.currPos.y - j*j, level->player.type);
		memcpy((char*)LCD_FRAME_BUFFER,(char*)LCD_TEMP_BUFFER, 153600); // write temp buffer to fram buffer
		mdelay(100);
	}
}
Ejemplo n.º 5
0
Group
Board::makeGrid( Point topLeft,
                 size_t columns, size_t rows,
                 double width, double height,
                 Color penColor, Color fillColor, double lineWidth,
                 const LineStyle style,
                 const LineCap cap,
                 const LineJoin join,
                 int depth )
{
  Group group;
  double cellSide = width / columns;
  group << Rectangle(topLeft.x,topLeft.y,width,height,penColor,fillColor,lineWidth,style,cap,join,depth);
  Line vLine(topLeft.x+cellSide,topLeft.y,topLeft.x+cellSide,topLeft.y-height,penColor,lineWidth,style,Shape::RoundCap,join,depth);
  while ( --columns ) {
    group << vLine;
    vLine.translate(cellSide,0);
  }
  cellSide = height / rows;
  Line hLine(topLeft.x,topLeft.y-cellSide,topLeft.x+width,topLeft.y-cellSide,penColor,lineWidth,style,Shape::RoundCap,join,depth);
  while ( --rows ) {
    group << hLine;
    hLine.translate(0,-cellSide);
  }

  return group;
}
Ejemplo n.º 6
0
void drawPanel(uchar* a) { 
  drawRect(a, 30, ROWS_CNT + 4);
  memset(a + (VIDEO_BPL * (2 + ROWS_CNT) + 1), 0x1C, 29); // hLine
  vLine(a + (VIDEO_BPL + 15), ROWS_CNT+1, 0x1B);
  print2(a + (VIDEO_BPL + 6 ), "imq");
  print2(a + (VIDEO_BPL + 21), "imq");  
}
void textBox::render()
{
	if(hidden)
		return;

	if(reDraw)
	{
		SDL_FillRect(surface,NULL,SDL_MapRGB(surface->format,color.r,color.g,color.b));
		hLine(0,0,rect.w,SDL_MapRGB(surface->format,0,0,0));
		vLine(0,1,rect.h - 2,SDL_MapRGB(surface->format,0,0,0));
		hLine(0,rect.h - 1,rect.w,SDL_MapRGB(surface->format,255,255,255));
		vLine(rect.w - 1,1,rect.h - 2,SDL_MapRGB(surface->format,255,255,255));
		reDraw = false;
		if(foreground != NULL)
		{
			SDL_Rect tmpRect = {2,2,0,0};
			SDL_BlitSurface(foreground,NULL,surface,&tmpRect);
		}
	}
	SDL_BlitSurface(surface,NULL,screen,&rect);
}
Ejemplo n.º 8
0
void CBeamEffectCreator::CreateLightningGlow (SLineDesc &Line, int iPointCount, CVector *pPoints, int iSize, CG16bitRegion *retRegion)

//	CreateLightningGlow
//
//	Creates a polygon region in the shape of th lightning.

	{
	int i;

	//	Compute a perpendicular line (the line width)

	CVector vLine(Line.xTo - Line.xFrom, Line.yTo - Line.yFrom);
	CVector vHalfPerp = (iSize * vLine.Perpendicular().Normal()) / 2.0;

	//	Generate polygon points.

	SPoint *pPolygon = new SPoint [iPointCount * 2];
	SPoint *pPoint = pPolygon;
	
	//	First add all the points on one side

	for (i = 0; i < iPointCount; i++)
		{
		pPoint->x = (int)(pPoints[i].GetX() + vHalfPerp.GetX());
		pPoint->y = (int)(pPoints[i].GetY() + vHalfPerp.GetY());

		pPoint++;
		}

	//	Now add the points on the other side (backwards)

	for (i = iPointCount - 1; i >= 0; i--)
		{
		pPoint->x = (int)(pPoints[i].GetX() - vHalfPerp.GetX());
		pPoint->y = (int)(pPoints[i].GetY() - vHalfPerp.GetY());

		pPoint++;
		}

	//	Convert to region

	retRegion->CreateFromPolygon(iPointCount * 2, pPolygon);

	//	Done

	delete [] pPolygon;
	}
Ejemplo n.º 9
0
void
UIScrollBar::draw() { 

    glLineWidth ( 1 );

    glPushName( _id ) ;
	if ( _vertical ) vLine();
	else hLine();

	if ( _vspan < _vrange ) { 
		glPushName( _box.id() );
		UIRect b = toGlobal(_box);
		b.filledRounded();
		b.outlineRounded();
		glPopName();
	}
    glPopName();
}
Ejemplo n.º 10
0
void PSV_ChartItem::createHVLine()
{
    QLineF hLine(m_chartRect.left(),m_chartRect.center().y(),m_chartRect.right(),m_chartRect.center().y());
    QLineF vLine(m_chartRect.center().x(),m_chartRect.top(),m_chartRect.center().x(),m_chartRect.bottom());

    m_hLineItem = new QGraphicsLineItem(hLine,this);
    m_vLineItem = new QGraphicsLineItem(vLine,this);
    m_boundingItem = new QGraphicsRectItem(getBoundingRect(),this);
    m_hLineItem->hide();
    m_vLineItem->hide();
    m_boundingItem->hide();
    m_hLineItem->setZValue(10001);
    m_vLineItem->setZValue(10001);
    m_boundingItem->setZValue(10001);

    m_currentMesItem = new QGraphicsTextItem(this);
    //    m_currentMesItem->setFont(m_valueFont);

}
Ejemplo n.º 11
0
void CBeamEffectCreator::DrawBeamStarBlaster (CG16bitImage &Dest, SLineDesc &Line, SViewportPaintCtx &Ctx)

//	DrawBeamStarBlaster
//
//	Draws the appropriate beam

	{
	WORD wStart, wEnd;

	wStart = CG16bitImage::BlendPixel(Ctx.wSpaceColor, m_wPrimaryColor, 155);
	wEnd = Ctx.wSpaceColor;
	Dest.DrawBiColorLine(Line.xFrom, Line.yFrom,
			Line.xTo, Line.yTo,
			3,
			wEnd,
			wStart);

	wStart = m_wSecondaryColor;
	wEnd = CG16bitImage::BlendPixel(Ctx.wSpaceColor, m_wPrimaryColor, 155);
	Dest.DrawBiColorLine(Line.xFrom, Line.yFrom,
			Line.xTo, Line.yTo,
			1,
			wEnd,
			wStart);

	//	Draw starburst

	int iCount = (m_iIntensity / 2) + mathRandom(4, 9);
	for (int i = 0; i < iCount; i++)
		{
		CVector vLine(Line.xTo, Line.yTo);
		vLine = vLine + PolarToVector(mathRandom(0,359), 4 * m_iIntensity + mathRandom(1, 11));
		Dest.DrawBiColorLine(Line.xTo, Line.yTo,
				(int)vLine.GetX(), (int)vLine.GetY(),
				1,
				wStart,
				Ctx.wSpaceColor);
		}
	}
Ejemplo n.º 12
0
void CScreenShotView::updatePreviewItem(const QPoint &pos)
{
    C_SCREENSHOT_LOG_FUNCTION;
    QPixmap pixmap(m_previewItemWidth,m_previewItemPixmapHeight+m_previewItemTextHeight);
    pixmap.fill(QColor(Qt::white));
    QPainter painter(&pixmap);
    painter.setRenderHints(QPainter::TextAntialiasing
                           | QPainter::SmoothPixmapTransform
                           | QPainter::HighQualityAntialiasing
                           | QPainter::NonCosmeticDefaultPen
                           | QPainter::Qt4CompatiblePainting);
    QPointF toItemPos = getPointToSelectedItem(pos);

    qreal scaleSize = 3;
    {//draw preview
        qreal width = m_previewItemWidth / scaleSize;
        qreal height = m_previewItemPixmapHeight / scaleSize;
        qreal x = (toItemPos.x() - 0.5 * width);
        QPointF pos(0,0);
        if(x < 0)
        {
            width = width + x;
            pos.setX(-x * scaleSize);
            x = 0;
        }
        else
        {
            width = qMin(width,m_desktopPixmap.width() - x);
        }
        qreal y = (toItemPos.y() - 0.5 * height);
        if(y < 0)
        {
            height += y;
            pos.setY(-y * scaleSize);
            y = 0;
        }
        else
        {
            height = qMin(height,m_desktopPixmap.height() - y);
        }
        QPixmap pixmap = m_desktopPixmap.copy(x,y,width,height).scaled(width * scaleSize,height * scaleSize);
        painter.drawImage(pos,pixmap.toImage());
        QColor lineColor("#89D4EB");
        lineColor.setAlpha(128);
        QPen pen(lineColor);
        pen.setWidth(m_previewLineWidth);
        painter.setPen(pen);
        QLineF hLine(0,0.5 * m_previewItemPixmapHeight,m_previewItemWidth,0.5 * m_previewItemPixmapHeight);
        painter.drawLine(hLine);
        QLineF vLine(0.5 * m_previewItemWidth,0,0.5 * m_previewItemWidth,m_previewItemPixmapHeight);
        painter.drawLine(vLine);
    }
    QRectF textRect(0,m_previewItemPixmapHeight,m_previewItemWidth,m_previewItemTextHeight);
    {//draw text background
        QBrush textBrush(QColor("#4F4F4F"));
        QPen pen(Qt::NoPen);
        painter.setPen(pen);
        painter.setBrush(textBrush);
        painter.drawRect(textRect);
    }
    {//draw text
        QRgb pointRgb = getPixmapPosRgb(m_desktopPixmap,toItemPos.toPoint());
        QFont font;
        font.setPixelSize(m_previewPointSize);
        painter.setFont(font);
        QColor textColor("#B8B8B8");
        QPen pen(textColor);
        painter.setPen(pen);
        QString text = QString("(%1,%2)\nRGB:(%3,%4,%5)")
                .arg(pos.x())
                .arg(pos.y())
                .arg(qRed(pointRgb))
                .arg(qGreen(pointRgb))
                .arg(qBlue(pointRgb));
        painter.drawText(textRect,Qt::AlignCenter,text);
    }
    m_previewItem->setPixmap(pixmap);
    qreal x = pos.x() - m_previewItemDx - pixmap.width();
    if(x < 0)
    {
        x = pos.x() + m_previewItemDy;
    }
    qreal y = pos.y() + m_previewItemDy;
    if(y + pixmap.height() > this->height())
    {
        y = pos.y() - m_previewItemDy - pixmap.height();
    }
    m_previewItem->setPos(x,y);
    if(!m_previewItem->isVisible())
    {
        emit sigPreviewItemShow();
        m_previewItem->setVisible(true && !m_onlySelect);
    }
}
Ejemplo n.º 13
0
void Surface::frameRect(const Common::Rect &r, uint32 color) {
	hLine(r.left, r.top, r.right-1, color);
	hLine(r.left, r.bottom-1, r.right-1, color);
	vLine(r.left, r.top, r.bottom-1, color);
	vLine(r.right-1, r.top, r.bottom-1, color);
}
void drawPbStamp(struct pbStamp *pbStampPtr, struct pbStampPict *stampPictPtr)
/* draw the stamp */
{
int ix, iy, iw, ih;
char *stampName, *stampTable, *stampTitle, *stampDesc;
double txmin, tymin, txmax, tymax;
int i, n, index;
int xx, yy;
char charStr[2];
Color edgeColor;
Color stampColor;
int titleLen;

stampName   = cloneString(pbStampPtr->stampName);
stampTable  = cloneString(pbStampPtr->stampTable);
stampTitle  = cloneString(pbStampPtr->stampTitle);
n           = pbStampPtr->len;
txmin       = pbStampPtr->xmin;
txmax       = pbStampPtr->xmax;
tymin       = pbStampPtr->ymin;
tymax       = pbStampPtr->ymax;
stampDesc   = cloneString(pbStampPtr->stampDesc);

ix = stampPictPtr->xOrig;
iy = stampPictPtr->yOrig;
iw = stampPictPtr->width;
ih = stampPictPtr->height;
    
xScale = (double)(iw)/(txmax - txmin);
yScale = (double)(ih)/(tymax - tymin);
   
calStampXY(stampPictPtr, txmin, tymax, &xx, &yy);
mapBoxStamp(xx, yy, iw, ih, stampTitle, stampName);

calStampXY(stampPictPtr, txmin+(txmax-txmin)/2.0, tymax, &xx, &yy);
vgTextCentered(g_vg, xx-5, yy-12, 10, 10, MG_BLACK, g_font, stampTitle);
    
titleLen = strlen(stampTitle);
mapBoxStampTitle(xx-5-titleLen*6/2-6, yy-14, titleLen*6+12, 14,  stampTitle, stampName);
    
edgeColor  = boundaryColor;
stampColor = vgFindColorIx(g_vg, 220, 220, 220);
for (index=0; index < (n-1); index++)
    {
    pbBox(tx[index], tymin, tx[index+1]-tx[index], ty[index], stampColor);
    hLine(tx[index], ty[index], tx[index+1]-tx[index], 1, edgeColor);
    }
vLine(tx[0], 0, ty[0], 1,  edgeColor);
for (index=0; index < (n-1); index++)
    {
    if (ty[index+1] > ty[index])
	{
	vLine(tx[index+1], ty[index], ty[index+1]-ty[index], 1,  edgeColor);
	}
    else
	{
	vLine(tx[index+1], ty[index+1], ty[index]-ty[index+1], 1, edgeColor);
	}
    }
    
hLine(txmin, tymin, txmax-txmin, 2, boundaryColor);
/* this line needs to call hLine2 for fine tuning at the right hand side ending */
hLine2(txmin, tymax, txmax-txmin, 2, boundaryColor);
vLine(txmin, tymin, tymax-tymin, 2, boundaryColor);
vLine(txmax, tymin, tymax-tymin, 2, boundaryColor);
    
if (strcmp(pbStampPtr->stampName, "pepRes") == 0)
    {
    for (i=0; i<20; i++)
	{
    	calStampXY(stampPictPtr, tx[i], tymin, &xx, &yy);
	safef(charStr, sizeof(charStr), "%c", aaAlphabet[i]);
	vgTextCentered(g_vg, xx+1, yy+5, 10, 10, MG_BLACK, g_font, charStr);
	}
    } 
}
void markResStdvStamp(struct pbStamp *pbStampPtr, struct pbStampPict *stampPictPtr,
 		  int iTarget, double yValueIn, double tx[], double ty[], 
		  double avg[], double stddev[])
/* mark the AA residual stddev stamp */
{
int ix, iy; 
double txmin, tymin, txmax, tymax;
double yValue, yPlotValue;
int len;
int xx,  yy;
double pctLow, pctHi;
char cond_str[255];
char *answer;
char aaChar;
   
len	= pbStampPtr->len; 
txmin	= pbStampPtr->xmin;
txmax	= pbStampPtr->xmax;

/* force fit for the stddev stamp plot */
tymin	= -4.0;
tymax	=  4.0;
   
ix	= stampPictPtr->xOrig;
iy	= stampPictPtr->yOrig;

aaChar = aaAlphabet[iTarget];
safef(cond_str, sizeof(cond_str), "AA='%c'", aaChar);
answer = sqlGetField(database, "pbAnomLimit", "pctLow", cond_str);
pctLow    = (double)(atof(answer));
answer = sqlGetField(database, "pbAnomLimit", "pctHi", cond_str);
pctHi    = (double)(atof(answer));

yScale = (double)(120)/8.0;
calStampXY(stampPictPtr, (txmax-txmin)/2.0, tymax, &xx, &yy);
  
yValue = (yValueIn - avg[iTarget])/stddev[iTarget];
if (yValue > tymax)
    {
    yPlotValue = tymax;
    }
else
    {
    if (yValue < tymin)
        {
        yPlotValue = tymin;
        }
    else
        {
        yPlotValue = yValue;
        }
    }
    
if (yValueIn > pctHi)
    {
    vLine(tx[iTarget]+0.4, 0.0, yPlotValue, 3, abnormalColor);
    }
else
    {
    if (yValueIn <= pctLow)
  	{
	vLine(tx[iTarget]+0.4, 0.0+yPlotValue, -yPlotValue, 3, abnormalColor);
	}
    else
  	{
	/* normal range */
	if ((yValueIn - avg[iTarget]) >= 0.0)
    	    {
    	    vLine(tx[iTarget]+0.4, 0.0, yPlotValue, 2, normalColor);
    	    }
	else
    	    {
    	    vLine(tx[iTarget]+0.4, 0.0+yPlotValue, -yPlotValue, 2, normalColor);
    	    }
	}
    }
}
Ejemplo n.º 16
0
void grph_line(int fd, int x0, int y0, int x1, int y1)
{
  short dx = 0, dy = 0;
  signed char  dx_sym = 0, dy_sym = 0;
  short dx_x2 = 0, dy_x2 = 0;
  short di = 0;
 // PGDC pgdc = (PGDC) fd;

//printf("line: %d %d %d\n", pgdc->x, pgdc->cx, pgdc->xres);
/*  x0 += pgdc->x;
  y0 += pgdc->y;
  x1 += pgdc->x;
  y1 += pgdc->y;
*/
  dx = x1-x0;
  dy = y1-y0;

/*  x += pgdc->x;
  y += pgdc->y;

  if (cx<0) cx = 0;
  if (cy<0) cy = 0;

  if (x > pgdc->x+pgdc->cx) return;
  else if (x+cx > pgdc->x+pgdc->cx) cx = pgdc->x+pgdc->cx -1 - x;

  if (y > pgdc->y+pgdc->cy) return;
  else if (y+cy > pgdc->y+pgdc->cy) cy = pgdc->y+pgdc->cy -1 - y;
*/

  if(dx == 0)          /* vertical line */
  {
   /* if (x0 < pgdc->x || x0 > pgdc->x + pgdc->cx) return;
    y0 = (y0 < pgdc->y) ? pgdc->y : y0;
    y0 = (y0 >= pgdc->y+pgdc->cy) ? pgdc->y+pgdc->cy-1 : y0;
    y1 = (y1 < pgdc->y) ? pgdc->y : y1;
    y1 = (y1 >= pgdc->y+pgdc->cy) ? pgdc->y+pgdc->cy-1 : y1;*/
    vLine(fd, x0, y0, y1);
    return;
  }

  if(dx > 0)
  {
    dx_sym = 1;
  }
  else
  {
    dx_sym = -1;
  }

  if(dy == 0)          /* horizontal line */
  {
   /* if (y0 < pgdc->y || y0 > pgdc->y + pgdc->cy) return;
printf("grph_line %d %d  %d %d\n", x0, x1, pgdc->x, pgdc->cx);
    x0 = (x0 < pgdc->x) ? pgdc->x : x0;
    x0 = (x0 >= pgdc->x+pgdc->cx) ? pgdc->x+pgdc->cx-1 : x0;
    x1 = (x1 < pgdc->x) ? pgdc->x : x1;
    x1 = (x1 >= pgdc->x+pgdc->cx) ? pgdc->x+pgdc->cx-1 : x1;*/
    hLine(fd, x0, y0, x1);
    return;
  }

  if (((PGDC) fd)->ps != PS_SOLID)
  {
    error("Only PS_SOLID is supported in %s", __FUNCTION__);
  }


  if(dy > 0)
  {
    dy_sym = 1;
  }
  else
  {
    dy_sym = -1;
  }

  dx = dx_sym*dx;
  dy = dy_sym*dy;

  dx_x2 = dx*2;
  dy_x2 = dy*2;

  if(dx >= dy)
  {
    di = dy_x2 - dx;
    while(x0 != x1)
    {
      lcd_point(fd, x0, y0);
      x0 += dx_sym;
      if(di<0)
      {
        di += dy_x2;
      }
      else
      {
        di += dy_x2 - dx_x2;
        y0 += dy_sym;
      }
     // if (x0<0 || x0>=pgdc->cx) break;
     // if (y0<0 || y0>=pgdc->cy) break;
    }
    lcd_point(fd, x0, y0);
  }
  else
  {
    di = dx_x2 - dy;
    while(y0 != y1)
    {
      lcd_point(fd, x0, y0);
      y0 += dy_sym;
      if(di < 0)
      {
        di += dx_x2;
      }
      else
      {
        di += dx_x2 - dy_x2;
        x0 += dx_sym;
      }
     // if (x0<0 || x0>=pgdc->cx) break;
     // if (y0<0 || y0>=pgdc->cy) break;
    }
    lcd_point(fd, x0, y0);
  }
  return;
}
Ejemplo n.º 17
0
void grph_line_bound(int fd, int x0, int y0, int x1, int y1, int yl, int yu)
{
  short dx = 0, dy = 0;
  signed char  dx_sym = 0, dy_sym = 0;
  short dx_x2 = 0, dy_x2 = 0;
  short di = 0;
 // PGDC pgdc = (PGDC) fd;

//printf("line: %d %d %d\n", pgdc->x, pgdc->cx, pgdc->xres);
  dx = x1-x0;
  dy = y1-y0;


  if(dx == 0)          /* vertical line */
  {
    if (y0 < yl && y1 < yl) return;
    if (y0 > yu && y1 > yu) return;
    if (y0 < yl) y0 = yl;
    if (y0 > yu) y0 = yu;
    if (y1 < yl) y1 = yl;
    if (y1 > yu) y1 = yu;
    vLine(fd, x0, y0, y1);
    return;
  }

  if(dx > 0)
  {
    dx_sym = 1;
  }
  else
  {
    dx_sym = -1;
  }

  if(dy == 0)          /* horizontal line */
  {
    if (y0 < yl) return;
    if (y0 > yu) return;
    hLine(fd, x0, y0, x1);
    return;
  }

  if (((PGDC) fd)->ps != PS_SOLID)
  {
    error("Only PS_SOLID is supported in %s", __FUNCTION__);
  }


  if(dy > 0)
  {
    dy_sym = 1;
  }
  else
  {
    dy_sym = -1;
  }

  dx = dx_sym*dx;
  dy = dy_sym*dy;

  dx_x2 = dx*2;
  dy_x2 = dy*2;

  if(dx >= dy)
  {
    di = dy_x2 - dx;
    while(x0 != x1)
    {
      if (y0 >= yl && y0 <= yu)
      {
        lcd_point(fd, x0, y0);
      }
      x0 += dx_sym;
      if(di<0)
      {
        di += dy_x2;
      }
      else
      {
        di += dy_x2 - dx_x2;
        y0 += dy_sym;
      }
    }
    if (y0 >= yl && y0 <= yu)
    {
      lcd_point(fd, x0, y0);
    }
  }
  else
  {
    di = dx_x2 - dy;
    while(y0 != y1)
    {
      if (y0 >= yl && y0 <= yu)
      {
        lcd_point(fd, x0, y0);
      }
      y0 += dy_sym;
      if(di < 0)
      {
        di += dx_x2;
      }
      else
      {
        di += dx_x2 - dy_x2;
        x0 += dx_sym;
      }
    }
    if (y0 >= yl && y0 <= yu)
    {
      lcd_point(fd, x0, y0);
    }
  }
  return;
}
void drawPbStampB(struct pbStamp *pbStampPtr, struct pbStampPict *stampPictPtr)
/* draw the stamp, especially for the AA Anomaly */
{
int ix, iy, iw, ih;
char *stampTable, *stampTitle, *stampDesc;
double txmin, tymin, txmax, tymax;
int i, n, index;
int xx, yy;
char charStr[2];
int titleLen;

stampTable  = cloneString(pbStampPtr->stampTable);
stampTitle  = cloneString(pbStampPtr->stampTitle);
n           = pbStampPtr->len;
txmin       = pbStampPtr->xmin;
txmax       = pbStampPtr->xmax;
tymin       = pbStampPtr->ymin;
tymax       = pbStampPtr->ymax;
stampDesc   = cloneString(pbStampPtr->stampDesc);

ix = stampPictPtr->xOrig;
iy = stampPictPtr->yOrig;
iw = stampPictPtr->width;
ih = stampPictPtr->height;

xScale = (double)(iw)/(txmax - txmin);
yScale = (double)(ih)/(tymax - tymin);

calStampXY(stampPictPtr, txmin, tymax, &xx, &yy);
mapBoxStamp(xx, yy, iw, ih, "Amino Acid Anomalies", "pepAnomalies");
 
calStampXY(stampPictPtr, txmin+(txmax-txmin)/2.0, tymax, &xx, &yy);
vgTextCentered(g_vg, xx-5, yy-12, 10, 10, MG_BLACK, g_font, "Amino Acid Anomalies");
    
titleLen = strlen("Amino Acid Anomoly");
mapBoxStampTitle(xx-5-titleLen*6/2-6, yy-14, titleLen*6+12, 14,  
	         "Amino Acid Anomolies", "pepAnomalies");
/*
calStampXY(stampPictPtr, txmax-(txmax-txmin)*.25, tymin+(tymax-tymin)/4.0*3.0, &xx, &yy);
vgTextCentered(g_vg, xx, yy-10, 10, 10, MG_BLACK, g_font, "+2 stddev");
calStampXY(stampPictPtr, txmax-(txmax-txmin)*.25, tymin+(tymax-tymin)/4.0, &xx, &yy);
vgTextCentered(g_vg, xx, yy-10, 10, 10, MG_BLACK, g_font, "-2 stddev");
*/

index = 0; 
hLine(tx[index], (tymax-tymin)/8.0,     (tx[index+1]-tx[index])/2.0, 1, MG_GRAY);
hLine(tx[index], (tymax-tymin)/4.0,     (tx[index+1]-tx[index])/2.0, 1, MG_GRAY);
hLine(tx[index], (tymax-tymin)/8.0*3.0, (tx[index+1]-tx[index])/2.0, 1, MG_GRAY);
hLine(tx[index], (tymax-tymin)/4.0*3.0, (tx[index+1]-tx[index])/2.0, 1, MG_GRAY);
hLine(tx[index], (tymax-tymin)/8.0*4.0, (tx[index+1]-tx[index])/2.0, 1, MG_GRAY);
hLine(tx[index], (tymax-tymin)/8.0*5.0, (tx[index+1]-tx[index])/2.0, 1, MG_GRAY);
hLine(tx[index], (tymax-tymin)/8.0*7.0, (tx[index+1]-tx[index])/2.0, 1, MG_GRAY);

for (index=0; index < (n-1); index++)
    {
    hLine(tx[index], (tymax-tymin)/2.0,     tx[index+1]-tx[index], 1, MG_BLACK);
    }
   
vLine(tx[0], 0, ty[0], 1,  pbBlue);
    
hLine(txmin, tymin, txmax-txmin, 2, boundaryColor);
/* this line needs to call hLine2 for fine tuning at the right hand side ending */ 
hLine2(txmin, tymax, txmax-txmin, 2, boundaryColor);
vLine(txmin, tymin, tymax-tymin, 2, boundaryColor);
vLine(txmax, tymin, tymax-tymin, 2, boundaryColor);
 
if (strcmp(pbStampPtr->stampName, "pepRes") == 0)
    {
    for (i=0; i<20; i++)
    	{
    	calStampXY(stampPictPtr, tx[i], tymin, &xx, &yy);
	safef(charStr, sizeof(charStr), "%c", aaAlphabet[i]);
	vgTextCentered(g_vg, xx+1, yy+5, 10, 10, MG_BLACK, g_font, charStr);
	}
    } 
}