コード例 #1
0
ファイル: Lily.cpp プロジェクト: Valoa/lily
void batteryStatus() {
  byte r, g, b;
  getBatteryColor(r, g, b);
  for (int i = 0; i < 255; i += 5)  makeColor(r * i / 255, g * i / 255, b * i / 255);
  for (int i = 255; i > 0; i -= 5)  makeColor(r * i / 255, g * i / 255, b * i / 255);
  makeColor(0, 0, 0);
}
コード例 #2
0
ファイル: main.cpp プロジェクト: b8875/gemtc
void CPUbilateralFiltering(RGB* data, int width, int height,int radius, float sigma_spatial, float sigma_range)
{
    int numElements = width*height;
    RGB* res_data = (RGB *)malloc (sizeof(RGB) * width * height);
    for(int x = 0; x < width; x++)
    {
        for(int y = 0; y < height; y++)
        {
            int array_idx = y * width + x;
            RGB currentColor = data[array_idx]; //idx

            RGB res = makeColor(0.0f,0.0f,0.0f);
            RGB normalization = makeColor(0.0f,0.0f,0.0f);


            for(int i = -radius; i <= radius; i++) {
                for(int j = -radius; j <= radius; j++) {
                    int x_sample = x+i;
                    int y_sample = y+j;

                    //mirror edges
                    if( (x_sample < 0) || (x_sample >= width ) ) {
                        x_sample = x-i;
                    }

                    if( (y_sample < 0) || (y_sample >= height) ) {
                        y_sample = y-j;
                    }

                    RGB tmpColor = data[y_sample * width + x_sample];

                    float gauss_spatial = gaussian2d(i,j,sigma_spatial); //gaussian1d(i,sigma_spatial)*gaussian1d(j,sigma_spatial);//
                    RGB gauss_range;
                    gauss_range.R = gaussian1d(currentColor.R - tmpColor.R, sigma_range);
                    gauss_range.G = gaussian1d(currentColor.G - tmpColor.G, sigma_range);
                    gauss_range.B = gaussian1d(currentColor.B - tmpColor.B, sigma_range);

                    RGB weight;
                    weight.R = gauss_spatial * gauss_range.R;
                    weight.G = gauss_spatial * gauss_range.G;
                    weight.B = gauss_spatial * gauss_range.B;

                    normalization = normalization + weight;

                    res = res + (tmpColor * weight);

                }
            }

            res_data[array_idx] = res / normalization;
        }
    }

    for(int i = 0; i < numElements; i++)
    {
        data[i] = res_data[i];
    }
    free(res_data);

}
コード例 #3
0
unsigned int ofxColor::asHex() const {
	float resize = 255. / colorRange;
	if(colorMode == OF_COLOR_RGB) {
		return makeColor(a, r, g, b, resize);
	} else if(colorMode == OF_COLOR_HSV) {
		return makeColor(a, h, s, v, resize);
	}
}
コード例 #4
0
ファイル: Canvas.cpp プロジェクト: stevewolter/rapidSTORM
void Canvas::DirectDrawer::clear( const Color &color ) {
    wxPen pen( makeColor(color) );
    wxBrush brush( makeColor(color) );
    dc.SetPen( pen );
    dc.SetBrush( brush );
    dc.DrawRectangle( c.canvas_coords(
        wxRect(0, 0, c.contents->GetWidth(), c.contents->GetHeight())) );

    BufferedDrawer::clear( color );
}
コード例 #5
0
ファイル: uGLRender.cpp プロジェクト: Jappsy/jappsy
void GLRender::drawRect(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2, const GLPaint& paint, GLCamera* camera) {
	GLCamera* cam = (camera != NULL) ? camera : this->cameras->gui;
	cam->update();
	GLfloat* projection16fv = cam->projection16fv.v;
	
	if (((paint.m_color & 0xFF000000) != 0) && (shaderSquareFill != NULL)) {
		if ((paint.m_color & 0xFF000000) != 0xFF000000)
			enableBlend();
		else
			disableBlend();
		
		glUseProgram(shaderSquareFill->program);
		
		glUniformMatrix4fv(shaderSquareFill->uLayerProjectionMatrix, 1, GL_FALSE, projection16fv);
		
		GLfloat* c = makeColor(&paint.m_color, 1);
		glUniform4fv(shaderSquareFill->uColor, 1, c);
		
		glBindBuffer(GL_ARRAY_BUFFER, m_squareBuffer);
		glBufferData(GL_ARRAY_BUFFER, 8 * sizeof(GLfloat), makeRect(x1, y1, x2, y2), GL_DYNAMIC_DRAW);
		glVertexAttribPointer(shaderSquareFill->aVertexPosition, 2, GL_FLOAT, GL_FALSE, 0, NULL);
		glEnableVertexAttribArray(shaderSquareFill->aVertexPosition);
		
		glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
		
		glDisableVertexAttribArray(shaderSquareFill->aVertexPosition);
		glUseProgram(0);
	}
	
	if (((paint.m_strokeColor & 0xFF000000) != 0) && (shaderSquareStroke != NULL)) {
		enableBlend();
		glUseProgram(shaderSquareStroke->program);
		
		glUniformMatrix4fv(shaderSquareStroke->uLayerProjectionMatrix, 1, GL_FALSE, projection16fv);
		
		GLfloat half = floorf((GLfloat)(paint.m_strokeWidth) / 2.0f);
		GLfloat corners[4] = { x1 - half, y1 - half, x2 + half, y2 + half };
		glUniform2fv(shaderSquareStroke->uCorners, 2, corners);
		glUniform1f(shaderSquareStroke->uBorder, paint.m_strokeWidth);
		
		GLfloat* c = makeColor(&paint.m_strokeColor, 1);
		glUniform4fv(shaderSquareStroke->uColor, 1, c);
		
		glBindBuffer(GL_ARRAY_BUFFER, m_squareBuffer);
		glBufferData(GL_ARRAY_BUFFER, 8 * sizeof(GLfloat), makeRect(x1-half, y1-half, x2+half, y2+half), GL_DYNAMIC_DRAW);
		glVertexAttribPointer(shaderSquareStroke->aVertexPosition, 2, GL_FLOAT, GL_FALSE, 0, NULL);
		glEnableVertexAttribArray(shaderSquareStroke->aVertexPosition);
		
		glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
		
		glDisableVertexAttribArray(shaderSquareStroke->aVertexPosition);
		glUseProgram(0);
	}
}
コード例 #6
0
void FastThreePhase::decode() {
	makeColor();
	
	int n = width * height;

	threePhaseWrap.setThreshold((unsigned char) rangeThreshold);
	threePhaseWrap.makeWrappedPhase(phasePixels, qualityPixels,
		graySequence[0], graySequence[1], graySequence[2]);
	
	// this is used by getStart() to determine the center
	for(int i = 0; i < n; i++)
		ready[i] = qualityPixels[i] != LABEL_BACKGROUND;
	
	partialQualityMap.makeQualityMap(phasePixels, qualityPixels);
	
	scanlineOffset.makeOffset(phasePixels, qualityPixels, (char*) offsetPixels, getStart(), phasePersistence);

	for(int i = 0; i < n; i++)
		mask[i] = qualityPixels[i] != LABEL_UNWRAPPED;

	for(int i = 0; i < n; i++) {
		int cur = ((char*) offsetPixels)[i];
		phase[i] = (cur * 256) + phasePixels[i];
		phase[i] *= .002f; // this should be handled by skew/scale instead
	}

	makeDepth();
	
	if(maxHoleSize > 0)
		fillHoles();
}
コード例 #7
0
ファイル: ogr_file_format.cpp プロジェクト: 999999333/mapper
PointSymbol* OgrFileImport::getSymbolForOgrSymbol(OGRStyleToolH tool, const QByteArray& style_string)
{
	Q_ASSERT(OGR_ST_GetType(tool) == OGRSTCSymbol);
	
	auto raw_tool_key = OGR_ST_GetStyleString(tool);
	auto tool_key = QByteArray::fromRawData(raw_tool_key, qstrlen(raw_tool_key));
	auto symbol = point_symbols.value(tool_key);
	if (symbol && symbol->getType() == Symbol::Point)
		return static_cast<PointSymbol*>(symbol);
	
	int is_null;
	auto color_string = OGR_ST_GetParamStr(tool, OGRSTSymbolColor, &is_null);
	if (is_null)
		return nullptr;
	
	auto point_symbol = static_cast<PointSymbol*>(default_point_symbol->duplicate());
	auto color = makeColor(tool, color_string);
	if (color)
		point_symbol->setInnerColor(color);
	else
		point_symbol->setHidden(true);
	
	auto key = style_string;
	key.detach();
	point_symbols.insert(key, point_symbol);
	
	if (key != tool_key)
	{
		tool_key.detach();
		point_symbols.insert(tool_key, point_symbol);
	}
	
	map->addSymbol(point_symbol, map->getNumSymbols());
	return point_symbol;
}
コード例 #8
0
ファイル: kernel.c プロジェクト: Kapilks/Basic-Kernel
void kernel()
{
	/* Initialize console so that print start working */
	initializeConsole(makeColor(COLOR_WHITE, COLOR_BLUE));
	
	usefullStuff();
}
コード例 #9
0
ファイル: student.c プロジェクト: LeoCerny/FIT_IZG
S_RGBA studrenTextureValue( S_StudentRenderer * pRenderer, double u, double v )
{
	u = u * pRenderer->width;
	v = v * pRenderer->height;

	int U = (int) floor(u);
	int V = (int) floor(v);
	double xU = u - floor(u);
	double xV = u - floor(u);
	S_RGBA color;
    if (!isnan(u) && !isnan(v)){
    	color.red = pRenderer->texture[U * pRenderer->height + V].red * (1 - xU) * (1 - xV)
    	    			+ pRenderer->texture[U * pRenderer->height + (V + 1)].red * (1 - xU) * xV
    					+ pRenderer->texture[(U + 1) * pRenderer->height + V].red * xU * (1 - xV)
    					+ pRenderer->texture[(U + 1) * pRenderer->height + (V + 1)].red * xU * xV;
    	color.green = pRenderer->texture[U * pRenderer->height + V].green * (1 - xU) * (1 - xV)
						+ pRenderer->texture[U * pRenderer->height + (V + 1)].green * (1 - xU) * xV
						+ pRenderer->texture[(U + 1) * pRenderer->height + V].green * xU * (1 - xV)
						+ pRenderer->texture[(U + 1) * pRenderer->height + (V + 1)].green * xU * xV;
    	color.blue = pRenderer->texture[U * pRenderer->height + V].blue * (1 - xU) * (1 - xV)
						+ pRenderer->texture[U * pRenderer->height + (V + 1)].blue * (1 - xU) * xV
						+ pRenderer->texture[(U + 1) * pRenderer->height + V].blue * xU * (1 - xV)
						+ pRenderer->texture[(U + 1) * pRenderer->height + (V + 1)].blue * xU * xV;
    } else {
    	color.red = 90;
    	color.blue = 60;
    	color.green = 90;
    }
    return (makeColor(color.red, color.green, color.blue));
}
コード例 #10
0
ファイル: Orc.cpp プロジェクト: vesabios/matador
Pixel Orc::render(float luma)  {
    Pixel p;
    p.fg = makeColor(2,2,2);
    p.bg = 0;
    p.a = 0;
    p.c = toascii('O');
    return p;
}
コード例 #11
0
void LightCycle::drawInnerCircles() {
	float * myColor = makeColor(31 / 255.0f, 1, 233 / 255.0f);
	vector <Component> list;
	list.push_back(getComponent("LeftInnerCircle"));
	list.push_back(getComponent("RightInnerCircle"));
	drawPart(list, myColor, false);

}
コード例 #12
0
ファイル: particle.cpp プロジェクト: TAhub/WPRIN
void particle::render(drawer *draw)
{
	sf::Color c = makeColor(global_data->getValue(DATA_PARTICLE, id, 2));
	c.a = (sf::Uint8) (255 * (1 - timer / lifetime));
	draw->renderSprite(global_data->getValue(DATA_PARTICLE, id, 0),
						global_data->getValue(DATA_PARTICLE, id, 1),
						x - global_camera->x, y - global_camera->y, false, c);
}
コード例 #13
0
ファイル: main.cpp プロジェクト: yuriks/Pong
void debugPoint(int x, int y) {
	Sprite spr;
	spr.color = makeColor(255, 0, 0, 255);
	spr.setImg(16 + 2, 16 + 2, 4, 4);
	spr.setPos(x - 2, y - 2);

	debug_sprites.push_back(spr);
}
コード例 #14
0
ファイル: ogr_file_format.cpp プロジェクト: 999999333/mapper
TextSymbol* OgrFileImport::getSymbolForLabel(OGRStyleToolH tool, const QByteArray&)
{
	Q_ASSERT(OGR_ST_GetType(tool) == OGRSTCLabel);
	
	int is_null;
	auto label_string = OGR_ST_GetParamStr(tool, OGRSTLabelTextString, &is_null);
	if (is_null)
		return nullptr;
	
	auto color_string = OGR_ST_GetParamStr(tool, OGRSTLabelFColor, &is_null);
	auto font_size_string = OGR_ST_GetParamStr(tool, OGRSTLabelSize, &is_null);
	
	// Don't use the style string as a key: The style contains the label.
	QByteArray key;
	key.reserve(qstrlen(color_string) + qstrlen(font_size_string) + 1);
	key.append(color_string);
	key.append(font_size_string);
	auto text_symbol = static_cast<TextSymbol*>(text_symbols.value(key));
	if (!text_symbol)
	{
		text_symbol = static_cast<TextSymbol*>(default_text_symbol->duplicate());
		
		auto color = makeColor(tool, color_string);
		if (color)
			text_symbol->setColor(color);
		else
			text_symbol->setHidden(true);
		
		auto font_size = OGR_ST_GetParamDbl(tool, OGRSTLabelSize, &is_null);
		if (!is_null && font_size > 0.0)
			text_symbol->scale(font_size / text_symbol->getFontSize());
		
		key.detach();
		text_symbols.insert(key, text_symbol);
		
		map->addSymbol(text_symbol, map->getNumSymbols());
	}
	
	auto anchor = qBound(1, OGR_ST_GetParamNum(tool, OGRSTLabelAnchor, &is_null), 12);
	if (is_null)
		anchor = 1;
	
	auto angle = OGR_ST_GetParamDbl(tool, OGRSTLabelAngle, &is_null);
	if (is_null)
		angle = 0.0;
	
	QString description;
	description.reserve(qstrlen(label_string) + 100);
	description.append(QString::number(100 + anchor));
	description.append(QString::number(angle, 'g', 1));
	description.append(QLatin1Char(' '));
	description.append(label_string);
	text_symbol->setDescription(description);
	
	return text_symbol;
}
コード例 #15
0
ファイル: VFX.hpp プロジェクト: vesabios/matador
    virtual void update(float dt) override {
        if (!inited) { init(); }
        
        frame++;
        
        Pixel pixel;
        pixel.fg = makeColor(5,5,5);
        pixel.bg = makeColor(0,0,0);
        
        
        int cr = 0;
        for (int i=0; i<9; i++) {
            if (angle < (i*45)+22.5) {
                cr = i;
                break;
            }
        }
        
        BYTE arr[9] = {133,253,134,252,133,253,134,252,133};

        pixel.c = arr[cr];
        pixel.a = 0;
        
        ofVec2i p = ofVec2i(pa.x, pa.y);
        
        console.setPixel(p, pixel);
        
        if (!done) {
            if (pa.x==pb.x && pa.y==pb.y) {
                done = true;
                
                if (nextEvent) {
                    ofNotifyEvent(CombatEvent::combatEvent, *nextEvent);
                }

            }
            e2 = err;
            if (e2 >-dx) { err -= dy; pa.x += sx; }
            if (e2 < dy) { err += dx; pa.y += sy; }
        }
 

    }
コード例 #16
0
void LightCycle::drawBottomDetails() {
	glLineWidth(5.0);
	float * myColor = makeColor(31 / 255.0f, 1, 233 / 255.0f);
	vector <Component> list;
	list.push_back(getComponent("bottomLeft"));
	list.push_back(getComponent("bottomMiddle"));
	list.push_back(getComponent("bottomRight"));
	drawPart(list, myColor, false);
	glLineWidth(1.0);
}
コード例 #17
0
ファイル: VFX.hpp プロジェクト: vesabios/matador
    virtual void update(float dt) override {
        
        elapsed += dt;
        frame++;

        if (elapsed>0.45f) {
            done = true;
        }
        
        Pixel pixel;
        pixel.fg = makeColor(5,1,0);
        pixel.bg = 0;
        pixel.a = 0;
        
        int y = p.y - (elapsed*5.0f);
        
        console.writeString(p.x, y, makeColor(5,1,0), ofToString(dmg));
        
    }
コード例 #18
0
ファイル: PatternK2000.cpp プロジェクト: speed47/StairwayLeds
void PatternK2000::_animate(direction_t direction)
{
  int currentDirection = 1;
  int hue = random(0, 360);
  int k[_chaseLen];

  // setup the head and tail  
  for (int i = 0; i < _chaseLen; i++)
  {
    k[i] = i;
  }
  
  while (this->elapsed() < _duration)
  {
    digitalWrite(TEENSY_LED_PIN, HIGH);
    ++this->_iterations;
    hue = hue + _hueStep % 360;
    // reverse direction if we're at the top
    if (k[_chaseLen-1] >= NBLEDS - 1)
    {
      currentDirection = -1; // down
    }
    // reverse direction if we're at the bottom
    else if (k[_chaseLen-1] <= 0)
    {
      currentDirection = 1; // up
    }
    
    // before advancing the tail, power off the last tail led
    // the others are either already black or will still be part
    // of the lighted leds of this step
    setPix(direction, LEDS_OFFSET, k[0], 0);
    
    // advance the tail
    for (int i = 0; i < _chaseLen - 1; i++)
    {
      k[i] = k[i+1];
    }
    // and set the head
    k[_chaseLen-1] += currentDirection;
    
    // set the colors now, from tail to head
    // because the head must always have the last word
    for (int i = 0; i < _chaseLen; i++)
    {
      setPix(direction, LEDS_OFFSET, k[i], makeColor(hue, 100, _chase[i]));
    }
    
    // now display
    leds.show();
    digitalWrite(TEENSY_LED_PIN, LOW);
    delay(_delay);
  }
}
コード例 #19
0
ファイル: main.c プロジェクト: senilica/IOOPM
void renderList(sLinkedList* list, sSdlWrapper* wrap)
{
  Uint32 bg = makeColor(255, 50, 25, 175);
  Uint32 fg = makeColor(255, 75, 50, 200);
  if(listEmpty(list))
    return;
  sListIterator* it = 0;
  listHead(list, &it);
  point* toDraw = 0;
  int x = 0;
  int y = 0;
  while(!listIteratorEnd(it))
  {
    toDraw = (point*)listGet(it);
    pointGetPos(toDraw, &x, &y);
    drawBevel(wrap, x*25, y*25, 25, 25, bg, fg);
    listIteratorNext(it);
  }
  free(it);
}
コード例 #20
0
ファイル: ogr_file_format.cpp プロジェクト: 999999333/mapper
void OgrFileImport::applyBrushColor(OGRStyleToolH tool, AreaSymbol* area_symbol)
{
	int is_null;
	auto color_string = OGR_ST_GetParamStr(tool, OGRSTBrushFColor, &is_null);
	if (!is_null)
	{
		auto color = makeColor(tool, color_string);
		if (color)
			area_symbol->setColor(color);
		else
			area_symbol->setHidden(true);
	}
}
コード例 #21
0
ファイル: ogr_file_format.cpp プロジェクト: 999999333/mapper
void OgrFileImport::applyPenColor(OGRStyleToolH tool, LineSymbol* line_symbol)
{
	int is_null;
	auto color_string = OGR_ST_GetParamStr(tool, OGRSTPenColor, &is_null);
	if (!is_null)
	{
		auto color = makeColor(tool, color_string);
		if (color)
			line_symbol->setColor(color);
		else
			line_symbol->setHidden(true);
	}
}
コード例 #22
0
void PhaseDecoder::decode() {
	makeColor();
	makePhase();
	memcpy( wrappedPhase, phase, sizeof(float) * width * height);
	for (int pass = 0; pass < maxPasses; pass++) {
		unwrapPhase();
		if (minRemaining != 0 && getRemaining() < minRemaining)
			break;
	}
	if (phasePersistence)
		memcpy(lastPhase, phase, sizeof(float) * width * height);
	makeDepth();
}
コード例 #23
0
ファイル: Inspect.cpp プロジェクト: vesabios/matador
void Inspect::render() {
    
    if (menuPos<CONSOLE_WIDTH) {
        ofRectangle r = ofRectangle((int)menuPos,2,28,40);
        
        unsigned char bg = makeColor(0,1,3);
        unsigned char fg = makeColor(5,5,5);
        
        console.drawBox(r, bg);
        console.writeString((int)menuPos+1, 3, "Inspect", makeColor(5,0,5), bg);
        
        for(auto it = btns.begin(); it != btns.end(); it++)
        {
            if (it->funptr==NULL) {
                
                string valueString;
                
                if (*(it->t) == typeid(unsigned char)) {
                    BYTE * i = (BYTE*)it->valuePtr;
                    valueString = ofToString((int)*i);
                } else if (*(it->t) == typeid(int)) {
                    int * i = (int*)it->valuePtr;
                    valueString = ofToString(*i);
                } else  if (*(it->t) == typeid(bool)) {
                    bool * i = (bool*)it->valuePtr;
                    valueString = *i ? "true" : "false";
                }
                
                console.writeString((int)menuPos+it->r.x, it->r.y, it->text+": "+valueString, it->fg, it->bg);
                
            } else {
                console.writeString((int)menuPos+it->r.x, it->r.y, it->text, it->fg, it->bg);
            }
        }
        
    }

    
}
コード例 #24
0
ファイル: MapGenerator.cpp プロジェクト: embr/cs225b
/*
Header header
  uint32 seq
  time stamp
  string frame_id
nav_msgs/MapMetaData info
  time map_load_time
  float32 resolution
  uint32 width
  uint32 height
  geometry_msgs/Pose origin
    geometry_msgs/Point position
      float64 x
      float64 y
      float64 z
    geometry_msgs/Quaternion orientation
      float64 x
      float64 y
      float64 z
      float64 w
int8[] data
*/
void MapGenerator::generateMap(PoseGraph *graph, nav_msgs::FancyMap *map) {
    // for convenience
    this->graph = graph;
    this->map = map;

    // first compute the map bounds
    computeMapBounds();

    // setup map
    map->info.resolution = map_resolution;
    map->info.width = map_size_x;
    map->info.height = map_size_y;
    map->info.origin.position.x = x_min;
    map->info.origin.position.y = y_min;
    map->info.origin.position.z = -0.1;
    tf::quaternionTFToMsg(tf::createQuaternionFromYaw(0), map->info.origin.orientation);
    map->channels.clear();

    // default color abgr
    map->default_color = 0x00000000;
    nav_msgs::FancyMapChannel chan;
    chan.name = "rgba";
    map->channels.push_back(chan);

    // put in initial data
    log_odds = new double[map_size_x * map_size_y];
    for (int i = 0; i < map_size_x * map_size_y; i++) {
        log_odds[i] = 0;
    }

    // process the graph
    for (size_t i = 0; i < graph->getNumNodes(); i++) {
        GraphNode *node = graph->getNode(i);
        processNode(node);
    }

    // translate odds
    for (size_t i = 0; i < map_size_x * map_size_y; i++) {
        int value = (int) (255 * sigmoid(log_odds[i]));
        map->channels[0].data.push_back(makeColor(255-value, 255-value, 255-value, 255));
        //map->channels[0].data.push_back(makeColor(value,0,255-value,255));
    }

    // clean up
    delete[] log_odds;

    // update header information
    map->header.stamp = ros::Time::now();
    map->header.frame_id = map_frame;
}
コード例 #25
0
ファイル: Buttons.c プロジェクト: anfray-lapeyre/imagimp
void drawButton(const Button *b){
	if(b->press){
		privateDrawButton(b,&b->back,&b->fore);
	}
	else if(b->hover)
	{
		Color fore = makeColor(b->fore.r+0.2,b->fore.g+0.4,
							   b->fore.b+0.4,b->fore.a);
		privateDrawButton(b,&fore,&b->back);
	}
	else{
		privateDrawButton(b,&b->fore,&b->back);
	}
}
コード例 #26
0
ファイル: Buttons.c プロジェクト: anfray-lapeyre/imagimp
void drawSlider(const Slider *s){

    if(s->press){
        privateDrawSlider(s,&s->back,&s->fore,&s->fore);
    }
    else if(s->hover)
    {
        Color fore = makeColor(s->fore.r+0.2,s->fore.g+0.4,s->fore.b+0.4,s->fore.a);
        privateDrawSlider(s,&fore,&s->back,&s->fore);
    }
    else{
        privateDrawSlider(s,&s->fore,&s->back,&s->fore);
    }

}
コード例 #27
0
ファイル: render.c プロジェクト: Jools64/IWBTG-C-Engine
void spriteInit(Sprite* s, Texture* t, float width, float height)
{
    Sprite clear = {0};
    *s = clear;
    s->texture = t;
    s->size.x = width;
    s->size.y = height;
    s->origin.x = width / 2;
    s->origin.y = height / 2;
    s->scale.x = 1;
    s->scale.y = 1;
    s->visible = true;
    s->alpha = 1;
    s->additiveBlend = false;
    s->color = makeColor(1.0, 1.0, 1.0, 1.0);
}
コード例 #28
0
ColorPickerForm::ColorPickerForm(EditData *pEditData, QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::ColorPickerForm)
{
    ui->setupUi(this);
    m_pEditData = pEditData;

    m_selectColor = 0;
    m_selectBright = QPoint();
    m_editMode = 0;

    setArrowPos();
    makeColor();
    makeBright();
    ui->label_bright->setSelectPos(m_selectBright);
}
コード例 #29
0
ファイル: Editor.cpp プロジェクト: yuriks/PlatformerGame
void editorDraw(const GameState& game_state, RenderState& render_state) {
	std::string status_text;

	if (editor_state.mode == EditorState::MODE_TILES) {
		// Draw world
		render_state.drawSprites();
		render_state.drawTileLayers();
		if (editor_state.current_layer == GameState::LAYER_ACTION) {
			game_state.level_layers[GameState::LAYER_ACTION].draw(render_state.sprite_buffers[RenderState::LAYER_TILES_ACTION], game_state.camera);
		}

		const BackgroundLayer& layer = game_state.level_layers[editor_state.current_layer];

		// Draw tile cursor
		Sprite tile_spr;
		tile_spr.img = layer.getTileImgRect(editor_state.current_tile_id);
		tile_spr.pos = intRoundTo(editor_state.mouse_coords - layer.position, layer.tile_size) + layer.position;
		tile_spr.pos = game_state.camera.transform(tile_spr.pos);
		tile_spr.color = makeColor(128, 128, 128, 64);
		render_state.sprite_buffers[getSpriteLayerForLevelLayer(editor_state.current_layer)].append(tile_spr);

		// Draw status line text
		boost::format status_text_fmt("%1% - X: %2% Y: %3%");
		status_text = str(status_text_fmt % "TILES" % editor_state.mouse_coords.x % editor_state.mouse_coords.y);
	} else if (editor_state.mode == EditorState::MODE_TILECHOOSER) {
		const TextureInfo& texture = *render_state.sprite_buffers[getSpriteLayerForLevelLayer(editor_state.current_layer)].texture;

		Sprite spr;
		spr.img.x = spr.img.y = 0;
		spr.img.w = texture.width;
		spr.img.h = texture.height;
		spr.pos = ivec2_0;
		render_state.sprite_buffers[getSpriteLayerForLevelLayer(editor_state.current_layer)].append(spr);

		boost::format status_text_fmt("TILE ID: %04X");
		status_text = str(status_text_fmt % editor_state.current_tile_id);
	}

	drawString(0, WINDOW_HEIGHT - ui_font.char_h, status_text, render_state.sprite_buffers[RenderState::LAYER_UI], ui_font, TextAlignment::left, color_white);
}
コード例 #30
0
ファイル: GSort.cpp プロジェクト: EmnaBenAbdallah/pgrou
GSort::GSort(SortPtr s, GVNode n, qreal width, qreal height) : QGraphicsRectItem(n.centerPos.x()-width/2, n.centerPos.y()-height/2, width, height),sort(s), node(n) {

    // graphic items set and Actions color
    color = makeColor();
    sizeRect = new QSize(width, height);

    leftTopCorner = new QPoint(n.centerPos.x()-sizeRect->width()/2,n.centerPos.y()-sizeRect->height()/2);

    // rectangle
    _rect = new QGraphicsRectItem(QRectF(*leftTopCorner, *sizeRect),this);
    _rect->setPen(QPen(QColor(7,54,66)));
    _rect->setBrush(QBrush(QColor(7,54,66)));

    // label
    text = new QGraphicsTextItem (QString(), this);
    text->setHtml(QString::fromStdString("<u>sort " + sort->getName() + "</u>"));
    text->setDefaultTextColor(*color);
    text->setPos(leftTopCorner->x()+sizeRect->width()/2, leftTopCorner->y());
    QSizeF textSize = text->document()->size();
    text->setPos(text->x() - textSize.width()/2, text->y() - textSize.height());

    setCursor(QCursor(Qt::OpenHandCursor));
    setAcceptedMouseButtons(Qt::LeftButton | Qt::RightButton);

    // set related GProcesses as children (so they move with this GSort)
    vector<ProcessPtr> processes = sort->getProcesses();
    int currPosYProcess = marginDefault+GProcess::sizeDefault/2;

    for(ProcessPtr &p : processes){
	gProcesses.push_back(make_shared<GProcess>(p, leftTopCorner->x() + GProcess::sizeDefault/2+ marginDefault, leftTopCorner->y()+ currPosYProcess));
	currPosYProcess+= 2*marginDefault + GProcess::sizeDefault;
    }
    for(GProcessPtr &gp: gProcesses){
	gp->getDisplayItem()->setParentItem(this);
	ProcessPtr* p = gp->getProcess();
	(*p)->setGProcess(gp);
    }

}