示例#1
0
/* neglectible % of execution time */
static void
animateLMorph(struct state *st)
{
    int i;
    if (st->currGamma > st->maxGamma) {
        st->currGamma = 0.0;
        st->nFrom = st->nTo;
        st->nTo = st->nNext;
        st->aFrom = st->a[st->nFrom];
	st->aTo = st->a[st->nTo];
        do {
            st->nNext = RND(st->numFigs);
        } while (st->nNext == st->nTo);
	st->aNext = st->a[st->nNext];

	st->shift = RND(st->numPoints);
        if (RND(2)) {
            /* reverse the array to get more variation. */
            int    i1, i2;
            XPoint p;
            
            for (i1 = 0, i2 = st->numPoints - 1; i1 < st->numPoints / 2; i1++, i2--) {
                p = st->aNext[i1];
                st->aNext[i1] = st->aNext[i2];
                st->aNext[i2] = p;
            }
        }

	/* calculate the slopes */
	for (i = 0; i < st->numPoints ; i++) {
            st->aSlopeFrom[i].x = st->aSlopeTo[i].x;
            st->aSlopeFrom[i].y = st->aSlopeTo[i].y;
            st->aSlopeTo[i].x = st->aNext[i].x - st->aTo[i].x;
            st->aSlopeTo[i].y = (st->aNext[i].y - st->aTo[i].y);
	}
    }

    createPoints(st);
    drawImage(st);
    st->aPrev = st->aCurr;
    st->aCurr = st->aWork[st->nWork ^= 1];

    st->currGamma += st->deltaGamma;
}
示例#2
0
文件: star.c 项目: shivae/CPE101
int main(){
   char image[HEIGHT][WIDTH][COLORS];
   char white[COLORS], red[COLORS];
   
   setColor(white, 255, 255, 255);
   setColor(red, 255, 0, 0);

   blankImage(image, white);

   putLine(image, 100, 300, 300, 400, red);
   putLine(image, 300, 400, 200, 150, red);
   putLine(image, 200, 150, 200, 450, red);
   putLine(image, 200, 450, 300, 200, red);
   putLine(image, 300, 200, 100, 300, red);

   drawImage(image);
   
   return 0;
}
示例#3
0
void GraphicsContext::drawTiledImage(Image* image, ColorSpace styleColorSpace, const IntRect& dest, const IntRect& srcRect, Image::TileRule hRule, Image::TileRule vRule, CompositeOperator op, bool useLowQualityScale)
{
    if (paintingDisabled() || !image)
        return;

    if (hRule == Image::StretchTile && vRule == Image::StretchTile) {
        // Just do a scale.
        drawImage(image, styleColorSpace, dest, srcRect, op);
        return;
    }

    if (useLowQualityScale) {
        InterpolationQuality previousInterpolationQuality = imageInterpolationQuality();
        setImageInterpolationQuality(InterpolationLow);
        image->drawTiled(this, dest, srcRect, hRule, vRule, styleColorSpace, op);
        setImageInterpolationQuality(previousInterpolationQuality);
    } else
        image->drawTiled(this, dest, srcRect, hRule, vRule, styleColorSpace, op);
}
示例#4
0
文件: main.cpp 项目: entropial/Tetris
int main(int argc, char* args[]) {
    if (!init()) {
        return INIT_FAILED;
    }
    if (!createWindow()) {
        return WINDOW_DRAW_FAILED;
    }
    SDL_Surface* background_image = loadImage("C:/Users/bry/Documents/Visual Studio 2015/Projects/Project1/Project1/x.bmp");
    drawInitialScreen();

    drawImage(background_image);

    gameLoop();

    SDL_DestroyWindow(window);
    SDL_Quit();

    return 0;
}
示例#5
0
void FractalForm::computeJulia(const Point& center, double zoom, std::size_t imageWidth, std::size_t imageHeight, const Point& computation)
{
  fractal_ = Fractal(center, zoom);
  ImageDraw draw(imageWidth, imageHeight, ColorSchemeFactory::getColorScheme());
  ProgressHandler progress(widget.progressBar);

  Julia algo(computation);
  fractal_.compute(draw, algo, progress);

  progress.setProgress(100);

  drawImage(draw.getImage());
  this->setCenter(fractal_.getCenter())
    ->setZoom(fractal_.getZoom())
    ->setIterations(fractal_.getIterations())
    ->setImageInfo(imageWidth, imageHeight)
    ->setColorScheme(ColorSchemeFactory::getColorScheme().getName())
    ->setTitle(fractal_.getName());
}
示例#6
0
void DesktopWindow::doDraw(DeviceContext *dc)
{
  AutoLock al(&m_bufferLock);
  int fbWidth  = m_framebuffer.getDimension().width;
  int fbHeight = m_framebuffer.getDimension().height;

  if (!fbWidth || !fbHeight) {
    Graphics graphics(dc);

    graphics.fillRect(m_clientArea.left, m_clientArea.top, 
                      m_clientArea.right, m_clientArea.bottom, &m_brush);
    return;
  }

  scrollProcessing(fbWidth, fbHeight);

  int iHorzPos = 0; 
  int iVertPos = 0; 

  if (m_showHorz) { 
    iHorzPos = m_sbar.getHorzPos();
  }

  if (m_showVert) {
    iVertPos = m_sbar.getVertPos();
  }

  m_scManager.setStartPoint(iHorzPos, iVertPos);

  Rect src, dst;
  m_scManager.getSourceRect(&src);
  m_scManager.getDestinationRect(&dst);

  int iWidth = m_clientArea.getWidth() - dst.getWidth();
  int iHeight = m_clientArea.getHeight() - dst.getHeight();

  if (iWidth || iHeight) {
    drawBackground(dc, &m_clientArea.toWindowsRect(), &dst.toWindowsRect());
  }

  drawImage(&src.toWindowsRect(), &dst.toWindowsRect());
}
示例#7
0
void UIItem::drawSelf(Fw::DrawPane drawPane)
{
    if((drawPane & Fw::ForegroundPane) == 0)
        return;

    // draw style components in order
    if(m_backgroundColor.aF() > Fw::MIN_ALPHA) {
        Rect backgroundDestRect = m_rect;
        backgroundDestRect.expand(-m_borderWidth.top, -m_borderWidth.right, -m_borderWidth.bottom, -m_borderWidth.left);
        drawBackground(m_rect);
    }

    drawImage(m_rect);

    if(m_itemVisible && m_item) {
        Rect drawRect = getPaddingRect();
        Point dest = drawRect.bottomRight() + Point(1,1);

        int exactSize = std::max<int>(32, m_item->getExactSize());
        if(exactSize == 0)
            return;

        float scaleFactor = std::min<float>(drawRect.width() / (float)exactSize, drawRect.height() / (float)exactSize);
        dest += (m_item->getDisplacement() - Point(32,32)) * scaleFactor;

        g_painter->setColor(m_color);
        m_item->draw(dest, scaleFactor, true);

        if(m_font && (m_item->isStackable() || m_item->isChargeable()) && m_item->getCountOrSubType() > 1) {
            std::string count = stdext::to_string(m_item->getCountOrSubType());
            g_painter->setColor(Color(231, 231, 231));
            m_font->drawText(count, Rect(m_rect.topLeft(), m_rect.bottomRight() - Point(3, 0)), Fw::AlignBottomRight);
        }

        if(m_showId)
            m_font->drawText(stdext::to_string(m_item->getServerId()), m_rect, Fw::AlignBottomRight);
    }

    drawBorder(m_rect);
    drawIcon(m_rect);
    drawText(m_rect);
}
示例#8
0
void Graphics::drawImagePattern(Image *image, int x, int y, int w, int h)
{
    int iw = image->getWidth();
    int ih = image->getHeight();
    if (iw == 0 || ih == 0) return;

    int px = 0;                       // X position on pattern plane
    int py = 0;                       // Y position on pattern plane

    while (py < h) {
        while (px < w) {
            int dw = (px + iw >= w) ? w - px : iw;
            int dh = (py + ih >= h) ? h - py : ih;
            drawImage(image, 0, 0, x + px, y + py, dw, dh);
            px += iw;
        }
        py += ih;
        px = 0;
    }
}
示例#9
0
void KissPictureBox::onRenderPre() {
	loadImage(this->strImageFile);

	if (this->getWidthFit()) {
		this->dZoom = (float)this->getDimensions().w / (float)this->sfImage->w;
		this->dZoom += this->dZoomAdjust;
	}
	else {
		this->rotate_zoom(this->dRotation, 1.0f);

		if (this->bAutoSize) {
			this->calcZoomFactor(this->getDimensions().w, this->getDimensions().h);
			this->dZoom += this->dZoomAdjust;
		}
	}

	this->rotate_zoom(0.0f, this->dZoom);

	drawImage();
}
示例#10
0
void KisOpenGLCanvas2::renderCanvasGL()
{
    // Draw the border (that is, clear the whole widget to the border color)
    QColor widgetBackgroundColor = borderColor();
    glClearColor(widgetBackgroundColor.redF(), widgetBackgroundColor.greenF(), widgetBackgroundColor.blueF(), 1.0);
    glClear(GL_COLOR_BUFFER_BIT);

    if (d->displayFilter) {
        d->displayFilter->updateShader();
    }

    if (KisOpenGL::hasOpenGL3()) {
        d->quadVAO.bind();
    }
    drawCheckers();
    drawImage();
    if (KisOpenGL::hasOpenGL3()) {
        d->quadVAO.release();
    }
}
示例#11
0
void GraphicsContext::drawTiledImage(Image& image, const FloatRect& destination, const FloatRect& source, const FloatSize& tileScaleFactor,
    Image::TileRule hRule, Image::TileRule vRule, const ImagePaintingOptions& imagePaintingOptions)
{
    if (paintingDisabled())
        return;

    if (isRecording()) {
        m_displayListRecorder->drawTiledImage(image, destination, source, tileScaleFactor, hRule, vRule, imagePaintingOptions);
        return;
    }

    if (hRule == Image::StretchTile && vRule == Image::StretchTile) {
        // Just do a scale.
        drawImage(image, destination, source, imagePaintingOptions);
        return;
    }

    InterpolationQualityMaintainer interpolationQualityForThisScope(*this, imagePaintingOptions.m_interpolationQuality);
    image.drawTiled(*this, destination, source, tileScaleFactor, hRule, vRule, imagePaintingOptions.m_compositeOperator);
}
示例#12
0
static void ogl_drawImageRegion(MAHandle image, const MARect *srcRect, const MAPoint2d *dstPoint, int transformMode) {	
	GLshort textureCoords[] = {
		(srcRect->left), (srcRect->top),
		(srcRect->left + srcRect->width), (srcRect->top),
		(srcRect->left + srcRect->width), (srcRect->top + srcRect->height),
		(srcRect->left), (srcRect->top + srcRect->height)
	};


	GLshort vertexCoords[] = {
		dstPoint->x, dstPoint->y,
		dstPoint->x+srcRect->width, dstPoint->y,
		dstPoint->x+srcRect->width, dstPoint->y+srcRect->height,
		dstPoint->x, dstPoint->y+srcRect->height
	};

	Texture* texture = getTexture(image);	

	drawImage(textureCoords, vertexCoords, texture);
}
示例#13
0
void drawMedalsMenu()
{
	int i;
	SDL_Rect rect;

	drawImage(menu.background, menu.x, menu.y, FALSE, 196);

	rect.x = menu.x + 5;
	rect.y = menu.y + 5;
	rect.w = menu.w;
	rect.h = menu.h;

	SDL_RenderSetClipRect(game.renderer, &rect);

	for (i=0;i<menu.widgetCount;i++)
	{
		drawWidget(menu.widgets[i], &menu, -1);
	}

	SDL_RenderSetClipRect(game.renderer, NULL);
}
示例#14
0
//--------------------------------------------------------------
void testApp::setup(){
    ofBackground(0);
    
    #ifdef RETINA_DISPLAY
        scale = 2;
        lineWidth = 2;
        lineLength = 6;
    #else
        scale = 1;
        lineWidth = 1;
        lineLength = 5;
    #endif
    
    screenWidth = ofGetScreenWidth();
    screenHeight = ofGetScreenHeight();
    
    fbo.allocate(screenWidth*scale, screenHeight*scale, GL_RGBA);
    
    drawImage();
    saveImage();
}
示例#15
0
void DocumentView::drawElement(cairo_t* cr, Element* e)
{
	XOJ_CHECK_TYPE(DocumentView);

	if (e->getType() == ELEMENT_STROKE)
	{
		drawStroke(cr, (Stroke*) e);
	}
	else if (e->getType() == ELEMENT_TEXT)
	{
		drawText(cr, (Text*) e);
	}
	else if (e->getType() == ELEMENT_IMAGE)
	{
		drawImage(cr, (Image*) e);
	}
	else if (e->getType() == ELEMENT_TEXIMAGE)
	{
		drawTexImage(cr, (TexImage*) e);
	}
}
示例#16
0
void FV_VisualDragText::mouseCut(UT_sint32 x, UT_sint32 y)
{
	getImageFromSelection(x,y);
	bool bPasteTableCol = (m_pView->getSelectionMode() == FV_SelectionMode_TableColumn);

	// flag up on the document level that we are dragging with the mouse
	// (in revisions mode the PT needs to be able to make a distinction between normal
	// cut/delete and the mouse cut)
	m_pView->getDocument()->setVDNDinProgress(true);
	
	if(bPasteTableCol)
	{
		m_pView->cmdCut();
	}
	else
	{
		PT_DocPosition pos1 = m_pView->getSelectionAnchor();
		PT_DocPosition pos2 = m_pView->getPoint();
		if(pos1 > pos2)
		{
			pos2 = m_pView->getSelectionAnchor();
			pos1 = m_pView->getPoint();
		}
		if(m_bSelectedRow)
		{
		    m_pView->copyToLocal(pos1,pos2);
		    m_pView->cmdDeleteRow(pos1+2);
		    m_pView->setSelectionMode(FV_SelectionMode_TableRow);
		}
		else
		{
		    m_pView->copyToLocal(pos1,pos2);
		    m_pView->cmdCharDelete(true,1);
		}
	}
	m_pView->getDocument()->setVDNDinProgress(false);
	
	m_pView->updateScreen(false);
	drawImage();
}
示例#17
0
bool OpenGLGraphics::drawRescaledImage(Image *image, int srcX, int srcY,
                                       int dstX, int dstY,
                                       int width, int height,
                                       int desiredWidth, int desiredHeight,
                                       bool useColor)
{
    if (!image)
        return false;

    // Just draw the image normally when no resizing is necessary,
    if (width == desiredWidth && height == desiredHeight)
    {
        return drawImage(image, srcX, srcY, dstX, dstY,
                         width, height, useColor);
    }

    srcX += image->mBounds.x;
    srcY += image->mBounds.y;

    if (!useColor)
        glColor4f(1.0f, 1.0f, 1.0f, image->mAlpha);

    bindTexture(Image::mTextureType, image->mGLImage);

    setTexturingAndBlending(true);

    // Draw a textured quad.
    drawRescaledQuad(image, srcX, srcY, dstX, dstY, width, height,
                     desiredWidth, desiredHeight);

    if (!useColor)
    {
        glColor4ub(static_cast<GLubyte>(mColor.r),
                   static_cast<GLubyte>(mColor.g),
                   static_cast<GLubyte>(mColor.b),
                   static_cast<GLubyte>(mColor.a));
    }

    return true;
}
示例#18
0
void Draw::drawTexts(const Mat& src, Text*& text1, Text*& text2)
{
    Mat dst1 = src.clone();
    Mat dst2 = src.clone();
    
    Scalar red = CV_RGB(BRIGHTNESS,0,0);
    Scalar blue = CV_RGB(0,0,BRIGHTNESS);
    
    Point2f rect_points1[4], rect_points2[4];
    text1->rotatedRect.points( rect_points1);
    text2->rotatedRect.points( rect_points2);
    for( int j = 0; j < 4; j++ ) {
        line( dst1, rect_points1[j], rect_points1[(j+1)%4], red, 1, 8 );
        line( dst2, rect_points2[j], rect_points2[(j+1)%4], red, 1, 8 );
    }
    
    for (int j = 0; j < text1->objects.size(); j++) {
        if (j == 0) circle(dst1, text1->objects[j]->centroid, 3, red, 3);
        else if (j == text1->focusedIndex) circle(dst1, text1->objects[j]->centroid, 3, blue);
        else circle(dst1, text1->objects[j]->centroid, 3, red);
        
        if (text1->originIndexes[j] >= 0) {
            line(dst1, text1->objects[j]->centroid,
                 text1->objects[text1->originIndexes[j]]->centroid, red);
        }
    }
    
    for (int j = 0; j < text2->objects.size(); j++) {
        if (j == 0) circle(dst2, text2->objects[j]->centroid, 3, red, 3);
        else if (j == text2->focusedIndex) circle(dst2, text2->objects[j]->centroid, 3, blue);
        else circle(dst2, text2->objects[j]->centroid, 3, red);
        
        if (text2->originIndexes[j] >= 0) {
            line(dst2, text2->objects[j]->centroid,
                 text2->objects[text2->originIndexes[j]]->centroid, red);
        }
    }
    
    drawImage(dst1, dst2);
}
示例#19
0
void decodeProgressiveModeBitApproximation(TwoByte* st, TwoByte offset){
	int h = workingImage.getHeight();
	int w = workingImage.getWidth();
										
	Byte* imgd = workingImage.getImageData();
	unsigned int q = 1<<quantizationLevel;

	TwoByte* tblock = new TwoByte[192];
	Byte* idctblock = new Byte[192];

	for(int y = 0; y < h; y+=8){
		for(int x = 0; x < w; x+=8){
			for(int yy= 0; yy < 8; yy++){
				for(int xx = 0; xx < 8; xx++){
					int src = ((y + yy)*w + (x + xx))*3;
					int dest = (yy*8 + xx)*3;
					tblock[dest] = (st[src]-offset)*q;
					tblock[dest + 1] = (st[src + 1]-offset)*q;  
					tblock[dest + 2] = (st[src + 2]-offset)*q;  
				}
			}

			doIDCT(tblock, idctblock);
			
			for(int yy= 0; yy < 8; yy++){
				for(int xx = 0; xx < 8; xx++){
					int dest = ((y + yy)*w + (x + xx))*3;
					int src = (yy*8 + xx)*3;
					imgd[dest]  = idctblock[src];					
					imgd[dest + 1] = idctblock[src + 1];					
					imgd[dest + 2] = idctblock[src + 2];  					
				}
			}
		}
	}
		
	delete[] tblock;
	delete[] idctblock;
	drawImage(&workingImage, nextStart);		
}
示例#20
0
void gameOver(Outcome outcome, int score) {
    char* s = "";
    char buffer[39];
    switch (outcome) {
        case WIN:
            s = "You win! :D";
            break;
        case LOSE:
            s = "You lost. :(";
            break;
    }
    sprintf(buffer, "Score: %d", score);
    waitForVblank();
    drawImage(EnemyFleet);
    waitForVblank();
    drawString(30, 10, "GAME OVER", RED);
    drawString(50, 10, s, YELLOW);
    drawString(70, 10, buffer, YELLOW);
    drawString(90, 10, "Press Start to play again.", YELLOW);
    while (!KEY_DOWN_NOW(BUTTON_START));
    while (KEY_DOWN_NOW(BUTTON_START));
}
示例#21
0
LRESULT CALLBACK WindowF(HWND hwnd, UINT message, WPARAM wParam,
                         LPARAM lParam)
{
    HDC hdc;
    PAINTSTRUCT ps;
    int x, y;

    switch (message)
    {
    case WM_CREATE:
        hdc = GetDC(hwnd);
        initialize(hwnd, hdc);
        ReleaseDC(hwnd, hdc);
        break;

    case WM_COMMAND:
        processCommand(LOWORD(wParam), hwnd);
        break;

    case WM_LBUTTONDOWN:
        x = LOWORD(lParam);
        y = HIWORD(lParam);
        processLeftButtonDown(hwnd, x, y);
        break;

    case WM_PAINT:
        hdc = BeginPaint(hwnd, &ps);
        drawImage(hdc);
        EndPaint(hwnd, &ps);
        break;

    case WM_DESTROY:
        cleanup();
        PostQuitMessage(0);
        break;
    }
    // Call the default window handler
    return DefWindowProc(hwnd, message, wParam, lParam);
}
示例#22
0
void UITextEdit::drawSelf(Fw::DrawPane drawPane)
{
    if((drawPane & Fw::ForegroundPane) == 0)
        return;

    drawBackground(m_rect);
    drawBorder(m_rect);
    drawImage(m_rect);
    drawIcon(m_rect);

    //TODO: text rendering could be much optimized by using vertex buffer or caching the render into a texture

    int textLength = m_text.length();
    const TexturePtr& texture = m_font->getTexture();

    g_painter->setColor(m_color);
    for(int i=0;i<textLength;++i)
        g_painter->drawTexturedRect(m_glyphsCoords[i], texture, m_glyphsTexCoords[i]);

    // render cursor
    if(isExplicitlyEnabled() && isActive() && m_cursorPos >= 0) {
        assert(m_cursorPos <= textLength);
        // draw every 333ms
        const int delay = 333;
        int elapsed = g_clock.millis() - m_cursorTicks;
        if(elapsed <= delay) {
            Rect cursorRect;
            // when cursor is at 0 or is the first visible element
            if(m_cursorPos == 0 || m_cursorPos == m_startRenderPos)
                cursorRect = Rect(m_drawArea.left()-1, m_drawArea.top(), 1, m_font->getGlyphHeight());
            else
                cursorRect = Rect(m_glyphsCoords[m_cursorPos-1].right(), m_glyphsCoords[m_cursorPos-1].top(), 1, m_font->getGlyphHeight());
            g_painter->drawFilledRect(cursorRect);
        } else if(elapsed >= 2*delay) {
            m_cursorTicks = g_clock.millis();
        }
    }
}
示例#23
0
static void
animateAnemone(struct state *st, Drawable curr_window)
{
  int i;
  double sint = sin(st->turn),cost = cos(st->turn);

  st->aCurr = st->appD;
  for (i = 0; i< st->arms; i++) {
    st->vCurr = st->vPendage + (st->finpoints + 1) * i;
    if (RND(25)<st->aCurr->rate) {
      if (st->aCurr->growth<0) {
	st->aCurr->numpt -= st->aCurr->numpt>1;
	if (!(++st->aCurr->growth)) st->aCurr->growth = RND(st->finpoints - st->aCurr->numpt) + 1;
      }
    }
    drawImage(st, curr_window, sint, cost);
    st->turn += st->turndelta;
    st->aCurr++;
  }
  createPoints(st);

  if (st->turn >= TWO_PI) st->turn -= TWO_PI;
}
示例#24
0
/**
 * Draws image.
 */
void RS_PainterQt::drawImg(QImage& img, const RS_Vector& pos,
                           double angle, const RS_Vector& factor) {
    save();

    // Render smooth only at close zooms
    if (factor.x < 1 || factor.y < 1) {
       RS_PainterQt::setRenderHint(SmoothPixmapTransform , true);
    }
    else {
      RS_PainterQt::setRenderHint(SmoothPixmapTransform);
    }

    QMatrix wm;
    wm.translate(pos.x, pos.y);
    wm.rotate(RS_Math::rad2deg(-angle));
    wm.scale(factor.x, factor.y);
    setWorldMatrix(wm);


    drawImage(0,-img.height(), img);

    restore();
}
示例#25
0
bool MYDISP::drawImage(char * name, int x, int y) {
	HBMP	hbmp;

	if ((hbmp = mtds.LoadBitmap(name)) == 0) {
		/* Unable to load the bitmap.
		*/
#if !defined(__SIM__)
#if defined(__MTDSTRACE__)
		Serial.print("!drawImage ");
		Serial.println(mtds.GetLastError(), HEX);
#endif
#endif
		return false;
	}

	/* We loaded the bitmap successfully. Get its dimensions and then blt it
	** to the display at the requested location.
	*/
	drawImage(hbmp, x, y);
	mtds.DestroyBitmap(hbmp);

	return true;

}
示例#26
0
void

	drawCircle(

		IImage* dst,

		const core::position2di& center,

		s32 radius,

		const SColor& color,

		s32 border,

		bool blend)

{
	if (!dst)
		return;

	if ( radius < 0 )
		return;

	else if ( radius == 0 )
	{
		drawPixel( dst, center.X, center.Y, color, blend);
	}
	else if (radius == 1)
	{
		if (border==0)
		{
			drawPixel( dst, center.X,center.Y,color,blend);
		}
		drawPixel( dst, center.X-1,center.Y,color,blend);
		drawPixel( dst, center.X,center.Y-1,color,blend);
		drawPixel( dst, center.X,center.Y+1,color,blend);
		drawPixel( dst, center.X+1,center.Y,color,blend);
	}
	else if (radius == 2)
	{
		if (border==0)
		{
		drawPixel( dst, center.X-1,center.Y+1,color,blend);
		drawPixel( dst, center.X-1,center.Y,color,blend);
		drawPixel( dst, center.X,center.Y+1,color,blend);
		drawPixel( dst, center.X,center.Y,color,blend);
		}

		drawPixel( dst, center.X-2,center.Y+1,color,blend);
		drawPixel( dst, center.X-2,center.Y,  color,blend);
		drawPixel( dst, center.X-1,center.Y+2,color,blend);
		drawPixel( dst, center.X-1,center.Y-1,color,blend);
		drawPixel( dst, center.X,  center.Y+2,color,blend);
		drawPixel( dst, center.X,  center.Y-1,color,blend);
		drawPixel( dst, center.X+1,center.Y+1,color,blend);
		drawPixel( dst, center.X+1,center.Y,  color,blend);
	}
	else
	{
		// 'Bresenham' Algorithmus (Achtelkreis Symmetrie)
		// ohne Trigonometrische- und Wurzel-Funktionen
		// und Spiegelung auf Restliche 7/8

		if (border==0) // filled
		{
			s32 i,j,F;
			i = 0;
			j = radius;
			F = 1 - radius;

			while (i < j)
			{
				++i;
				if (F < 0)
				{
					F += (i<<1) - 1;
				}
				else
				{
					F += ((i - j)<<1);
					--j;
				}

				// Verbesserungen by Benjamin Hampe (c) 2012
				drawLine( dst, center.X-i, center.Y+j-1, center.X+i-1,center.Y+j-1, color, blend );
				drawLine( dst, center.X-j, center.Y+i-1, center.X+j-1,center.Y+i-1, color, blend );
				drawLine( dst, center.X-j, center.Y-i, center.X+j-1, center.Y-i, color, blend );
				drawLine( dst, center.X-i, center.Y-j, center.X+i-1, center.Y-j, color, blend );
			}
		}

		// 'Bresenham' Algorithmus (Achtelkreis Symmetrie)
		// ohne Trigonometrische- und Wurzel-Funktionen
		// und Spiegelung auf Restliche 7/8

		else if (border == 1)
		{
			s32 i,j,F;
			i = 0;
			j = radius;
			F = 1 - radius;

			while (i < j)
			{
				++i;
				if (F < 0)
				{
					F += (i<<1) - 1;
				}
				else
				{
					F += ((i - j)<<1);
					--j;
				}
				// Verbesserungen by Benjamin Hampe (c) 2012
				drawPixel( dst, center.X+i-1,center.Y-j,color, blend); // 1st quadrant
				drawPixel( dst, center.X+j-1,center.Y-i,color, blend); // 1st quadrant
				drawPixel( dst, center.X+i-1,center.Y+j-1,color, blend); // 2nd quadrant
				drawPixel( dst, center.X+j-1,center.Y+i-1,color, blend); // 2nd quadrant
				drawPixel( dst, center.X-i,center.Y+j-1,color, blend); // 3rd quadrant
				drawPixel( dst, center.X-j,center.Y+i-1,color, blend); // 3rd quadrant
				drawPixel( dst, center.X-i,center.Y-j,color, blend); // 4th quadrant
				drawPixel( dst, center.X-j,center.Y-i,color, blend); // 4th quadrant
			}
		}

		// by Benjamin Hampe
		// create circle from undistorted temporary image

		else if (border > 1)
		{
			if (radius - border > 1)
			{
				IImage* tmp = new CImage( dst->getColorFormat(), core::dimension2du( radius<<1, radius<<1) );
				if (!tmp)
					return;

//				tmp->enableColorKey();
				tmp->fill( 0 );
				drawCircle( tmp, core::position2di(radius,radius), radius, color, 0, blend);
				drawCircle( tmp, core::position2di(radius,radius), radius - border, 0, 0, blend);
				drawImage( tmp, dst, center - core::position2di(radius,radius), tmp->getDimension(), true, false);
				tmp->drop();
			}
		}
	}
}
示例#27
0
文件: draw.cpp 项目: chrisws/scummvm
void AGOSEngine::animateSprites() {
	VgaSprite *vsp;
	VgaPointersEntry *vpe;

	if (_copyScnFlag) {
		_copyScnFlag--;
		_vgaSpriteChanged++;
	}

	if (getGameType() == GType_ELVIRA1 || getGameType() == GType_ELVIRA2) {
		const uint8 var = (getGameType() == GType_ELVIRA1) ? 293 : 71;
		if (_wallOn && !_variableArray[var]) {
			_wallOn--;

			VC10_state state;
			state.srcPtr = getBackGround() + 3 * _backGroundBuf->pitch + 3 * 16;
			state.height = state.draw_height = 127;
			state.width = state.draw_width = 14;
			state.y = 0;
			state.x = 0;
			state.palette = 0;
			state.paletteMod = 0;
			state.flags = kDFNonTrans;

			_windowNum = 4;

			_backFlag = true;
			drawImage(&state);
			_backFlag = false;

			_vgaSpriteChanged++;
		}
	}

	if (!_scrollFlag && !_vgaSpriteChanged) {
		return;
	}

	_vgaSpriteChanged = 0;

	if (_paletteFlag == 2)
		_paletteFlag = 1;

	if (getGameType() == GType_SIMON2 && _scrollFlag) {
		scrollScreen();
	}

	if (getGameType() == GType_SIMON1 || getGameType() == GType_SIMON2) {
		dirtyClips();
	}

	restoreBackGround();

	vsp = _vgaSprites;
	for (; vsp->id !=0; vsp++) {
		if ((getGameType() == GType_SIMON1 || getGameType() == GType_SIMON2) &&
			!(vsp->windowNum & 0x8000)) {
			continue;
		}

		vsp->windowNum &= ~0x8000;

		vpe = &_vgaBufferPointers[vsp->zoneNum];
		_curVgaFile1 = vpe->vgaFile1;
		_curVgaFile2 = vpe->vgaFile2;
		_curSfxFile = vpe->sfxFile;
		_windowNum = vsp->windowNum;
		_vgaCurSpriteId = vsp->id;

		saveBackGround(vsp);

		drawImage_init(vsp->image, vsp->palette, vsp->x, vsp->y, vsp->flags);
	}

	if (getGameType() == GType_ELVIRA1 && _variableArray[293]) {
		// Used by the Fire Wall and Ice Wall spells
		debug(0, "Using special wall");

		uint8 color, h, len;
		byte *dst = (byte *)_window4BackScn->pixels;

		color = (_variableArray[293] & 1) ? 13 : 15;
		_wallOn = 2;

		h = 127;
		while (h) {
			len = 112;
			while (len--) {
				*dst++ = color;
				dst++;
			}

			h--;
			if (h == 0)
				break;

			len = 112;
			while (len--) {
				dst++;
				*dst++ = color;
			}
			h--;
		}

		_window4Flag = 1;
		setMoveRect(0, 0, 224, 127);
	} else if (getGameType() == GType_ELVIRA2 && _variableArray[71] & 2) {
		// Used by the Unholy Barrier spell
		uint8 color, h, len;
		byte *dst = (byte *)_window4BackScn->pixels;

		color = 1;
		_wallOn = 2;

		h = 43;
		while (h) {
			len = 56;
			while (len--) {
				*dst++ = color;
				dst += 3;
			}

			h--;
			if (h == 0)
				break;

			dst += 448;

			len = 56;
			while (len--) {
				dst += 2;
				*dst++ = color;
				dst += 1;
			}
			dst += 448;
			h--;
		}

		_window4Flag = 1;
		setMoveRect(0, 0, 224, 127);
	}

	if (_window6Flag == 1)
		_window6Flag++;

	if (_window4Flag == 1)
		_window4Flag++;

	_displayFlag++;
}
示例#28
0
void imgLabel::setPos(DPT::txtposition pos)
{
    currPos = pos;
    drawImage();
}
示例#29
0
void GraphicsContext::drawImage(Image* image, ColorSpace styleColorSpace, const IntRect& dest, const IntRect& srcRect, CompositeOperator op, bool useLowQualityScale)
{
    drawImage(image, styleColorSpace, FloatRect(dest), srcRect, op, useLowQualityScale);
}
示例#30
0
void GraphicsContext::drawImage(Image* image, ColorSpace styleColorSpace, const IntPoint& dest, const IntRect& srcRect, CompositeOperator op)
{
    drawImage(image, styleColorSpace, IntRect(dest, srcRect.size()), srcRect, op);
}