예제 #1
0
Pixel HueSaturationMixer::getPixel( const Im::Position& pos, unsigned char val )  const
{
    ColourVector hs;
    RGBWeight rgb_weights;
    convert_xy_tone_to_hue_sat
        ( colours(pos).x(), colours(pos).y(), hs[0], hs[1] );
    rgb_weights_from_hue_saturation( hs[0], hs[1], rgb_weights );
    return Pixel( val * rgb_weights );
}
예제 #2
0
void HueSaturationMixer::merge_tone( const Im::Position& pos,
                    float old_data_weight, float new_data_weight )
{
    assert( colours.contains( pos ) );
    if ( old_data_weight < 1E-3 ) {
        colours(pos) = tone_point;
        DEBUG("Used tone point " << colours(pos).transpose() << " for new point");
    } else {
        colours(pos) = 
            ( colours(pos) * old_data_weight + 
                tone_point * new_data_weight ) /
                ( old_data_weight + new_data_weight );
        DEBUG("Merged tone point " << colours(pos).transpose() << " from " << tone_point << " for new point");
    }
}
예제 #3
0
mesh_object::mesh_object(const std::shared_ptr<mesh_shader>& shader,
                         const glm::vec3* positions,
                         size_t num_positions)
        : shader_{shader} {
    std::vector<GLuint> indices(num_positions);
    std::iota(indices.begin(), indices.end(), 0);
    ibo.data(indices);

    geometry_.data(positions, num_positions);

    {
        std::vector<float> colours(num_positions, 0.0f);
        set_pressures(colours.data(), colours.size());
    }

    //  init vao
    const auto s_vao = vao_.get_scoped();
    mglu::enable_and_bind_buffer(vao_,
                                 geometry_,
                                 shader->get_attrib_location_v_position(),
                                 3,
                                 GL_FLOAT);

    mglu::enable_and_bind_buffer(vao_,
                                 pressures_,
                                 shader->get_attrib_location_v_pressure(),
                                 1,
                                 GL_FLOAT);
    ibo.bind();
}
예제 #4
0
/*************************************************************************
	Perform the actual rendering for this Window.
*************************************************************************/
void Static::populateRenderCache()
{
    Rect backgroundRect(Point(0,0), getAbsoluteSize());

    // draw frame
    if (d_frameEnabled)
    {
        d_frame.draw(d_renderCache);

        // adjust destination area for backfrop image.
        backgroundRect.d_left		+= d_left_width;
        backgroundRect.d_right		-= d_right_width;
        backgroundRect.d_top		+= d_top_height;
        backgroundRect.d_bottom	-= d_bottom_height;
    }

    // draw backdrop
    if (d_backgroundEnabled && (d_background != NULL))
    {
        // factor window alpha into colours to use when rendering background
        ColourRect colours(d_backgroundCols);
        colours.modulateAlpha(getEffectiveAlpha());
        // cache image for drawing
        d_renderCache.cacheImage(*d_background, backgroundRect, 0, colours);
    }

}
예제 #5
0
	void FalagardCheckButton::drawCheck()
	{
        ColourRect colours(d_selectImage.getColours());
        colours.setAlpha(getEffectiveAlpha());
        d_selectImage.setColours(colours);
        d_selectImage.draw(d_renderCache);
	}
예제 #6
0
	void FrameWindow::populateRenderCache()
	{
		Rect unclipped_rect = getUnclippedPixelRect();
		Rect rect(Point(0.0f, 0.0f), Size(unclipped_rect.getWidth(), unclipped_rect.getHeight()));
		ColourRect colours(Colour(1.0f, 1.0f, 1.0f, getEffectiveAlpha()));

		if (d_section_images[TopLeft])
			d_renderCache.cacheImage(*d_section_images[TopLeft], Rect(Point(0.0f, 0.0f), Size(d_width_left, d_height_top)), colours);
		if (d_section_images[TopMiddle])
			d_renderCache.cacheImage(*d_section_images[TopMiddle], Rect(Point(d_width_left, 0.0f), Size(d_width_middle, d_height_top)), colours);
		if (d_section_images[TopRight])
			d_renderCache.cacheImage(*d_section_images[TopRight], Rect(Point(d_width_left + d_width_middle, 0.0f), Size(d_width_right, d_height_top)), colours);
		if (d_section_images[MiddleLeft])
			d_renderCache.cacheImage(*d_section_images[MiddleLeft], Rect(Point(0.0f, d_height_top), Size(d_width_left, d_height_middle)), colours);
		if (d_section_images[MiddleMiddle])
			d_renderCache.cacheImage(*d_section_images[MiddleMiddle], Rect(Point(d_width_left, d_height_top), Size(d_width_middle, d_height_middle)), colours);
		if (d_section_images[MiddleRight])
			d_renderCache.cacheImage(*d_section_images[MiddleRight], Rect(Point(d_width_left + d_width_middle, d_height_top), Size(d_width_right, d_height_middle)), colours);
		if (d_section_images[BottomLeft])
			d_renderCache.cacheImage(*d_section_images[BottomLeft], Rect(Point(0.0f, d_height_top + d_height_middle), Size(d_width_left, d_height_bottom)), colours);
		if (d_section_images[BottomMiddle])
			d_renderCache.cacheImage(*d_section_images[BottomMiddle], Rect(Point(d_width_left, d_height_top + d_height_middle), Size(d_width_middle, d_height_bottom)), colours);
		if (d_section_images[BottomRight])
			d_renderCache.cacheImage(*d_section_images[BottomRight], Rect(Point(d_width_left + d_width_middle, d_height_top + d_height_middle), Size(d_width_right, d_height_bottom)), colours);
	}
예제 #7
0
	void FalagardAnimate::drawNormal(float z)
	{
		if( m_bPlay )
		{
			ColourRect colours(d_normalImage.getColours());
			colours.setAlpha(getEffectiveAlpha() * m_fAlpha );
			d_normalImage.setColours(colours);
			d_normalImage.draw(d_renderCache);
		}
	}
예제 #8
0
static void
prompt(const char *p, struct ship *ship)
{
    static char buf[60];

    if (ship != NULL) {
        printf(buf, p, ship->shipname, colours(ship),
               sterncolour(ship));
        p = buf;
    }
    sc_prompt = p;
    sc_buf = "";
    sc_hasprompt = 1;
    waddstr(scroll_w, p);
}
예제 #9
0
void
draw_board(void)
{
    int n;

    clear();
    werase(view_w);
    werase(slot_w);
    werase(scroll_w);
    werase(stat_w);
    werase(turn_w);

    sc_line = 0;

    move(BOX_T, BOX_L);
    for (n = 0; n < BOX_X; n++)
        addch('-');
    move(BOX_B, BOX_L);
    for (n = 0; n < BOX_X; n++)
        addch('-');
    for (n = BOX_T+1; n < BOX_B; n++) {
        mvaddch(n, BOX_L, '|');
        mvaddch(n, BOX_R, '|');
    }
    mvaddch(BOX_T, BOX_L, '+');
    mvaddch(BOX_T, BOX_R, '+');
    mvaddch(BOX_B, BOX_L, '+');
    mvaddch(BOX_B, BOX_R, '+');
    refresh();

#define WSaIM "Wooden Ships & Iron Men"
    wmove(view_w, 2, (VIEW_X - sizeof WSaIM - 1) / 2);
    waddstr(view_w, WSaIM);
    wmove(view_w, 4, (VIEW_X - strlen(cc->name)) / 2);
    waddstr(view_w, cc->name);
    wrefresh(view_w);

    move(LINE_T, LINE_L);
    printw("Class %d %s (%d guns) '%s' (%c%c)",
           mc->class,
           classname[mc->class],
           mc->guns,
           ms->shipname,
           colours(ms),
           sterncolour(ms));
    refresh();
}
예제 #10
0
void GMExperiment6_1::displaySmoothData()
{
    // draw Bezier curve
    bool colourise = true;
    auto colour = makeVector4f(0, 1.0, 0, 1);
    vector<Vector4f> colours(smoothData.size());

    float min_curv = *std::min_element(curvature.begin(), curvature.end());
    float max_curv = *std::max_element(curvature.begin(), curvature.end());

    float max_mag = std::max(fabs(min_curv), fabs(max_curv));
    max_mag = 10;

    for(int i = 0; i < smoothData.size(); ++i)
        colours[i] = colourise ? getColor(curvature[i], -max_mag, max_mag) : colour;
    displayData(smoothData, colours);
}
예제 #11
0
파일: squish.cpp 프로젝트: aclysma/Helium
void Compress( u8 const* rgba, void* block, int flags )
{
	// fix any bad flags
	flags = FixFlags( flags );

	// get the block locations
	void* colourBlock = block;
	void* alphaBock = block;
	if( ( flags & ( kDxt3 | kDxt5 ) ) != 0 )
		colourBlock = reinterpret_cast< u8* >( block ) + 8;

	// create the minimal point set
	ColourSet colours( rgba, flags );
	
	// check the compression type and compress colour
	if( colours.GetCount() == 1 )
	{
		// always do a single colour fit
		SingleColourFit fit;
        fit.SetColourSet( &colours, flags );
		fit.Compress( colourBlock );
	}
	else if( ( flags & kColourRangeFit ) != 0 )
	{
		// do a range fit
		RangeFit fit;
        fit.SetColourSet( &colours, flags );
		fit.Compress( colourBlock );
	}
	else
	{
		// default to a cluster fit
		ClusterFit fit;
        fit.SetColourSet( &colours, flags );
        fit.SetMetric( 1.0f, 1.0f, 1.0f );
		fit.Compress( colourBlock );
	}
	
	// compress alpha separately if necessary
	if( ( flags & kDxt3 ) != 0 )
		CompressAlphaDxt3( rgba, alphaBock );
	else if( ( flags & kDxt5 ) != 0 )
		CompressAlphaDxt5( rgba, alphaBock );
}
예제 #12
0
cv::Mat Visualize::mapGeneration(cv::Mat image, std::vector <int> label, std::vector <Matrix_double> distances, std::string colourNameFloor, std::string colourNameObstacle)
{
	std::vector<double> floor=colour(colourNameFloor); // obtain colour parameters of input name
	std::vector<double> obstacle=colour(colourNameObstacle); // obtain colour parameters of input name
	
	/* Perform map reconstruction
	 * The system asumes that each pixel of image represents a square of evironment of 5cm width and 5cm height
	 * */
	#pragma omp parallel 
	{
		#pragma omp for shared (image, label) private (i, j) reduction(+: sum) 
		{
			for (int i=0; i<label.size(); i++)
			{
				//If the pixel is located in a safe zone (in a distance between 0 an 40m in absolute value) print the pixel
				if (distances[i].columns[0]!=-999999 && distances[i].columns[1]!=-999999)
				{
                    int x_aux1=600-abs(distances[i].columns[1])*100/5;
			
                    int y_aux1=200+(distances[i].columns[0])*100/5;

					std::vector <double> colours (3,0);
					
					if (label[i]==1)
						colours=floor;
					
					else
						colours=obstacle;
					
					for (int j=x_aux1; j<=x_aux1+40; j++)
					{
							image.at<cv::Vec3b>(j,y_aux1)[3] = colours[2];
							image.at<cv::Vec3b>(j,y_aux1)[2] = colours[0];
							image.at<cv::Vec3b>(j,y_aux1)[1] = colours[1];
					}
				}
			}		
		}
	}

	
	return image;
}
예제 #13
0
std::vector<Matrix_double> ExtractColour::indexPCD2VectorRGB(pcl::PointCloud<pcl::PointXYZRGBA> cloud, std::vector<int> index)
{
	std::vector <Matrix_double> colours(index.size());
	pcl::PointCloud<pcl::PointXYZRGBA>::ConstPtr cloudPtr (new pcl::PointCloud<pcl::PointXYZRGBA> (cloud)); 
	
	#pragma omp parallel 
	{
		#pragma omp for shared (colours, index) private (i) reduction(+: sum) 
		{
			for (int i=0; i<index.size(); i++)
			{
				colours[i].columns.push_back(cloudPtr->points[index[i]].r); // save R parameter
				colours[i].columns.push_back(cloudPtr->points[index[i]].g); // save G parameter
				colours[i].columns.push_back(cloudPtr->points[index[i]].b); // save B parameter
			}
		}
	}
	
	return colours;
}
예제 #14
0
void
draw_view(void)
{
    struct ship *sp;

    werase(view_w);
    foreachship(sp) {
        if (sp->file->dir
                && sp->file->row > viewrow
                && sp->file->row < viewrow + VIEW_Y
                && sp->file->col > viewcol
                && sp->file->col < viewcol + VIEW_X) {
            wmove(view_w, sp->file->row - viewrow,
                  sp->file->col - viewcol);
            waddch(view_w, colours(sp));
            wmove(view_w,
                  sternrow(sp) - viewrow,
                  sterncol(sp) - viewcol);
            waddch(view_w, sterncolour(sp));
        }
    }
    wrefresh(view_w);
}
예제 #15
0
std::vector<Matrix_double> ExtractColour::indexPCD2VectorLab(pcl::PointCloud<pcl::PointXYZRGBA> cloud, std::vector<int> index)
{
	std::vector <Matrix_double> colours(3);
	pcl::PointCloud<pcl::PointXYZRGBA>::ConstPtr cloudPtr (new pcl::PointCloud<pcl::PointXYZRGBA> (cloud));
	
	Conversion conversion;
	
	#pragma omp parallel 
	{
		#pragma omp for shared (cloud, index, colours) private (i) reduction(+: sum) 
		{
			for (int i=0; i<index.size(); i++)
			{
				std::vector<int> lab=conversion.rgb2lab(cloudPtr->points[index[i]].r,cloudPtr->points[index[i]].g,cloudPtr->points[index[i]].b); // perform RGB to Lab conversion
				
				colours[i].columns.push_back(lab[0]); // save L parameter
				colours[i].columns.push_back(lab[1]); // save a parameter
				colours[i].columns.push_back(lab[2]); // save b parameter
			}
		}
	}
	
	return colours;
}
예제 #16
0
std::vector <double> Visualize::colour (std::string colour)
{
	std::vector <double> colours(3);
	
	// select colour name string and return RGB values
	if (colour=="black")
	{
		colours[0]=0;
		colours[1]=0;
		colours[2]=0;
	}
			
	else
	{
		if (colour=="white")
		{
			colours[0]=255;
			colours[1]=255;
			colours[2]=255;
		}
			
		else
		{
			if (colour=="red")
			{
				colours[0]=255;
				colours[1]=0;
				colours[2]=0;
			}
			
			else
			{
				if (colour=="green")
				{
					colours[0]=0;
					colours[1]=255;
					colours[2]=0;
				}
				
				else
				{
					if (colour=="blue")
					{
						colours[0]=0;
						colours[1]=0;
						colours[2]=255;
					}
					
					else
					{
						if (colour=="yellow")
						{
							colours[0]=255;
							colours[1]=255;
							colours[2]=0;
						}
						
						else
						{
							if (colour=="cyan")
							{
								colours[0]=0;
								colours[1]=255;
								colours[2]=255;
							}
							
							else
							{
								if (colour=="magenta")
								{
									colours[0]=255;
									colours[1]=0;
									colours[2]=255;
								}
							}
						}
					}
				}
			}
		}
	}
	
	return colours;
}
예제 #17
0
bool playlist_view::draw_items(HDC dc, int start_item, int count)
{
	//	profiler(draw_items);

	if (!drawing_enabled) return false;

	static_api_ptr_t<playlist_manager> playlist_api;

	HDC hdc_mem = 0;
	RECT rect, item, item_area, bk, draw/*,text*/;
	GetClientRect(wnd_playlist, &rect);
	rect.top += get_header_height();

	int item_height = get_item_height();

	HBRUSH br = 0;
	HBITMAP hbm_mem = 0, hbm_old = 0;

	pfc::array_t<int, pfc::alloc_fast_aggressive> widths;
	int total_width = get_column_widths(widths);
	int t = columns.get_count();

	const bit_array & p_mask = g_cache.active_get_columns_mask();

	item_area.left = rect.left;
	item_area.right = rect.right;
	item_area.top = rect.top + (item_height*start_item);
	item_area.bottom = item_area.top + (item_height*count);

	item.left = 0 - horizontal_offset;
	item.right = item.left + total_width;
	item.top = 0;
	item.bottom = item.top + item_height;

	bk.top = 0;
	bk.left = 0;
	bk.bottom = item_height*count;
	bk.right = rect.right - rect.left;

	/*static */pfc::string8_fast_aggressive temp;
	temp.prealloc(512);

	/* edit01 */

	hdc_mem = CreateCompatibleDC(dc);

	COLORREF colourfore = 0xff;

	hbm_mem = CreateCompatibleBitmap(dc, rect.right - rect.left, item_height*count);

	hbm_old = (HBITMAP)SelectObject(hdc_mem, hbm_mem);

	HGDIOBJ font_old = SelectObject(hdc_mem, g_font);

	cui::colours::helper p_helper(appearance_client_pv_impl::g_guid);

	//fill entire area with back colour
	br = CreateSolidBrush(p_helper.get_colour(cui::colours::colour_background));
	FillRect(hdc_mem, &bk, br);
	DeleteObject(br);

	//need checks here because of filling background

	{
		int total = playlist_api->activeplaylist_get_item_count();

		if (start_item + count + scroll_item_offset > total) //end item is NOT inclusive
		{
			count -= (start_item + count + scroll_item_offset) - total;
		}

	}

	int end_item = start_item + count;



	//draw each item

	int n,
		focus = playlist_api->activeplaylist_get_focus_item();

	//	static int pcount;



	t_size playing_index, playing_playlist;
	playlist_api->get_playing_item_location(&playing_playlist, &playing_index);
	bool b_playback = static_api_ptr_t<play_control>()->is_playing();
	if (g_cache.get_active_playlist() != playing_playlist) playing_index = pfc_infinite;
	for (n = start_item; n < end_item; n++)
	{
		bool sel = playlist_api->activeplaylist_is_item_selected(n + scroll_item_offset);
		bool b_focused = GetFocus() == wnd_playlist || IsChild(wnd_playlist, GetFocus());
		bool b_playing = b_playback && playing_index == (n + scroll_item_offset);
		//draw each column of each item
		int theme_state = NULL;
		if (sel)
			theme_state = (b_playing ? LISS_HOTSELECTED : (b_focused ? LISS_SELECTED : LISS_SELECTEDNOTFOCUS));
		else if (b_playing) theme_state = LISS_HOT;
		bool b_themed = m_theme && p_helper.get_themed() && IsThemePartDefined(m_theme, LVP_LISTITEM, theme_state);
		if (b_themed && theme_state)
		{
			if (IsThemeBackgroundPartiallyTransparent(m_theme, LVP_LISTITEM, theme_state))
				DrawThemeParentBackground(get_wnd(), hdc_mem, &item);
			DrawThemeBackground(m_theme, hdc_mem, LVP_LISTITEM, theme_state, &item, NULL);
		}

		//int total = playlist_api->activeplaylist_get_item_count();
		int c, offset = 0, i = 0;
		for (c = 0; c < t; c++)
		{
			if (p_mask[c])
			{

				draw.left = item.left + offset;
				draw.top = item.top;

				offset += widths[i];

				draw.right = item.left + offset;
				draw.bottom = item.bottom;

				{
					//					profiler_debug(draw_item_get_string);
					g_cache.active_get_display_name(n + scroll_item_offset, i, temp);
				}

				colourinfo colours(0x000000, 0x000000, 0xFF, 0xFF, 0, 0xFF);
				g_cache.active_get_colour(n + scroll_item_offset, i, colours);

				if (b_themed)
				{
					//COLORREF cr_back= get_default_colour(colours::COLOUR_BACK);
					//colourfore = get_default_colour(colours::COLOUR_TEXT);
					//GetThemeColor(m_theme, LVP_LISTITEM, sel ? (GetFocus() == wnd_playlist ? LIS_SELECTED : LIS_SELECTEDNOTFOCUS) : LIS_NORMAL, TMT_WINDOWTEXT, &colourfore);
					colourfore = GetThemeSysColor(m_theme, sel ? COLOR_BTNTEXT : COLOR_WINDOWTEXT);
					//GetThemeColor(m_theme, LVP_LISTITEM, sel ? (GetFocus() == wnd_playlist ? LIS_SELECTED : LIS_SELECTEDNOTFOCUS) : LIS_NORMAL, TMT_TEXTCOLOR, &colourfore);
					if (!theme_state)
					{
						//GetThemeColor(m_theme, LVP_LISTITEM, LIS_NORMAL, TMT_FILLCOLOR, &colourfore);
						br = CreateSolidBrush(colours.background_colour);
						FillRect(hdc_mem, &draw, br);
					}
				}
				else
				{
					if (sel)
					{
						/* TEST */

						if (GetFocus() == wnd_playlist)
						{
							colourfore = colours.selected_text_colour;
							br = CreateSolidBrush(colours.selected_background_colour);
						}
						else
						{
							colourfore = colours.selected_text_colour_non_focus;
							br = CreateSolidBrush(colours.selected_background_colour_non_focus);
						}
					}
					else
					{
						colourfore = colours.text_colour;
						br = CreateSolidBrush(colours.background_colour);
					}
					//draw cell background
					//if (!b_themed)
					FillRect(hdc_mem, &draw, br);
				}


				if (br) { DeleteObject(br); br = 0; }

				//render text
				//if (b_themed)
				//	DrawThemeText(m_theme, hdc_mem, LVP_LISTITEM, sel ? (GetFocus() == wnd_playlist ? LIS_SELECTED : LIS_SELECTEDNOTFOCUS) : LIS_NORMAL, L"test", 4, 0, 0, &draw);
				//else
				ui_helpers::text_out_colours_tab(hdc_mem, temp, temp.length(), 2, 1, &draw, sel, colourfore, TRUE, true, (cfg_ellipsis != 0), (ui_helpers::alignment)columns[c]->align);


				if (colours.use_frame_left)
				{
					HPEN pen = CreatePen(PS_SOLID, 1, colours.frame_left);
					HPEN pen_old = (HPEN)SelectObject(hdc_mem, pen);

					MoveToEx(hdc_mem, draw.left, draw.top, 0);
					LineTo(hdc_mem, draw.left, draw.bottom);
					SelectObject(hdc_mem, pen_old);
					DeleteObject(pen);
				}
				if (colours.use_frame_top)
				{
					HPEN pen = CreatePen(PS_SOLID, 1, colours.frame_top);
					HPEN pen_old = (HPEN)SelectObject(hdc_mem, pen);

					MoveToEx(hdc_mem, draw.left, draw.top, 0);
					LineTo(hdc_mem, draw.right, draw.top);
					SelectObject(hdc_mem, pen_old);
					DeleteObject(pen);
				}
				if (colours.use_frame_right)
				{
					HPEN pen = CreatePen(PS_SOLID, 1, colours.frame_right);
					HPEN pen_old = (HPEN)SelectObject(hdc_mem, pen);

					MoveToEx(hdc_mem, draw.right - 1, draw.top, 0);
					LineTo(hdc_mem, draw.right - 1, draw.bottom);
					SelectObject(hdc_mem, pen_old);
					DeleteObject(pen);
				}
				if (colours.use_frame_bottom)
				{
					HPEN pen = CreatePen(PS_SOLID, 1, colours.frame_bottom);
					HPEN pen_old = (HPEN)SelectObject(hdc_mem, pen);

					MoveToEx(hdc_mem, draw.right - 1, draw.bottom - 1, 0);
					LineTo(hdc_mem, draw.left - 1, draw.bottom - 1);
					SelectObject(hdc_mem, pen_old);
					DeleteObject(pen);
				}
				i++;
			}
		}



		//draw focus frame
		if ((n + scroll_item_offset) == focus)
		{
			if (m_always_show_focus || (!(SendMessage(get_wnd(), WM_QUERYUISTATE, NULL, NULL) & UISF_HIDEFOCUS) && b_focused))
			{
				RECT rc_focus = item;
				if (m_theme && p_helper.get_themed() && IsThemePartDefined(m_theme, LVP_LISTITEM, LISS_SELECTED))
					InflateRect(&rc_focus, -1, -1);
				if (!p_helper.get_bool(cui::colours::bool_use_custom_active_item_frame))
				{
					DrawFocusRect(hdc_mem, &rc_focus);
				}
				else
				{
					br = CreateSolidBrush(p_helper.get_colour(cui::colours::colour_active_item_frame));
					FrameRect(hdc_mem, &rc_focus, br);
					DeleteObject(br);
				}
			}
		}

		item.top += item_height;
		item.bottom += item_height;
	}


	BitBlt(dc, item_area.left, item_area.top, item_area.right - item_area.left, item_area.bottom - item_area.top,
		hdc_mem, 0, 0, SRCCOPY);

	if (font_old) SelectObject(hdc_mem, font_old);
	SelectObject(hdc_mem, hbm_old);
	DeleteObject(hbm_mem);
	DeleteDC(hdc_mem);

	return true;
}