Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //scr_draw_button( x1, y1, x2, y2, coltop, colbias, colbottom, outline, coloutline, shadow, colshadow, percent, steps )
- /*
- x1,y1,x2,y2 are the boundaries of the shape
- coltop is the color of the top of the button
- colbias is the color that the middle is blended towards between coltop and colbottom using a nurb-like technique, it's really cool
- colbottom is the color of the bottom of the button
- outline is whether or not there should be an outline (TRUE/FALSE)
- coloutline is the color of the outline
- shadow is whether there should be a shadow, and how much (0 to 1, 0 is disabled)
- colshadow is the color of the shadow
- percent is the percent of the shape should be rounded (0 to 1, 0 being a rectangle, and 1 being a circle)
- steps is how smooth you want the shape to be, but the smoother it is, the more repetitions it takes in the loop
- */
- //~Jonathan Pearl. No credit neccessary, just don't try to say you made it, because that would be a jerk move. ;)
- var _i,_x1,_y1,_x2,_y2,_col1,_col2,_col3,_perc,_steps,_rat,_doo,_dist,_tcol;
- _x1 = argument0;
- _y1 = argument1;
- _x2 = argument2;
- _y2 = argument3;
- _col1 = argument4;
- _col2 = argument5;
- _col3 = argument6;
- _perc = argument11;
- _steps = argument12;
- draw_primitive_begin( pr_trianglestrip );
- draw_vertex_color( _x1 + _perc*(_x2-_x1)/2, _y1, _col1, 1 );
- draw_vertex_color( _x2 - _perc*(_x2-_x1)/2, _y1, _col1, 1 );
- for( _i = 0; _i < _steps; _i += 1 )
- {
- _rat = scr_linearaverage( _y1, _y2, ( ( -(cos((12*((_i+1) / (_steps+1))-pi)/2)-6*((_i+1) / (_steps+1)))/12)*6/pi ) );
- _doo = abs( ((_y1 + _y2)/2)-_rat)/((_y2 - _y1)/2);
- _dist = -cos(arcsin( _doo ))*_perc*(_x2-_x1)/2;
- _tcol = make_color_rgb( scr_linearaverage( scr_linearaverage(color_get_red(_col1),color_get_red(_col2),(_i+1) / (_steps+1)),
- scr_linearaverage(color_get_red(_col2),color_get_red(_col3),(_i+1) / (_steps+1)), (_i+1) / (_steps+1)),
- scr_linearaverage( scr_linearaverage(color_get_green(_col1),color_get_green(_col2),(_i+1) / (_steps+1)),
- scr_linearaverage(color_get_green(_col2),color_get_green(_col3),(_i+1) / (_steps+1)), (_i+1) / (_steps+1)),
- scr_linearaverage( scr_linearaverage(color_get_blue(_col1),color_get_blue(_col2),(_i+1) / (_steps+1)),
- scr_linearaverage(color_get_blue(_col2),color_get_blue(_col3),(_i+1) / (_steps+1)), (_i+1) / (_steps+1)));
- draw_vertex_color( _x1 + _dist + _perc*(_x2-_x1)/2, _rat , _tcol , 1 );
- draw_vertex_color( _x2 - _dist - _perc*(_x2-_x1)/2, _rat , _tcol , 1 );
- }
- draw_vertex_color( _x1 + _perc*(_x2-_x1)/2, _y2, _col3, 1 );
- draw_vertex_color( _x2 - _perc*(_x2-_x1)/2, _y2, _col3, 1 );
- draw_primitive_end();
- if (argument9!=0)
- {
- draw_primitive_begin( pr_trianglefan );
- draw_vertex_color( (_x2+_x1)/2, (_y1+3*_y2)/4, argument10, .1*argument9 );
- draw_vertex_color( _x1 + _perc*(_x2-_x1)/2, _y1, argument10, 0 );
- draw_vertex_color( _x2 - _perc*(_x2-_x1)/2, _y1, argument10, 0 );
- for( _i = 0; _i < _steps; _i += 1 )
- {
- _rat = scr_linearaverage( _y1, _y2, ( ( -(cos((12*((_i+1) / (_steps+1))-pi)/2)-6*((_i+1) / (_steps+1)))/12)*6/pi ) );
- _doo = abs( ((_y1 + _y2)/2)-_rat)/((_y2 - _y1)/2);
- _dist = -cos(arcsin( _doo ))*_perc*(_x2-_x1)/2;
- draw_vertex_color( _x2 - _dist - _perc*(_x2-_x1)/2, _rat , argument10 , (1-( ((_y1 + _y2)/2)-_rat)/((_y2 - _y1)/2))*argument9 );
- }
- draw_vertex_color( _x2 - _perc*(_x2-_x1)/2, _y2, argument10, (1-( ((_y1 + _y2)/2)-(scr_linearaverage( _y1, _y2, ( ( -(cos((12*((_steps+1) / (_steps+1))-pi)/2)-6*((_i+1) / (_steps+1)))/12)*6/pi ) )))/((_y2 - _y1)/2))*argument9 );
- for( _i = _steps; _i >= 0; _i -= 1 )
- {
- _rat = scr_linearaverage( _y1, _y2, ( ( -(cos((12*((_i+1) / (_steps+1))-pi)/2)-6*((_i+1) / (_steps+1)))/12)*6/pi ) );
- _doo = abs( ((_y1 + _y2)/2)-_rat)/((_y2 - _y1)/2);
- _dist = -cos(arcsin( _doo ))*_perc*(_x2-_x1)/2;
- draw_vertex_color( _x1 + _dist + _perc*(_x2-_x1)/2, _rat , argument10 , (1-( ((_y1 + _y2)/2)-_rat)/((_y2 - _y1)/2))*argument9 );
- }
- draw_vertex_color( _x1 + _perc*(_x2-_x1)/2, _y1, argument10, 0 );
- draw_primitive_end();
- }
- if (argument7)
- {
- draw_primitive_begin( pr_linestrip );
- draw_vertex_color( _x1 + _perc*(_x2-_x1)/2, _y1, argument8, 1 );
- draw_vertex_color( _x2 - _perc*(_x2-_x1)/2, _y1, argument8, 1 );
- for( _i = 0; _i < _steps; _i += 1 )
- {
- _rat = scr_linearaverage( _y1, _y2, ( ( -(cos((12*((_i+1) / (_steps+1))-pi)/2)-6*((_i+1) / (_steps+1)))/12)*6/pi ) );
- _doo = abs( ((_y1 + _y2)/2)-_rat)/((_y2 - _y1)/2);
- _dist = -cos(arcsin( _doo ))*_perc*(_x2-_x1)/2;
- draw_vertex_color( _x2 - _dist - _perc*(_x2-_x1)/2, _rat , argument8 , 1 );
- }
- draw_vertex_color( _x2 - _perc*(_x2-_x1)/2, _y2, argument8, 1 );
- for( _i = _steps; _i >= 0; _i -= 1 )
- {
- _rat = scr_linearaverage( _y1, _y2, ( ( -(cos((12*((_i+1) / (_steps+1))-pi)/2)-6*((_i+1) / (_steps+1)))/12)*6/pi ) );
- _doo = abs( ((_y1 + _y2)/2)-_rat)/((_y2 - _y1)/2);
- _dist = -cos(arcsin( _doo ))*_perc*(_x2-_x1)/2;
- draw_vertex_color( _x1 + _dist + _perc*(_x2-_x1)/2, _rat , argument8 , 1 );
- }
- draw_vertex_color( _x1 + _perc*(_x2-_x1)/2, _y1, argument8, 1 );
- draw_primitive_end();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement