Esempio n. 1
0
/// Get the tiles colour
static inline void getColour(PIELIGHT *colour, int x, int y, bool center)
{
	MAPTILE *psTile;
	
	if (center)
	{
		PIELIGHT a,b,c,d;
		getColour(&a, x  , y  , false);
		getColour(&b, x+1, y  , false);
		getColour(&c, x  , y+1, false);
		getColour(&d, x+1, y+1, false);
		averageColour(colour, a, b, c, d);
		return;
	}
	
	*colour = WZCOL_BLACK;
	if (x < 0 || y < 0 || x > mapWidth - 1 || y > mapHeight - 1)
	{
		return;
	}
	psTile = mapTile(x, y);
	*colour = psTile->colour;

	if (psTile->tileInfoBits & BITS_GATEWAY && showGateways)
	{
		colour->byte.g = 255;
	}
}
Esempio n. 2
0
void AppearanceSettings::applyToCodeEditor (CodeEditorComponent& editor) const
{
    CodeEditorComponent::ColourScheme cs (editor.getColourScheme());

    for (int i = cs.types.size(); --i >= 0;)
    {
        CodeEditorComponent::ColourScheme::TokenType& t = cs.types.getReference(i);
        getColour (t.name, t.colour);
    }

    editor.setColourScheme (cs);
    editor.setFont (getCodeFont());

    for (int i = 0; i < AppearanceColours::numColours; ++i)
    {
        if (AppearanceColours::colours[i].applyToEditorOnly)
        {
            Colour col;
            if (getColour (AppearanceColours::colours[i].name, col))
                editor.setColour (AppearanceColours::colours[i].colourID, col);
        }
    }

    editor.setColour (ScrollBar::thumbColourId,
                      IntrojucerLookAndFeel::getScrollbarColourForBackground (editor.findColour (CodeEditorComponent::backgroundColourId)));
}
Esempio n. 3
0
void Circle::Draw() const {
	glColor3f(getColour().r, getColour().g, getColour().b);
		glBegin(GL_POLYGON);
		for (int i = 1; i < 360; i+=7.2)
		{
			int xCoord = centre.x + radius * cos(i*M_PI/180);
			int yCoord = centre.y + radius * sin(i*M_PI/180);
			glVertex2f(xCoord, yCoord);
		}
		glEnd();
}
Esempio n. 4
0
int drawDisintegrationSpell()
{
	int colour1, colour2, colour3;

	colour1 = getColour(231, 231, 231);
	colour2 = getColour(57, 57, 224);
	colour3 = getColour(41, 41, 160);

	drawDisintegrationLine(self->startX, self->startY, self->endX, self->endY, colour1, colour2, colour3);

	return TRUE;
}
Esempio n. 5
0
int drawSoulStealSpell()
{
	int colour1, colour2, colour3;

	colour1 = getColour(38, 152, 38);
	colour2 = getColour(50, 200, 50);
	colour3 = getColour(56, 225, 56);

	drawDisintegrationLine(self->startX, self->startY, self->endX, self->endY, colour1, colour2, colour3);

	return TRUE;
}
Esempio n. 6
0
GC setup(Display * dpy, int argc, char ** argv, int *width_r, int *height_r,
		XFontSet *font_r){
	int width, height;
	unsigned long background, border;
	Window win;
	GC pen;
	XGCValues values;

	XFontSet font;
	XrmDatabase db;

	XrmInitialize();
	db = XrmGetDatabase(dpy);
	XrmParseCommand(&db, xrmTable, sizeof(xrmTable)/sizeof(xrmTable[0]),
		"xtut7", &argc, argv);

	font = getFont(dpy, db, "xtut7.font", "xtut7.Font", "fixed");
	background = getColour(dpy,  db, "xtut7.background", "xtut7.BackGround", "DarkGreen");
	border = getColour(dpy,  db, "xtut7.border", "xtut7.Border", "LightGreen");
	values.foreground = getColour(dpy,  db, "xtut7.foreground", "xtut7.ForeGround", "Red");


	width = 400;
	height = 400;

	win = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), /* display, parent */
		0,0, /* x, y: the window manager will place the window elsewhere */
		width, height, /* width, height */
		2, border, /* border width & colour, unless you have a window manager */
		background); /* background colour */

	Xutf8SetWMProperties(dpy, win, "XTut7", "xtut7", argv, argc,
		NULL, NULL, NULL);

	/* create the pen to draw lines with */
	values.line_width = 1;
	values.line_style = LineSolid;
	/*values.font = font->fid; */
	pen = XCreateGC(dpy, win, GCForeground|GCLineWidth|GCLineStyle,&values);

	/* tell the display server what kind of events we would like to see */
	XSelectInput(dpy, win, ButtonPressMask|ButtonReleaseMask|StructureNotifyMask|ExposureMask);

	/* okay, put the window on the screen, please */
	XMapWindow(dpy, win);

	*width_r = width; *height_r = height;
	*font_r = font;

	return pen;
}
Esempio n. 7
0
void RDirNode::drawFiles(Frustum &frustum, float dt) {

    if(frustum.boundsInFrustum(quadItemBounds)) {

        vec4f col = getColour();

        glPushMatrix();
            glTranslatef(pos.x, pos.y, 0.0);

            //draw files

            for(std::list<RFile*>::iterator it = files.begin(); it!=files.end(); it++) {
                RFile* f = *it;
                if(f->isHidden()) continue;

                f->draw(dt);
            }

        glPopMatrix();
    }

    glDisable(GL_TEXTURE_2D);

    for(std::list<RDirNode*>::iterator it = children.begin(); it != children.end(); it++) {
        RDirNode* node = (*it);
        node->drawFiles(frustum,dt);
    }
}
Esempio n. 8
0
unsigned char* JuliaThread::DrawJuliaRow()
{
    int i, iter=0;
    double x, y, xtemp;
    unsigned char* rgbdata = new unsigned char[width*3];
        for (i=0; i<width; i++) //columns: x
        {
           y = ymax - r*dy;
           x = xmin + i*dx;
           iter = 0;
           while (x*x+y*y < 4 && iter<maxiter)
           {
                xtemp = x*x - y*y + cx;
                y = x*y + x*y + cy;
                x = xtemp;
                iter++;
           }

           if(iter==maxiter)
           {
               rgbdata[i*3] = (unsigned char)0;
        	   rgbdata[i*3+1] = (unsigned char)0;
        	   rgbdata[i*3+2] = (unsigned char)0;
           }
           else
           {
               unsigned char* temp = getColour((4*(iter - (log(log(x*x+y*y)))/log(2.0))));
               rgbdata[i*3] = temp[0];
        	   rgbdata[i*3+1] = temp[1];
        	   rgbdata[i*3+2] = temp[2];
        	   delete[] temp;
           }
        }
    return rgbdata;
}
Esempio n. 9
0
void Pawn::draw(float dt) {
    if(hidden) return;

    float halfsize = size * 0.5f;
    vec2 offsetpos = pos - vec2(halfsize, halfsize*graphic_ratio);

    float alpha = getAlpha();

    vec3 col = getColour();

    glBindTexture(GL_TEXTURE_2D, graphic->textureid);

    glPushMatrix();
        glTranslatef(offsetpos.x, offsetpos.y, 0.0f);

        glColor4f(col.x, col.y, col.z, alpha);

        glBegin(GL_QUADS);
            glTexCoord2f(0.0f,0.0f);
            glVertex2f(0.0f, 0.0f);

            glTexCoord2f(1.0f,0.0f);
            glVertex2f(size, 0.0f);

            glTexCoord2f(1.0f,1.0f);
            glVertex2f(size, size*graphic_ratio);

            glTexCoord2f(0.0f,1.0f);
            glVertex2f(0.0f, size*graphic_ratio);
        glEnd();

    glPopMatrix();
}
Esempio n. 10
0
void Pawn::drawSimple(float dt) {
    if(isHidden()) return;

    glLoadName(tagid);

    float ratio = icon->h / (float) icon->w;
    float halfsize = size * 0.5f;
    vec2f offsetpos = pos - vec2f(halfsize, halfsize);

    float alpha = getAlpha();
    vec3f col = getColour();

    glColor4f(col.x, col.y, col.z, alpha);

    glPushMatrix();
        glTranslatef(offsetpos.x, offsetpos.y, 0.0f);

        glBegin(GL_QUADS);
            glTexCoord2f(0.0f,0.0f);
            glVertex2f(0.0f, 0.0f);

            glTexCoord2f(1.0f,0.0f);
            glVertex2f(size, 0.0f);

            glTexCoord2f(1.0f,1.0f);
            glVertex2f(size, size*ratio);

            glTexCoord2f(0.0f,1.0f);
            glVertex2f(0.0f, size*ratio);
        glEnd();

    glPopMatrix();
}
Esempio n. 11
0
	void LightCategory::bind( castor::PxBufferBase & p_texture, uint32_t index )const
	{
		uint32_t offset = 0u;
		doCopyComponent( getColour(), index, offset, p_texture );
		doCopyComponent( getIntensity(), getFarPlane(), index, offset, p_texture );
		doBind( p_texture, index, offset );
	}
Esempio n. 12
0
void RDirNode::drawFiles(float dt) const{

    if(in_frustum) {

        vec4f col = getColour();

        glPushMatrix();
            glTranslatef(pos.x, pos.y, 0.0);

            //draw files

            for(std::list<RFile*>::const_iterator it = files.begin(); it!=files.end(); it++) {
                RFile* f = *it;
                if(f->isHidden()) continue;

                f->draw(dt);
            }

        glPopMatrix();
    }

    for(std::list<RDirNode*>::const_iterator it = children.begin(); it != children.end(); it++) {
        RDirNode* node = (*it);
        node->drawFiles(dt);
    }
}
Esempio n. 13
0
//! Reads the ui config into m_uiConfig
void Button::readUIConfig(){
 	UIConfigManager &configMan = UIConfigManager::getInstance();

 	const std::string buttonPath = "$.button";
 	boost::optional<jsoncons::json> maybeSettings = configMan.getSetting(buttonPath);
	if(!maybeSettings)
		CAP_THROW(CapEngineException("Could not load button settings. jsonpath query: " + buttonPath));
	jsoncons::json settings = (*maybeSettings)[0];

	// get the font path
	jsoncons::json fontpath = jsoncons::jsonpath::json_query(settings, "$.font.path");
	if(fontpath.empty()){
		boost::optional<jsoncons::json> defaultFontPath = configMan.getSetting(kDefaultFontSettingsPath);
		if(!defaultFontPath)
			CAP_THROW(CapEngineException("Could not get default font."))

		m_uiConfig.fontpath = (*defaultFontPath)[0].as<std::string>();
	}

	// neutral settings
	if(!settings.has_key("neutral"))
		 CAP_THROW(CapEngineException("Button settings missing \"neutral\" property."));


	auto getColourSetting = [](const jsoncons::json colourParent) -> boost::optional<Colour> {
		if(!colourParent.has_key("colour"))
			return boost::none;
		else{
			boost::optional<Colour> maybeColour = getColour(colourParent["colour"]);
			if(maybeColour)
				return *maybeColour;
			else
				return boost::none;
		}
	};

	// neutral settings
	jsoncons::json neutralSettings = settings["neutral"];
	boost::optional<Colour> maybeNeutralFontColour = getColourSetting(getProperty(neutralSettings, "font"));
	m_uiConfig.neutralFontColour = maybeNeutralFontColour ? *maybeNeutralFontColour : kDefaultNeutralFontColour;

	boost::optional<Colour> maybeNeutralBackgroundColour = getColourSetting(getProperty(neutralSettings,"fill"));
	m_uiConfig.neutralBackgroundColour = maybeNeutralBackgroundColour ? *maybeNeutralBackgroundColour : kDefaultNeutralBackgroundColour;

	// hover settings
 	jsoncons::json hoverSettings = getProperty(settings, "hover");
	boost::optional<Colour> maybeHoverFontColour = getColourSetting(getProperty(hoverSettings, "font"));
	m_uiConfig.hoverFontColour = maybeHoverFontColour ? *maybeHoverFontColour : kDefaultHoverFontColour;

	boost::optional<Colour> maybeHoverBackgroundColour = getColourSetting(getProperty(hoverSettings, "fill"));
	m_uiConfig.hoverBackgroundColour = maybeHoverBackgroundColour ? *maybeHoverBackgroundColour : kDefaultHoverBackgroundColour;

	// pressed settings
 	jsoncons::json pressedSettings = getProperty(settings, "pressed");
	boost::optional<Colour> maybePressedFontColour = getColourSetting(getProperty(pressedSettings, "font"));
	m_uiConfig.pressedFontColour = maybePressedFontColour ? *maybePressedFontColour : kDefaultPressedFontColour;

	boost::optional<Colour> maybePressedBackgroundColour = getColourSetting(getProperty(pressedSettings, "fill"));
	m_uiConfig.pressedBackgroundColour = maybePressedBackgroundColour ? *maybePressedBackgroundColour : kDefaultPressedBackgroundColour;
}
void mouse(int btn, int state, int x, int y)
{
	switch (btn) {
	case(GLUT_LEFT_BUTTON) :
		Vector2d clickedXY = Vector2d((float)x, (float)y);
		if ((clickedTimes == 0 || clickedTimes % 2 == 0) && state == (gDragMode ? GLUT_DOWN : GLUT_UP)) { // first click
			currentVertex.position = clickedXY;
			currentVertex.colour = getColour(gColour);
			clickedTimes++;
		}
		else if ((clickedTimes % 2 == 1) && state == GLUT_UP) { // second click
			currentVertex.direction = pointSlope(currentVertex.position.x, currentVertex.position.y, x, y);
			currentVertices.push_back(currentVertex);
			clickedTimes++;
		}
		if (((clickedTimes == 2 && mouseMode == Dot) || (clickedTimes == 4 && mouseMode == Line)) && state == GLUT_UP) {
			finishedShapes.push_back(currentVertices);
			switch (mouseMode){
			case(Dot) :
				finishedShapes.back().type = GL_POINTS;
				break;
			case(Line) :
				finishedShapes.back().type = GL_LINES;
				break;
			case(Poly) :
				break;
			}
			clearCurrentVertex();
		} 
		break;
	}
}
void makeVertex(void)
{
	currentVertex.position = Vector2d(randFloat(0, gWidth), randFloat(0, gHeight));
	currentVertex.direction = Vector2d(randFloat(-1, 1), randFloat(-1, 1));
	currentVertex.colour = getColour(gColour);
	currentVertices.push_back(currentVertex);
}
static void getCPUColour(byte cpuUsage, s_rgbVal* colour)
{
	// Workout colour
	colour->red		= getColour(cpuUsage, 128, 255, MIN_RGB_LEVEL, MAX_RGB_LEVEL);
	colour->blue	= getColour(cpuUsage, 0, 127, MAX_RGB_LEVEL, MIN_RGB_LEVEL);

	if(cpuUsage < 128)
		colour->green = getColour(cpuUsage, 0, 127, MIN_RGB_LEVEL, MAX_RGB_LEVEL);
	else
		colour->green = getColour(cpuUsage, 128, 255, MAX_RGB_LEVEL, MIN_RGB_LEVEL);

	// Adjust colour (sine smooth, brightness)
	adjustColour(&colour->red);
	adjustColour(&colour->blue);
	adjustColour(&colour->green);
}
Esempio n. 17
0
	void ColourPanel::setAlphaSupport(bool _value)
	{
		mAlphaSupport = _value;
		updateAlphaSupport();

		setColour(getColour());
	}
Esempio n. 18
0
	// Re-apply the changes in selection, colour and amount on a fresh palette
	void redraw()
	{
		pal_preview->setPalette(palette);
		pal_preview->getPalette().tint(getColour(), getAmount(),
		                               pal_preview->getSelectionStart(), pal_preview->getSelectionEnd());
		pal_preview->draw();
	}
Esempio n. 19
0
void Box2DRenderer::DrawCircle (const b2Vec2& center, float32 radius, const b2Color& color)
{
    graphics->setColour (getColour (color));
    graphics->drawEllipse (center.x - radius, center.y - radius,
                           radius * 2.0f, radius * 2.0f,
                           getLineThickness());
}
Esempio n. 20
0
	// Re-apply the changes in selection and colour on a fresh palette
	void redraw()
	{
		pal_preview->setPalette(palette);
		pal_preview->getPalette().colourise(getColour(),
		                                    pal_preview->getSelectionStart(), pal_preview->getSelectionEnd());
		pal_preview->draw();
	}
Esempio n. 21
0
void Entry::render( wxDC& dc, bool draw_left, bool draw_right ) const
{
    dc.SetBrush(*wxWHITE_BRUSH); 		// white filling
    dc.SetPen( wxPen( getColour(), Model::TWIPS ) ); 	// 1-pixel-thick outline

    wxPoint points[4];
    unsigned int i = 0;
    if ( draw_right ) {
	points[i].x   = _extent.x;		/* top right  */
	points[i++].y = 0;
    }
    points[i].x   = _extent.x - 3*__dx;		/* Bottom right */
    points[i++].y = _extent.y;
    points[i].x   = 0;				/* bottom left */
    points[i++].y = _extent.y;
    if ( draw_left ) {
	points[i].x   = 3*__dx;			/* top left */
	points[i++].y = 0;
    }
    dc.DrawLines( i, points, _origin.x, _origin.y );
    
    wxString s( getName().c_str(), wxConvLibc );
    wxFont font( Model::DEFAULT_FONT_SIZE, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false );
    dc.SetFont(font);
    wxSize size = dc.GetTextExtent(s);
    dc.DrawText( s, _origin.x+(_extent.x-size.GetWidth())/2, _origin.y+(_extent.y-size.GetHeight())/2 );

    for ( std::vector<ArcForEntry *>::const_iterator next_arc = _src_arcs.begin(); next_arc != _src_arcs.end(); ++next_arc ) {
	(*next_arc)->render( dc );
    }
}
Esempio n. 22
0
	void GroundFog::updateSkyFogging() {
		Ogre::GpuProgramParametersSharedPtr params = 
			mDomeMaterial->getBestTechnique()->getPass(0)->getFragmentProgramParameters();
		params->setNamedConstant("fogDensity", getDensity());
		params->setNamedConstant("fogColour", getColour());
		params->setNamedConstant("fogVerticalDecay", getVerticalDecay());
		params->setNamedConstant("fogGroundLevel", getGroundLevel());
	}
Esempio n. 23
0
void Circle::draw (easygl* window) const {
   // Load up the data structure needed by easygl, and draw the triangle
   // using the easygl::draw_polygon call.
   
   window->gl_setcolor(getColour());
   window->gl_fillarc(getXcen(), getYcen(), radius, 0, 360);     

}
Esempio n. 24
0
void Box2DRenderer::DrawSolidPolygon (const b2Vec2* vertices, int32 vertexCount, const b2Color& color)
{
    graphics->setColour (getColour (color));

    Path p;
    createPath (p, vertices, vertexCount);
    graphics->fillPath (p);
}
Esempio n. 25
0
void Box2DRenderer::DrawPolygon (const b2Vec2* vertices, int32 vertexCount, const b2Color& color)
{
    graphics->setColour (getColour (color));

    Path p;
    createPath (p, vertices, vertexCount);
    graphics->strokePath (p, PathStrokeType (getLineThickness()));
}
// Events
void GfxTintDialog::onColourChanged(wxColourPickerEvent& e)
{
	Misc::loadImageFromEntry(gfx_preview->getImage(), entry);
	wxColour col = cp_colour->GetColour();
	gfx_preview->getImage()->tint(getColour(), getAmount(), palette);
	gfx_preview->updateImageTexture();
	gfx_preview->Refresh();
}
Esempio n. 27
0
void CtrlrMenuBarLookAndFeel::drawMenuBarItem (Graphics &g, int width, int height, int itemIndex, const String &itemText, bool isMouseOverItem, bool isMenuOpen, bool isMouseOverBar, MenuBarComponent &menuBar)
{
	if (itemText.isEmpty())
		return;

	Colour textColour	= getColour (Ids::ctrlrMenuBarTextColour);
	Font textFont		= getMenuBarFont (menuBar, itemIndex, itemText);

	if (!menuBar.isEnabled())
	{
		textColour = textColour.withMultipliedAlpha (0.5f);
	}
	else if (isMouseOverItem && !isMenuOpen)
	{
		textColour = getColour (Ids::ctrlrMenuBarHighlightedTextColour);
		drawSelectionRectangle (g, width, height, getColour (Ids::ctrlrMenuBarHighlightColour).darker(0.3f));
	}
	else if (isMouseOverItem && isMenuOpen)
	{
		textColour = getColour (Ids::ctrlrMenuBarHighlightedTextColour);
		drawSelectionRectangle (g, width, height, getColour (Ids::ctrlrMenuBarHighlightColour));
	}
	else if (isMenuOpen)
	{
		textColour = getColour (Ids::ctrlrMenuBarHighlightedTextColour);
		drawSelectionRectangle (g, width, height, getColour (Ids::ctrlrMenuBarHighlightColour));
	}

	g.setColour (textColour);
	g.setFont (textFont);
	g.drawFittedText (itemText, 0, 0, width, height, Justification::centred, 1);
}
void GfxTintDialog::onAmountChanged(wxCommandEvent& e)
{
	Misc::loadImageFromEntry(gfx_preview->getImage(), entry);
	wxColour col = cp_colour->GetColour();
	gfx_preview->getImage()->tint(getColour(), getAmount(), palette);
	gfx_preview->updateImageTexture();
	gfx_preview->Refresh();
	label_amount->SetLabel(S_FMT("%d%% ", slider_amount->GetValue()));
}
void GfxTintDialog::setValues(string col, int val)
{
	wxColour colour(col);
	cp_colour->SetColour(colour);
	slider_amount->SetValue(val);
	label_amount->SetLabel(S_FMT("%d%% ", slider_amount->GetValue()));
	gfx_preview->getImage()->tint(getColour(), getAmount(), palette);
	gfx_preview->updateImageTexture();
	gfx_preview->Refresh();
}
    void mouseDown (const MouseEvent&) override
    {
        ColourSelector* colourSelector = new ColourSelector();
        colourSelector->setName ("Colour");
        colourSelector->setCurrentColour (getColour());
        colourSelector->addChangeListener (this);
        colourSelector->setColour (ColourSelector::backgroundColourId, Colours::transparentBlack);
        colourSelector->setSize (300, 400);

        CallOutBox::launchAsynchronously (colourSelector, getScreenBounds(), nullptr);
    }