Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

color picker for your shitty hack #112

Open
puppygirlcoded opened this issue Aug 13, 2021 · 4 comments
Open

color picker for your shitty hack #112

puppygirlcoded opened this issue Aug 13, 2021 · 4 comments

Comments

@puppygirlcoded
Copy link

yes

`void menu_framework::color_picker ( int x, int y, int position, std::string string, color& output_value, bool& toggle ) {
GetCursorPos ( &cursor );
const auto [rain_r, rain_g, rain_b] { utilities::draw_rainbow ( 1.f ) };
auto in_bounds = mouse_in_range ( position - 4, y, 15, 10 );

render::text ( x, y, render::fonts::watermark_font, string, false, color::white ( ) );
render::draw_filled_rect ( position - 4, y, 15, 10, color ( output_value.r, output_value.g, output_value.b ) );
render::draw_rect ( position - 4, y, 15, 10, in_bounds ? color ( rain_r * 255, rain_g * 255, rain_b * 255 ) : color ( 50, 50, 50 ) );


if ( in_bounds && GetAsyncKeyState ( VK_LBUTTON ) & 1 ) {
	toggle = true;
}

if ( toggle ) {

	static float h = 1.f, s = 1.f, v = 1.f, a = 1.f;
	static float v_2 = 1.f;
	static int r = output_value.r, g = output_value.g, b = output_value.b;
	static float clr_r = r / 255, clr_g = g / 255, clr_b = b / 255;
	color_convert_hsv_to_rgb ( h, s, v, clr_r, clr_g, clr_b );


	int cp_x = variables::menu::x + variables::menu::w + 10;
	int cp_render_x = variables::menu::x + variables::menu::w + 15;
	int cp_y = variables::menu::y;
	int cp_render_y = variables::menu::y + 5;
	int cp_w = 150;
	int cp_main_w = 175;
	int cp_main_h = 200;
	int cp_h = 150;

	int button_y = cp_render_y + 150 + 20;
	int hsv_x = cp_render_x + cp_w + 5;

	if ( !mouse_in_range ( cp_x, cp_y, cp_main_w, cp_main_h ) && GetAsyncKeyState ( VK_LBUTTON ) & 1 )
		toggle = false;


	static float full_sat_r, full_sat_g, full_sat_b;
	color_convert_hsv_to_rgb ( h, 1.f, 1.f, full_sat_r, full_sat_g, full_sat_b );
	render::draw_filled_rect ( cp_x, cp_y, cp_main_w, cp_main_h, color ( 25, 25, 25 ) );
	render::draw_outline ( cp_x, cp_y, cp_main_w, cp_main_h, color ( 50, 50, 50 ) );
	render::rect_fade ( cp_render_x, cp_render_y, cp_w, cp_h, color ( 255, 255, 255 ), color ( full_sat_r * 255, full_sat_g * 255, full_sat_b * 255 ), true, true );
	render::rect_fade ( cp_render_x, cp_render_y + ( cp_h / 2 ), cp_w, cp_h / 2, color ( 0, 0, 0, 0 ), color ( 0, 0, 0 ), false, true );

	//hsv rainbow gay pride thing ;D
	const color col_hues [6 + 1] = { color ( 255,0,0,255 ), color ( 255,255,0,255 ), color ( 0,255,0,255 ), color ( 0,255,255,255 ), color ( 0,0,255,255 ), color ( 255,0,255,255 ), color ( 255,0,0,255 ) };
	for ( int i = 0; i < 6; i++ )
		render::rect_fade ( hsv_x, cp_render_y + ( ( 150 / 6 ) * i ), 10, 150 / 6, col_hues [i], col_hues [i + 1], false, true );

	render::rect_fade ( cp_render_x, cp_render_y + cp_h + 5, 150, 10, color ( 0, 0, 0 ), color::white ( ), true, false );



	//main math
	auto main_box_in_bounds = mouse_in_range ( cp_render_x, cp_render_y, 150, 150 );
	auto hsv_box_in_bounds = mouse_in_range ( hsv_x, cp_render_y, 10, 150 );
	auto alpha_in_bounds = mouse_in_range ( cp_render_x, cp_render_y + cp_h + 5, 150, 10 );

	render::draw_rect ( cp_render_x, cp_render_y, 150, 150, main_box_in_bounds ? color ( rain_r * 255, rain_g * 255, rain_b * 255 ) : color ( 50, 50, 50 ) );
	render::draw_rect ( hsv_x, cp_render_y, 10, 150, hsv_box_in_bounds ? color ( rain_r * 255, rain_g * 255, rain_b * 255 ) : color ( 50, 50, 50 ) );
	render::draw_rect ( cp_render_x, cp_render_y + cp_h + 5, 150, 10, alpha_in_bounds ? color ( rain_r * 255, rain_g * 255, rain_b * 255 ) : color ( 50, 50, 50 ) );



	if ( main_box_in_bounds && GetAsyncKeyState ( VK_LBUTTON ) ) {
		s = ( cursor.x - cp_render_x ) / ( float ( 150 ) / float ( 1 ) );
	}
	if ( main_box_in_bounds && GetAsyncKeyState ( VK_LBUTTON ) ) {
		v = 1 - ( cursor.y - cp_render_y ) / ( float ( 150 ) / float ( 1 ) );
		v_2 = ( cursor.y - cp_render_y ) / ( float ( 150 ) / float ( 1 ) );
	}
	if ( hsv_box_in_bounds && GetAsyncKeyState ( VK_LBUTTON ) ) {
		h = ( cursor.y - cp_render_y ) / ( float ( 150 ) / float ( 1 ) );
	}
	if ( alpha_in_bounds && GetAsyncKeyState ( VK_LBUTTON ) ) {
		a = ( cursor.x - cp_render_x ) / ( float ( 150 ) / float ( 1 ) );
	}
	output_value.r = clr_r * 255; output_value.g = clr_g * 255; output_value.b = clr_b * 255; output_value.a = a * 255;


	//indicator thingys


	render::draw_rect ( cp_render_x + ( s * 150 ) - 2, cp_render_y + ( v_2 * 150 ) - 2, 6, 6, color ( 0, 0, 0 ) );


	render::draw_rect ( hsv_x, cp_render_y + ( h * 150 ), 10, 5, color ( 0, 0, 0 ) );



	render::draw_rect ( cp_render_x + ( a * 150 ) - 2, cp_render_y + cp_h + 5, 5, 10, color ( 0, 0, 0 ) );







	//copy & pasting function

	auto copy_in_bounds = mouse_in_range ( cp_render_x, button_y, cp_main_w / 2 - 7.5, 20 );
	auto paste_in_bounds = mouse_in_range ( cp_render_x + cp_main_w / 2 + 2.5, button_y, cp_main_w / 2 - 7.5, 20 );

	render::draw_filled_rect ( cp_render_x, button_y, cp_main_w / 2 - 7.5, 20, color ( 20, 20, 20 ) );
	render::draw_rect ( cp_render_x, button_y, cp_main_w / 2 - 7.5, 20, copy_in_bounds ? color ( rain_r * 255, rain_g * 255, rain_b * 255 ) : color ( 50, 50, 50 ) );
	render::draw_filled_rect ( cp_render_x + cp_main_w / 2, button_y, cp_main_w / 2 - 7.5, 20, color ( 20, 20, 20 ) );
	render::draw_rect ( cp_render_x + cp_main_w / 2, button_y, cp_main_w / 2 - 7.5, 20, paste_in_bounds ? color ( rain_r * 255, rain_g * 255, rain_b * 255 ) : color ( 50, 50, 50 ) );
	render::text ( cp_render_x + ( ( cp_main_w / 2 - 7.5 ) / 2 ), button_y + 3, render::fonts::watermark_font, "Copy", true, copy_in_bounds ? color ( rain_r * 255, rain_g * 255, rain_b * 255 ) : color ( 125, 125, 125 ) );
	render::text ( cp_render_x + cp_main_w / 2 + ( ( cp_main_w / 2 - 7.5 ) / 2 ), button_y + 3, render::fonts::watermark_font, "Paste", true, paste_in_bounds ? color ( rain_r * 255, rain_g * 255, rain_b * 255 ) : color ( 125, 125, 125 ) );


	if ( copy_in_bounds && GetAsyncKeyState ( VK_LBUTTON ) & 1 ) {
		variables::last_copied_color = output_value;

	}

	if ( paste_in_bounds && GetAsyncKeyState ( VK_LBUTTON ) & 1 ) {
		output_value = variables::last_copied_color;
		clr_r = variables::last_copied_color.r;
		clr_g = variables::last_copied_color.g;
		clr_b = variables::last_copied_color.b;
	}
}

}`

`void color_convert_hsv_to_rgb ( float h, float s, float v, float& out_r, float& out_g, float& out_b ) {
if ( s == 0.0f ) {
// gray
out_r = out_g = out_b = v;
return;
}

h = ImFmod ( h, 1.0f ) / ( 60.0f / 360.0f );
int   i = ( int ) h;
float f = h - ( float ) i;
float p = v * ( 1.0f - s );
float q = v * ( 1.0f - s * f );
float t = v * ( 1.0f - s * ( 1.0f - f ) );

switch ( i ) {
	case 0: out_r = v; out_g = t; out_b = p; break;
	case 1: out_r = q; out_g = v; out_b = p; break;
	case 2: out_r = p; out_g = v; out_b = t; break;
	case 3: out_r = p; out_g = q; out_b = v; break;
	case 4: out_r = t; out_g = p; out_b = v; break;
	case 5: default: out_r = v; out_g = p; out_b = q; break;
}

}`

@cristeigabriel
Copy link
Contributor

this is retarded

@MyNameIsKodak
Copy link

this shit some ass nigga 💀💀😭

@puppygirlcoded
Copy link
Author

this shit some ass nigga 💀💀😭

ok retard dint ask +ratio +cope +idc +posted at 4am and made at 4am stupid

@MyNameIsKodak
Copy link

iqless

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants