Exemple #1
0
void
Camera::click(Scene* pScene, Image* pImage)
{
    calcLookAt();
    static bool firstRayTrace = false;

    if (m_renderer == RENDER_OPENGL)
    {
        glDrawBuffer(GL_BACK);
        pScene->openGL(this);
        firstRayTrace = true;
    }
    else if (m_renderer == RENDER_RAYTRACE)
    {
        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();

        glDrawBuffer(GL_FRONT);
        if (firstRayTrace)
        {
            pImage->clear(bgColor());
            pScene->raytraceImage(this, g_image);
            firstRayTrace = false;
        }
        
        g_image->draw();
    }
}
Exemple #2
0
void Cell::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
    if(!stitch())
        return;

    QColor clr = bgColor();
    if(!clr.isValid())
        clr = QColor(Qt::white);

    if(clr != Qt::white)
        painter->fillRect(option->rect, clr);
    if(mHighlight)
        painter->fillRect(option->rect, option->palette.highlight());

    if(stitch()->isSvg()) {
        QGraphicsSvgItem::paint(painter, option, widget);
    } else {
        painter->drawPixmap(option->rect.x(), option->rect.y(), *(stitch()->renderPixmap()));

         if(option->state & QStyle::State_Selected) {
            painter->setPen(Qt::DashLine);
            painter->drawRect(option->rect);
            painter->setPen(Qt::SolidLine);
        }
    }
}
Exemple #3
0
void Graphic::drawCell (int y, int x, int val) {

    sf::Color borderColor(101, 123, 131);
    sf::Color bgColor(88, 110, 117);
    sf::Color textColor(238, 232, 213);

    sf::RectangleShape square(sf::Vector2f(100, 100));

    square.setOutlineColor(borderColor);
    square.setOutlineThickness(2);
    square.setFillColor(bgColor);
    square.setPosition(x * 110 + 100 + 10, y * 110 + 10);
    this->_win->draw(square);

    // text
    std::string valStr = std::to_string(val);
    sf::Text    text(valStr, this->_font);
    sf::Text    shadow(valStr, this->_font);
    int         textX = static_cast<int>(x * 110 + 100 + 10 + 50 - text.getLocalBounds().width / 2);
    int         textY = y * 110 + 10 + 30;

    text.setCharacterSize(30);
    shadow.setCharacterSize(30);
    text.setColor(textColor);
    shadow.setColor(sf::Color(7, 54, 66));
    text.setPosition(textX, textY);
    shadow.setPosition(textX, textY + 2);
    this->_win->draw(shadow);
    this->_win->draw(text);
}
Exemple #4
0
//! Picks random colors for foreground and backgound on the dialog box.  Tries to pick contrasting colors
//! so the text remains visible.
void PoppyUpper::setRandomColors()
{
  // pick random foreground/background colors (but not the same foreground and background!)
  // color vector has CSScolors.size() elements, so indexes are zero to size()-1
  Randoid colorRandThing(0, CSSColors.size() - 1);

  unsigned int bgInd = colorRandThing.getRand();
  QString backgroundColorStr = CSSColors[bgInd];

  unsigned int textInd = colorRandThing.getRand();
  QString textColorStr = CSSColors[textInd];

  // Make sure they're not the same and have suitable contrast
  // we'll try using the lightness value from the HSL representation of the color,
  // and make sure they differ by at least 125
  QColor bgColor(backgroundColorStr);
  QColor txtColor(textColorStr);

  while (abs(bgColor.lightness() - txtColor.lightness()) < 125)
  {
      textInd = colorRandThing.getRand();
      textColorStr = CSSColors[textInd];
      txtColor = QColor(textColorStr);
  }

  QPalette thePalette;

  thePalette.setColor(QPalette::Window, backgroundColorStr);
  thePalette.setColor(QPalette::WindowText, textColorStr);
  thePalette.setColor(QPalette::Text, textColorStr);

  setPalette(thePalette);

}
Exemple #5
0
void BookmarkView::updateTheme() {
    wxColour bgColor(ThemeMgr::mgr.currentTheme->generalBackground);
    wxColour textColor(ThemeMgr::mgr.currentTheme->text);
    wxColour btn(ThemeMgr::mgr.currentTheme->button);
    wxColour btnHl(ThemeMgr::mgr.currentTheme->buttonHighlight);
    
    SetBackgroundColour(bgColor);

    m_treeView->SetBackgroundColour(bgColor);
    m_treeView->SetForegroundColour(textColor);
    
    m_propPanel->SetBackgroundColour(bgColor);
    m_propPanel->SetForegroundColour(textColor);

    m_buttonPanel->SetBackgroundColour(bgColor);
    m_buttonPanel->SetForegroundColour(textColor);
    
    m_labelLabel->SetForegroundColour(textColor);
    m_frequencyVal->SetForegroundColour(textColor);
    m_frequencyLabel->SetForegroundColour(textColor);
    m_bandwidthVal->SetForegroundColour(textColor);
    m_bandwidthLabel->SetForegroundColour(textColor);
    m_modulationVal->SetForegroundColour(textColor);
    m_modulationLabel->SetForegroundColour(textColor);
    
    refreshLayout();
}
void OGLSpotLight::Render(double time)
{
    glClear(GL_DEPTH_BUFFER_BIT);
    glm::vec3 bgColor(0.2f);
    glClearBufferfv(GL_COLOR, 0, &bgColor[0]);

    camera.Update();
    light.position = camera.GetPosition();
    light.direction = camera.GetForwardDirection();

    // Render container
    auto programMesh = programs[0];
    programMesh->Use();

    SendLightUniform(programMesh.get());

    glm::mat4 model = glm::mat4(1);
    for (size_t i = 0; i < 10; i++) {
        float sign = (i % 2) * 2 - 1.0f;
        model = glm::mat4(1);
        model = glm::rotate(model, i * 0.2f * glm::two_pi<float>(), glm::vec3(0, 1, 0)) *
                glm::translate(model, glm::vec3(20, 0, 20));

        model = glm::scale(glm::rotate(glm::translate(glm::mat4(1), cubePositions[i]), glm::radians(sign * 30.0f), cubePositions[i]), glm::vec3(10));
        SendMatricesUniform(programMesh.get(), model);
        vaos[0]->BindVAO();
        vbos[0]->BindVBO();
        textures[0]->BindTexture(GL_TEXTURE0);
        textures[1]->BindTexture(GL_TEXTURE3);
        glUniform1f(programMesh->GetUniform("material.shininess"), 32.0f);
        glDrawArrays(GL_TRIANGLES, 0, 36);
    }
}
QwtText RRPlotPicker::trackerText (const QPoint & pos) const
{
    QwtScaleMap xMap = this->plot()->canvasMap(d_xAxis);
    QwtScaleMap yMap = this->plot()->canvasMap(d_yAxis);

    const double x = xMap.invTransform(pos.x());
    const double y = yMap.invTransform(pos.y());


    QString str;
    if(isInited) {
        QDateTime dt;
        dt.setTime_t(baseDTime);

        str = dt.addSecs(x).time().toString();
    } else {
        str = "00:00:00";
    }
    QwtText text("( " + str + " , " + QString::number(y,'g', 10) + " ) ");


    QColor bgColor(Qt::transparent);
    //bgColor.setAlpha(160);
    text.setBackgroundBrush(QBrush(bgColor));
    return text;
}
	WebResponse* GetPreviewHandler::DrawFeature(FeatureClass* pFeatureClass, GetPreviewRequest* pRequest)
	{
		g_uint width  = pRequest->GetWidth();
		g_uint height = pRequest->GetHeight();

		Canvas* pCanvas = NULL;
		CartoFactory* pCartoFactory = augeGetCartoFactoryInstance();
		GLogger* pLogger = augeGetLoggerInstance();

		Style* pStyle = NULL;
		FeatureLayer* pFeatureLayer = NULL;
		CartoManager* pCartoManager = augeGetCartoManagerInstance();
		StyleFactory* pStyleFactory = augeGetStyleFactoryInstance();

		pFeatureLayer = pCartoFactory->CreateFeatureLayer();
		pFeatureLayer->SetFeatureClass(pFeatureClass);
		//pFeatureClass->AddRef();

		GField* pField = pFeatureClass->GetFields()->GetGeometryField();
		augeGeometryType type = pField->GetGeometryDef()->GeometryType();
		pStyle = pStyleFactory->CreateFeatureStyle(type);

		GColor bgColor(255,255,255,255);
		pCanvas = pCartoFactory->CreateCanvas2D(width, height);
		pCanvas->DrawBackground(bgColor);

		GEnvelope extent = pRequest->GetExtent();
		if(extent.IsValid())
		{
			pCanvas->SetViewer(extent);
		}
		else
		{
			pCanvas->SetViewer(pFeatureClass->GetExtent());
		}
		//pCanvas->SetViewer(extent.IsValid() ? extent : pFeatureClass->GetExtent());
		
		pCanvas->DrawLayer(pFeatureLayer, pStyle);

		char img_sfix[AUGE_EXT_MAX] = {0};
		//char img_name[AUGE_NAME_MAX] = {0};
		char img_path[AUGE_PATH_MAX] = {0};
		auge_get_image_suffix(pRequest->GetMimeType(), img_sfix, AUGE_EXT_MAX);
		//auge_generate_uuid(img_name, AUGE_NAME_MAX);
		WebContext* pWebContext = augeGetWebContextInstance();
		//const char* cache_path = "E:\\Research\\Auge.GIS\\Dist\\32_x86_win_vc10\\binD\\cache\\map";//pWebContext->GetCacheMapPath();
		const char* uuid = pFeatureClass->GetUUID();
		auge_make_path(img_path, NULL, pWebContext->GetCacheMapPath(), pFeatureClass->GetUUID(), img_sfix);
		pCanvas->Save(img_path);
		pCanvas->Release();
		GetPreviewResponse* pMapResponse = new GetPreviewResponse(pRequest);
		pMapResponse->SetPath(img_path);

		pStyle->Release();
		pFeatureLayer->Release();

		return pMapResponse;
	}
Exemple #9
0
void CPanelMessages::OnEraseBackground(wxEraseEvent& event){
    CSkinSimple* pSkinSimple = wxGetApp().GetSkinManager()->GetSimple();
    
    wxASSERT(pSkinSimple);
    wxASSERT(wxDynamicCast(pSkinSimple, CSkinSimple));

    wxMemoryDC memDC;
    wxCoord w, h, x, y;

    // Get the desired background bitmap
    wxBitmap bmp(*pSkinSimple->GetDialogBackgroundImage()->GetBitmap());

    // Dialog dimensions
    wxSize sz = GetClientSize();

    // Create a buffered device context to reduce flicker
    wxBufferedDC dc(event.GetDC(), sz, wxBUFFER_CLIENT_AREA);

    // bitmap dimensions
    w = bmp.GetWidth();
    h = bmp.GetHeight();

#if TEST_BACKGROUND_WITH_MAGENTA_FILL
    // Fill the dialog with a magenta color so people can detect when something
    //   is wrong
    dc.SetBrush(wxBrush(wxColour(255,0,255)));
    dc.SetPen(wxPen(wxColour(255,0,255)));
    dc.DrawRectangle(0, 0, sz.GetWidth(), sz.GetHeight());
#else
    wxColour bgColor(*pSkinSimple->GetDialogBackgroundImage()->GetBackgroundColor());
    SetBackgroundColour(bgColor);
#endif

    // Is the bitmap smaller than the window?
    if ( (w < sz.x) || (h < sz.y) ) {
        // Check to see if they need to be rescaled to fit in the window
        wxImage img = bmp.ConvertToImage();
        img.Rescale((int) sz.x, (int) sz.y);

        // Draw our cool background (centered)
        dc.DrawBitmap(wxBitmap(img), 0, 0);
    } else {
        // Snag the center of the bitmap and use it
        //   for the background image
        x = wxMax(0, (w - sz.x)/2);
        y = wxMax(0, (h - sz.y)/2);

        // Select the desired bitmap into the memory DC so we can take
        //   the center chunk of it.
        memDC.SelectObject(bmp);

        // Draw the center chunk on the window
        dc.Blit(0, 0, w, h, &memDC, x, y, wxCOPY);

        // Drop the bitmap
        memDC.SelectObject(wxNullBitmap);
    }
}
Exemple #10
0
void BookmarkView::onTreeEndDrag( wxTreeEvent& event ) {

    wxColour bgColor(ThemeMgr::mgr.currentTheme->generalBackground);
    wxColour textColor(ThemeMgr::mgr.currentTheme->text);
    
    m_treeView->SetBackgroundColour(bgColor);
    m_treeView->SetForegroundColour(textColor);
    m_treeView->UnsetToolTip();

    SetCursor(wxCURSOR_ARROW);

    if (visualDragItem != nullptr) {
        visualDragItem->Destroy();
        delete visualDragItem;
        visualDragItem = nullptr;
    }
    
    if (!event.GetItem()) {
        event.Veto();
        return;
    }

    TreeViewItem* tvi = dynamic_cast<TreeViewItem*>(m_treeView->GetItemData(event.GetItem()));

    if (!tvi) {
        if (event.GetItem() == bookmarkBranch) {
            if (dragItem && dragItem->type == TreeViewItem::TREEVIEW_ITEM_TYPE_ACTIVE) {
                doBookmarkActive(BOOKMARK_VIEW_STR_UNNAMED, dragItem->demod);
            } else if (dragItem && dragItem->type == TreeViewItem::TREEVIEW_ITEM_TYPE_RECENT) {
                doBookmarkRecent(BOOKMARK_VIEW_STR_UNNAMED, dragItem->bookmarkEnt);
            } else if (dragItem && dragItem->type == TreeViewItem::TREEVIEW_ITEM_TYPE_BOOKMARK) {
                doMoveBookmark(dragItem->bookmarkEnt, BOOKMARK_VIEW_STR_UNNAMED);
            }
        }
        return;
    }
    
    if (tvi->type == TreeViewItem::TREEVIEW_ITEM_TYPE_GROUP) {
        if (dragItem && dragItem->type == TreeViewItem::TREEVIEW_ITEM_TYPE_ACTIVE) { // Active -> Group Item
            doBookmarkActive(tvi->groupName, dragItem->demod);
        } else if (dragItem && dragItem->type == TreeViewItem::TREEVIEW_ITEM_TYPE_RECENT) { // Recent -> Group Item
            doBookmarkRecent(tvi->groupName, dragItem->bookmarkEnt);
            m_treeView->Delete(dragItemId);
        } else if (dragItem && dragItem->type == TreeViewItem::TREEVIEW_ITEM_TYPE_BOOKMARK) { // Bookmark -> Group Item
            doMoveBookmark(dragItem->bookmarkEnt, tvi->groupName);
        }
    } else if (tvi->type == TreeViewItem::TREEVIEW_ITEM_TYPE_BOOKMARK) {
        if (dragItem && dragItem->type == TreeViewItem::TREEVIEW_ITEM_TYPE_ACTIVE) { // Active -> Same Group
            doBookmarkActive(tvi->groupName, dragItem->demod);
        } else if (dragItem && dragItem->type == TreeViewItem::TREEVIEW_ITEM_TYPE_RECENT) { // Recent -> Same Group
            doBookmarkRecent(tvi->groupName, dragItem->bookmarkEnt);
            m_treeView->Delete(dragItemId);
        } else if (dragItem && dragItem->type == TreeViewItem::TREEVIEW_ITEM_TYPE_BOOKMARK) { // Bookmark -> Same Group
            doMoveBookmark(dragItem->bookmarkEnt, tvi->groupName);
        }
    }
}
void OGLIndexedDraw::Render(double time)
{
    glm::vec4 bgColor(0.32f, 0.61f, 1.0f, 1.0f);
	glClear(GL_DEPTH_BUFFER_BIT);
    glClearBufferfv(GL_COLOR, 0, &bgColor[0]);

	glUniform1f(hDivLocation, heightDivider);

    glDrawElements(GL_TRIANGLE_STRIP, (int)indices.size(), GL_UNSIGNED_SHORT, nullptr);
}
void KisCanvasResourceProvider::slotCanvasResourceChanged(int key, const QVariant & res)
{
    if(key == KoCanvasResourceManager::ForegroundColor || key == KoCanvasResourceManager::BackgroundColor) {
        KoAbstractGradient* resource = KoResourceServerProvider::instance()->gradientServer()->resources()[0];
        KoStopGradient* stopGradient = dynamic_cast<KoStopGradient*>(resource);
        if(stopGradient) {
            QList<KoGradientStop> stops;
            stops << KoGradientStop(0.0, fgColor()) << KoGradientStop(1.0, bgColor());
            stopGradient->setStops(stops);
            KoResourceServerProvider::instance()->gradientServer()->updateResource(resource);
        }
        resource = KoResourceServerProvider::instance()->gradientServer()->resources()[1];
        stopGradient = dynamic_cast<KoStopGradient*>(resource);
        if(stopGradient) {
            QList<KoGradientStop> stops;
            stops << KoGradientStop(0.0, fgColor()) << KoGradientStop(1.0,  KoColor(QColor(0, 0, 0, 0), fgColor().colorSpace()));
            stopGradient->setStops(stops);
            KoResourceServerProvider::instance()->gradientServer()->updateResource(resource);
        }
    }
    switch (key) {
    case(KoCanvasResourceManager::ForegroundColor):
        m_fGChanged = true;
        emit sigFGColorChanged(res.value<KoColor>());
        break;
    case(KoCanvasResourceManager::BackgroundColor):
        emit sigBGColorChanged(res.value<KoColor>());
        break;
    case(CurrentPattern):
        emit sigPatternChanged(static_cast<KisPattern *>(res.value<void *>()));
        break;
    case(CurrentGeneratorConfiguration):
        emit sigGeneratorConfigurationChanged(static_cast<KisFilterConfiguration*>(res.value<void*>()));
    case(CurrentGradient):
        emit sigGradientChanged(static_cast<KoAbstractGradient *>(res.value<void *>()));
        break;
    case(CurrentPaintOpPreset):
        emit sigPaintOpPresetChanged(currentPreset());
        break;
    case(CurrentKritaNode) :
        emit sigNodeChanged(currentNode());
        break;
    case(CurrentCompositeOp) :
        emit sigCompositeOpChanged(currentCompositeOp());
        break;
    case (Opacity):
    {
        emit sigOpacityChanged(res.toDouble());
    }
    default:
        ;
        // Do nothing
    };
}
Exemple #13
0
void Ball::drawBall(QPainter* painter)
{
    // draw bg
    const QPoint center = rect().center();
    int radius = width() > height() ? height() / 2 : width() / 2;
    QRadialGradient bgColor(center, radius, QPoint(center.x(), center.y() - 5));

    if (_isInteractive && !_pressed) {
        QColor grayColor(176, 176, 176);
        bgColor.setColorAt(0.0, lighterColor(grayColor));
        bgColor.setColorAt(1.0, grayColor);
    } else {
        if (_type == Red) {
            switch (numberZone(_number)) {
            case 1:
                bgColor.setColorAt(0.0, lighterColor(Zone1Color));
                bgColor.setColorAt(1.0, Zone1Color);
                break;

            case 2:
                bgColor.setColorAt(0.0, lighterColor(Zone2Color));
                bgColor.setColorAt(1.0, Zone2Color);
                break;

            case 3:
                bgColor.setColorAt(0.0, lighterColor(Zone3Color));
                bgColor.setColorAt(1.0, Zone3Color);
                break;
            }

        } else {
            QColor blueColor(0, 162, 245);
            bgColor.setColorAt(0.0, lighterColor(blueColor));
            bgColor.setColorAt(1.0, blueColor);
        }
    }

    painter->setBrush(bgColor);
    painter->setPen(Qt::NoPen);
    painter->drawEllipse(center, radius - 1, radius - 1);

    // draw text
    painter->setRenderHints(QPainter::TextAntialiasing);
    if ((_isInteractive && !_pressed) ||(_type == Red && (numberZone(_number) == 3 || numberZone(_number) == 2)))
        painter->setPen(AlternateNumberColor);
    else
        painter->setPen(NumberColor);
    QFont f = painter->font();
    f.setBold(true);
    f.setPointSize(12);
    painter->setFont(f);
    painter->drawText(rect(), Qt::AlignVCenter | Qt::AlignHCenter, QString("%1").arg(_number));
}
Exemple #14
0
void PixelBufferClass::Clear(int which)
{
    xlColor bgColor(0, 0, 0, 0);
    if (which != -1)
    {
        layers[which]->buffer.Clear(bgColor); //just clear this one
    }
    else
    {
        //clear them all
        for (size_t i = 0; i < numLayers; i++)
        {
            layers[i]->buffer.Clear(bgColor);
        }
    }
}
Exemple #15
0
Input::Input(Window & window):
	Label(window, "")
{
	textColor(DEFAULT_COLOR_TEXT);
	bgColor(DEFAULT_COLOR_INPUT_BG);
	position(0, 0);
	size(DEFAULT_INPUT_WIDTH, DEFAULT_INPUT_HEIGHT);
	showBg(true);
	layout(LayoutLeft, LayoutMiddle);
	padding(1, 3, 2, 2);
	_charLimit = 256;
	_bGrating = false;
	_asciiOnly = false;
	_passwdOnly = false;
	_passwdMaskChar = DEFAULT_PASSWORD_CHAR;
	SDL_SetTextInputRect(&_rc);
}
void Minitel::refreshSettings() {
  // Common parameters
  serialprint7(_currentMode);
  textColor(_currentTextColor);
  bgColor(_currentBgColor); // Only in graphic mode ?
  blink(_currentBlink);
  cursor(_currentShowCursor);
  // Graphic mode specific parameters
  if (_currentMode == GRAPHIC_MODE) {
    pixelate(_currentUnderline);
  }
  // Text mode specific parameters
  if (_currentMode == TEXT_MODE) {
    video(_currentVideo);
    charSize(_currentSize);
  }
}
Exemple #17
0
void BookmarkView::onTreeBeginDrag( wxTreeEvent& event ) {

    TreeViewItem* tvi = dynamic_cast<TreeViewItem*>(m_treeView->GetItemData(event.GetItem()));
    
    dragItem = nullptr;
    dragItemId = nullptr;

    SetCursor(wxCURSOR_CROSS);

    if (!tvi) {
        event.Veto();
        return;
    }
    
    bool bAllow = false;
    std::wstring dragItemName;
    
    if (tvi->type == TreeViewItem::TREEVIEW_ITEM_TYPE_ACTIVE) {
        bAllow = true;
        dragItemName = BookmarkMgr::getActiveDisplayName(tvi->demod);
    } else if (tvi->type == TreeViewItem::TREEVIEW_ITEM_TYPE_RECENT || tvi->type == TreeViewItem::TREEVIEW_ITEM_TYPE_BOOKMARK) {
        bAllow = true;
        dragItemName = BookmarkMgr::getBookmarkEntryDisplayName(tvi->bookmarkEnt);
    }
    
    if (bAllow) {
        wxColour bgColor(ThemeMgr::mgr.currentTheme->generalBackground);
        wxColour textColor(ThemeMgr::mgr.currentTheme->text);
        
        m_treeView->SetBackgroundColour(textColor);
        m_treeView->SetForegroundColour(bgColor);
//        m_treeView->SetToolTip("Dragging " + dragItemName);
        
        dragItem = tvi;
        dragItemId = event.GetItem();

        visualDragItem = new BookmarkViewVisualDragItem(dragItemName);
        
        event.Allow();
    } else {
        event.Veto();
    }
}
Exemple #18
0
Cell* Cell::copy(Cell *cell)
{
    Cell *c = 0;
    if(!cell)
        c = new Cell();
    else
        c = cell;

    c->setStitch(stitch());
    c->setBgColor(bgColor());
    c->setColor(c->color());
    c->setTransformOriginPoint(transformOriginPoint());
    c->setRotation(0);
    c->setTransform(QTransform());
	c->setTransformations(ChartItemTools::cloneGraphicsTransformations(this));
	foreach (QGraphicsTransform* t, transformations())
		t->setParent(parentObject());

    return c;
}
void VideoWaveformScopeWidget::refreshScope(const QSize& size, bool full)
{
    while (m_queue.count() > 0) {
        m_frame = m_queue.pop();
    }

    if (!full && m_refreshTime.elapsed() < 90) {
        // Limit refreshes to 90ms unless there is a good reason.
        return;
    }

    if (m_frame.is_valid() && m_frame.get_image_width() && m_frame.get_image_height()) {
        int columns = m_frame.get_image_width();
        if (m_renderImg.width() != columns) {
            m_renderImg = QImage(columns, 256, QImage::Format_ARGB32_Premultiplied);
        }
        QColor bgColor( 0, 0, 0 ,0 );
        m_renderImg.fill(bgColor);

        const uint8_t* yData = m_frame.get_image();

        for (int x = 0; x < columns; x++) {
            int pixels = m_frame.get_image_height();
            for (int j = 0; j < pixels; j++) {
                int y = 255 - (yData[j * columns + x]);
                QRgb currentVal = m_renderImg.pixel(x,y);
                if (currentVal < 0xffffffff) {
                    currentVal += 0x0f0f0f0f;
                    m_renderImg.setPixel(x, y, currentVal);
                }

            }
        }
    }

    m_mutex.lock();
    m_displayImg.swap(m_renderImg);
    m_mutex.unlock();

    m_refreshTime.restart();
}
void Graphics::drawScene() {
	D3DXCOLOR bgColor(0.1f, 0.1f, 0.3f, 0.0f);
	context->ClearRenderTargetView(renderTargetView, bgColor);
	context->ClearDepthStencilView(depthStencilView, D3D11_CLEAR_DEPTH | D3D11_CLEAR_STENCIL, 1.0f, 0);
	
	skyMapPass->draw();

	pass->draw();
	
	renderDepthPass->draw();
	shadowMapPass->draw();

//	normalMapPass->draw();

	debugPass->draw();

	instancesPass->draw();

	//Present the backbuffer to the screen
	swapChain->Present(0, 0);
}
Exemple #21
0
void RenderThemeWinCE::adjustMenuListButtonStyle(StyleResolver*, RenderStyle* style, Element*) const
{
    // These are the paddings needed to place the text correctly in the <select> box
    const int dropDownBoxPaddingTop    = 2;
    const int dropDownBoxPaddingRight  = style->direction() == LTR ? 4 + dropDownButtonWidth : 4;
    const int dropDownBoxPaddingBottom = 2;
    const int dropDownBoxPaddingLeft   = style->direction() == LTR ? 4 : 4 + dropDownButtonWidth;
    // The <select> box must be at least 12px high for the button to render nicely on Windows
    const int dropDownBoxMinHeight = 12;

    // Position the text correctly within the select box and make the box wide enough to fit the dropdown button
    style->setPaddingTop(Length(dropDownBoxPaddingTop, Fixed));
    style->setPaddingRight(Length(dropDownBoxPaddingRight, Fixed));
    style->setPaddingBottom(Length(dropDownBoxPaddingBottom, Fixed));
    style->setPaddingLeft(Length(dropDownBoxPaddingLeft, Fixed));

    // Height is locked to auto
    style->setHeight(Length(Auto));

    // Calculate our min-height
    int minHeight = style->fontMetrics().height();
    minHeight = max(minHeight, dropDownBoxMinHeight);

    style->setMinHeight(Length(minHeight, Fixed));

    // White-space is locked to pre
    style->setWhiteSpace(PRE);

    DWORD colorMenu = GetSysColor(COLOR_MENU);
    DWORD colorMenuText = GetSysColor(COLOR_MENUTEXT);
    Color bgColor(GetRValue(colorMenu), GetGValue(colorMenu), GetBValue(colorMenu), 255);
    Color textColor(GetRValue(colorMenuText), GetGValue(colorMenuText), GetBValue(colorMenuText), 255);
    if (bgColor == textColor)
        textColor.setRGB((~bgColor.rgb()) | 0xFF000000);
    style->clearBackgroundLayers();
    style->accessBackgroundLayers()->setClip(ContentFillBox);
    style->setBackgroundColor(bgColor);
    style->setColor(textColor);
}
Exemple #22
0
void PeriodicGrid::create()
{
    int r, g, b, color, period, group, intElement = 1;

    QColor bgColor(m_applet->palette().foreground().color());
    bgColor.darker();
    bgColor.getRgb(&r,&g,&b);

    foreach (ElementLabel * i, m_elementItemList) {
        delete i;
    }

    m_elementItemList.clear();

    int maxWidth = pseTables::instance()->getTabletype(m_psTableType)->tableSize().x();
    // a parameter for the linear function. y(x) = ax + b
    double a = 50 / (maxWidth / 2);

    foreach (intElement, pseTables::instance()->getTabletype(m_psTableType)->elements()) {
        if (intElement <= 112) {
            group = pseTables::instance()->getTabletype(m_psTableType)->elementCoords(intElement).x();
            period = pseTables::instance()->getTabletype(m_psTableType)->elementCoords(intElement).y();

            // makes a v-like color scheme
            color = period + (abs(group - maxWidth/2) * a);

            ElementLabel *element = new ElementLabel(intElement, m_applet);
            m_elementItemList.append(element);

            element->setTextBackgroundColor(QColor (r - color, g - color, b - color));

            connect (element, SIGNAL(ElementAction(QString)), m_applet, SLOT(appendElement(QString)));

            m_actualPeriodSystem->addItem (element, period, group);
        }
    }
}
Exemple #23
0
int main()
{
    std::string separator     = "\n----------------------------------------------\n";
    std::string separatorStar = "\n**********************************************\n";
    std::cout << separator << "RTIS - Ray Tracer for \"Imatge Sintetica\"" << separator << std::endl;

    // Create an empty film
    Film *film;
    film = new Film(720, 576);


    // Declare the shader
    Vector3D bgColor(0.0, 0.0, 0.0); // Background color (for rays which do not intersect anything)
    Vector3D intersectionColor(1,0,0);
    Shader *shader = new IntersectionShader (intersectionColor, bgColor);
	Shader *depthShader = new DepthShader(Vector3D(0.4, 1, 0.4), 8, bgColor);
	Shader *directShader = new DirectShader(Vector3D(0.4, 1, 0.4), 8, bgColor);

    // Declare pointers to all the variables which describe the scene
    Camera *cam;
    std::vector<Shape*> *objectsList;
    std::vector<PointLightSource> *lightSourceList = new std::vector<PointLightSource>;

    // Build the scene
    buildSceneSphere(cam, film, objectsList, lightSourceList);

    // Launch some rays!
    raytrace(cam, directShader, film, objectsList, lightSourceList);

    // Save the final result to file
    std::cout << "\n\nSaving the result to file output.bmp\n" << std::endl;
    film->save();

    std::cout << "\n\n" << std::endl;
    return 0;
}
Exemple #24
0
void DrawScene()
{
	//FONT STUFF             neeeeeeeeeeeeed
	//-----------------------------------
	UINT stride = sizeof(Vertex);
	UINT offset = 0;
	d3d11DevCon->IASetVertexBuffers(0, 2, &vertexBuffer, &stride, &offset);
	d3d11DevCon->VSSetShader(VS, NULL, 0);
	d3d11DevCon->PSSetShader(PS, NULL, 0);
	//---------------------------------------
				//Cleare den Backbuffer bevor irgendwas gezeichnet wird
				D3DXCOLOR bgColor(0.0f, 0.0f, 0.0f, 0.0f);
				d3d11DevCon->ClearRenderTargetView(renderTargetView, bgColor);

				//Setze DepthStencilView zurück
				d3d11DevCon->ClearDepthStencilView(depthStencilView, D3D11_CLEAR_DEPTH | D3D11_CLEAR_STENCIL, 1.0f, 0);

				// Default Render State
				d3d11DevCon->RSSetState(NULL);

				// Zeichne Objekte mit Backface Culling

				// No Culling Render State
				d3d11DevCon->RSSetState(noCull);

				// Zeichne den Ersten würfel
				WVP = cube1World*camView*camProjection;
				cbPerObj.WVP = XMMatrixTranspose(WVP);
				d3d11DevCon->UpdateSubresource(cbPerObjectBuffer, 0, NULL, &cbPerObj, 0, 0);
				d3d11DevCon->VSSetConstantBuffers(0, 1, &cbPerObjectBuffer);

				//Schicke Textur an Pixelshader
				d3d11DevCon->PSSetShaderResources(0, 1, &Texture);
				d3d11DevCon->PSSetSamplers(0, 1, &TexSamplerState);

				d3d11DevCon->DrawIndexed(36, 0, 0);

				// Zeichne den 2ten Würfel;
				WVP = cube2World*camView*camProjection;
				cbPerObj.WVP = XMMatrixTranspose(WVP);
				d3d11DevCon->UpdateSubresource(cbPerObjectBuffer, 0, NULL, &cbPerObj, 0, 0);
				d3d11DevCon->VSSetConstantBuffers(0, 1, &cbPerObjectBuffer);

				d3d11DevCon->PSSetShaderResources(0, 1, &Texture);
				d3d11DevCon->PSSetSamplers(0, 1, &TexSamplerState);

				d3d11DevCon->DrawIndexed(36, 0, 0);

	//Font Stuff ////////////neeeeeeeeeed
	//-----------------------------
	d3d11DevCon->VSSetShader(FONT_VS, 0, 0);
	d3d11DevCon->PSSetShader(FONT_PS, 0, 0);
	//d3d11DevCon->RSSetState(NULL);

	WVP = camProjection;
	cbPerObj.WVP = XMMatrixTranspose(WVP);
	d3d11DevCon->UpdateSubresource(cbPerObjectBuffer, 0, NULL, &cbPerObj, 0, 0);
	d3d11DevCon->VSSetConstantBuffers(0, 1, &cbPerObjectBuffer);

	d3d11DevCon->IASetVertexBuffers(0, 1, &fontVertexBuffer, &stride, &offset);
	d3d11DevCon->PSSetShaderResources(0, 1, &fontAtlas);
	d3d11DevCon->PSSetSamplers(0, 1, &fontAtlasSampler);
	DrawString("Matt, Meaghan, Nicole, & Tim", -0.95f, 0.65f);
	
	
				//----------------------------
					//Swap
					SwapChain->Present(0, 0);
}
void TaskDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
    {
        Task task;
        task.setName(index.data(Task::NameRole).toString());
        task.setDescription(index.data(Task::DescriptionRole).toString());
        task.setPriority(index.data(Task::PriorityRole).toInt());
        task.setDeadlineTime(index.data(Task::DeadlineRole).toDateTime());
        task.setCompleted(index.data(Task::CompleteStatusRole).toBool());
        task.setPrivate(index.data(Task::PrivateRole).toBool());
        task.setCreateDate(index.data(Task::CreatedRole).toDate());
        task.setRepeatType((Task::RepeatType)index.data(Task::RepeatRole).toInt());

        QImage priorityImage(task.priorityIcon());




        QColor taskTextColor;
        if (option.state & QStyle::State_Selected)
        {
            if (task.deadlineTime()<QDateTime::currentDateTime() && task.deadlineTime().isValid() && !task.completed())
            {
                QColor bgColor(255,65,204);
                QBrush brush(bgColor);



                painter->fillRect(option.rect, brush);

            } else
            QStyledItemDelegate::paint(painter, option, index);
        } else if (task.deadlineTime()<QDateTime::currentDateTime() && task.deadlineTime().isValid() && !task.completed())
        {
            QColor bgColor(255,91,91);
            QBrush brush(bgColor);

            painter->fillRect(option.rect, brush);
        }

        else {
            QBrush brush = (index.row()%2)?option.palette.base():option.palette.alternateBase();
            taskTextColor.setRgb(255-brush.color().red(),
                                 255-brush.color().green(),
                                 255-brush.color().blue());

            painter->fillRect(option.rect, brush);
            }
            painter->save();
            QFont taskFont = getTaskFont(option);
            QFont descriptionFont = getDescriptionFont(option);
            QFont dateFont = getDateFont(option);
            QFont timeFont = getTimeFont(option);

            QFontMetrics fmTaskFont(taskFont);
            QFontMetrics fmDescriptionFont(descriptionFont);
            QFontMetrics fmDateFont(dateFont);
            int dateWidth=fmDateFont.width(task.deadlineTime().date().toString(Qt::SystemLocaleShortDate));

            painter->setPen(Qt::black);

            painter->setFont(taskFont);
            QRect nameRect=option.rect.adjusted(priorityImage.width(),4, -dateWidth-10,0);
            painter->drawText(nameRect,Qt::AlignHCenter, fmTaskFont.elidedText(task.name(),Qt::ElideRight,nameRect.width()-70,0));


            QRect descriptionRect=option.rect.adjusted(priorityImage.width(),30,-dateWidth-10,0);
            painter->setFont(descriptionFont);

            painter->drawText(descriptionRect,Qt::AlignHCenter,
                              fmDescriptionFont.elidedText(task.description().replace("\n"," "),Qt::ElideRight,descriptionRect.width()));


            painter->drawImage(option.rect.adjusted(0,3,-(option.rect.width()-priorityImage.width()),-(option.rect.height()-priorityImage.height())),priorityImage);
            if (task.completed()%2==1)
            {
                QImage completeImage=QImage(":/icons/task-complete");
                painter->drawImage(option.rect.adjusted(10,10,-(option.rect.width()-priorityImage.width()+10),-(option.rect.height()-priorityImage.height())-10),completeImage);
            }
            if ((int)task.repeatType()>0)
            {
                QImage completeImage=QImage(":/icons/clock");
                painter->drawImage(option.rect.adjusted(priorityImage.width(),5,-(option.rect.width()-completeImage.width()),-(option.rect.height()-completeImage.height())),completeImage);
            }

            painter->setFont(dateFont);

            painter->drawText(option.rect.adjusted((option.rect.width()-dateWidth-10),8,0,0),Qt::AlignHCenter,task.deadlineTime().date().toString(Qt::SystemLocaleShortDate));

            painter->setFont(timeFont);
            painter->drawText(option.rect.adjusted((option.rect.width()-dateWidth-10),20,0,0),Qt::AlignHCenter,task.deadlineTime().time().toString(Qt::SystemLocaleShortDate));

            if (task.isPrivate() && !task.completed())
            {
                QImage privateImage(":/icons/private");
                painter->drawImage(option.rect.adjusted(10,10,-(option.rect.width()-priorityImage.width()+10),-(option.rect.height()-priorityImage.height())-10),privateImage);
            }
            painter->restore();

        }
}
Exemple #26
0
void VisPrefsDialog::on_bgColorButton_colorPicked( QColor color )
{
	QColor bgColor(color.red(), color.green(), color.blue());
	_vtkVisPipeline->setBGColor(bgColor);
}
void BackgroundFromLayer::onExecute()
{
  Layer* layer = this->layer();
  Sprite* sprite = layer->sprite();
  auto doc = static_cast<Doc*>(sprite->document());
  color_t bgcolor = doc->bgColor();

  // Create a temporary image to draw each cel of the new Background
  // layer.
  ImageRef bg_image(Image::create(sprite->pixelFormat(),
      sprite->width(),
      sprite->height()));

  CelList cels;
  layer->getCels(cels);
  for (Cel* cel : cels) {
    Image* cel_image = cel->image();
    ASSERT(cel_image);

    clear_image(bg_image.get(), bgcolor);
    render::composite_image(
      bg_image.get(), cel_image,
      sprite->palette(cel->frame()),
      cel->x(), cel->y(),
      MID(0, cel->opacity(), 255),
      static_cast<LayerImage*>(layer)->blendMode());

    // now we have to copy the new image (bg_image) to the cel...
    executeAndAdd(new cmd::SetCelPosition(cel, 0, 0));

    // change opacity to 255
    if (cel->opacity() < 255)
      executeAndAdd(new cmd::SetCelOpacity(cel, 255));

    // Same size of cel image and background image, we can just
    // replace pixels.
    if (bg_image->width() == cel_image->width() &&
        bg_image->height() == cel_image->height()) {
      executeAndAdd(new CopyRect(cel_image, bg_image.get(),
          gfx::Clip(0, 0, cel_image->bounds())));
    }
    // In other case we have to replace the whole image (this is the
    // most common case, a smaller transparent cel that is converted
    // to a canvas size cel in the background)
    else {
      ImageRef bg_image2(Image::createCopy(bg_image.get()));
      executeAndAdd(new cmd::ReplaceImage(sprite, cel->imageRef(), bg_image2));
    }
  }

  // Fill all empty cels with a flat image filled with bgcolor
  for (frame_t frame(0); frame<sprite->totalFrames(); ++frame) {
    Cel* cel = layer->cel(frame);
    if (!cel) {
      ImageRef cel_image(Image::create(sprite->pixelFormat(),
          sprite->width(), sprite->height()));
      clear_image(cel_image.get(), bgcolor);

      // Create the new cel and add it to the new background layer
      cel = new Cel(frame, cel_image);
      executeAndAdd(new cmd::AddCel(layer, cel));
    }
  }

  executeAndAdd(new cmd::ConfigureBackground(layer));
}
Exemple #28
0
void FlattenLayers::onExecute()
{
  Sprite* sprite = this->sprite();
  auto doc = static_cast<Doc*>(sprite->document());

  // Create a temporary image.
  ImageRef image(Image::create(sprite->pixelFormat(),
      sprite->width(),
      sprite->height()));

  LayerImage* flatLayer;  // The layer onto which everything will be flattened.
  color_t     bgcolor;    // The background color to use for flatLayer.

  flatLayer = sprite->backgroundLayer();
  if (flatLayer && flatLayer->isVisible()) {
    // There exists a visible background layer, so we will flatten onto that.
    bgcolor = doc->bgColor(flatLayer);
  }
  else {
    // Create a new transparent layer to flatten everything onto.
    flatLayer = new LayerImage(sprite);
    ASSERT(flatLayer->isVisible());
    executeAndAdd(new cmd::AddLayer(sprite->root(), flatLayer, nullptr));
    executeAndAdd(new cmd::SetLayerName(flatLayer, "Flattened"));
    bgcolor = sprite->transparentColor();
  }

  render::Render render;
  render.setBgType(render::BgType::NONE);

  // Copy all frames to the background.
  for (frame_t frame(0); frame<sprite->totalFrames(); ++frame) {
    // Clear the image and render this frame.
    clear_image(image.get(), bgcolor);
    render.renderSprite(image.get(), sprite, frame);

    // TODO Keep cel links when possible

    ImageRef cel_image;
    Cel* cel = flatLayer->cel(frame);
    if (cel) {
      if (cel->links())
        executeAndAdd(new cmd::UnlinkCel(cel));

      cel_image = cel->imageRef();
      ASSERT(cel_image);

      executeAndAdd(new cmd::CopyRect(cel_image.get(), image.get(),
          gfx::Clip(0, 0, image->bounds())));
    }
    else {
      cel_image.reset(Image::createCopy(image.get()));
      cel = new Cel(frame, cel_image);
      flatLayer->addCel(cel);
    }
  }

  // Delete old layers.
  LayerList layers = sprite->root()->layers();
  for (Layer* layer : layers)
    if (layer != flatLayer)
      executeAndAdd(new cmd::RemoveLayer(layer));
}
Exemple #29
0
std::vector<Vector3 *> Scene::traceLine(Camera const *cam, Image const *img, int j) const
{
    std::vector<Vector3 *> results(img->width());
    Ray ray;
    HitInfo hitInfo;
    Vector3 shadeResult;
    std::vector<float> refr_stack;
    std::vector<Vector3> colors(m_samples);
    for (int i = 0; i < img->width(); ++i)
    {
		for (int k = 0; k < m_samples; ++k)
		{
			ray = cam->eyeRay(i + (m_samples == 1 ? 0.5f : randone(g_rng) - 0.5f), j + (m_samples == 1 ? 0.5f : randone(g_rng) - 0.5f), img->width(), img->height());
			if (m_focus_length >= 0.f) // if depth of field enabled
			{
				Vector3 focal_point = ray.o + m_focus_length * ray.d;
				Vector3 view_dir = cam->viewDir();
				Vector3 d_vec(randone(g_rng) - 0.5f, randone(g_rng) - 0.5f, randone(g_rng) - 0.5f);
				d_vec.normalize();
				d_vec = view_dir.cross(d_vec);
					
				ray.o += d_vec * randone(g_rng) * m_lens;
				ray.d = focal_point - ray.o;
				ray.d.normalize();
			}

			refr_stack.clear();
			refr_stack.push_back(1.f);
			ray.refractionStack = &refr_stack;
			ray.refractionIndex = 0;
			if (!results[i])
				results[i] = new Vector3();
			if (trace(hitInfo, ray))
			{
				colors[k] = hitInfo.material->shade(ray, hitInfo, *this);
			}
			else
			{
				colors[k] = bgColor();
			}
			*results[i] += colors[k];
		}
		if (m_cutoffs > 0)
		{
			std::vector<int> biggest(m_cutoffs, -1);
			for (int c = 0; c < m_cutoffs; ++c)
			{
				if (biggest[0] == -1 || colors[c].length2() > colors[biggest[0]].length2())
				{
					biggest[0] = c;
					for (int k = 1; k < m_cutoffs; ++k)
					{
						if (biggest[k] == -1 || colors[biggest[k - 1]].length2() > colors[biggest[k]].length2())
							std::swap(biggest[k - 1], biggest[k]);
						else
							break;
					}
				}
			}
			for (int k = 0; k < m_cutoffs; ++k)
				*results[i] -= colors[biggest[k]];
		}
		if (results[i])
			*results[i] /= m_samples - m_cutoffs;
    }
    return results;
}
void Minitel::useDefaultColors() {
  bgColor(BLACK);
  textColor(WHITE); 
}