NOTE: This code is not intended to add an effect to the surface but create a new surface containing only the effect.
Example:

EDIT: I figured out the problem, but I haven't found a solution. The alpha for the soft radius is not being calculated correctly.
//surface_effect_from_surface(surface, xscale, yscale, color, alpha, hardradius, softradius)
//By Tiby312
//Modified by jimn346
//Initialize the variables.
var surface, width, height, newsurf, softradius, alpha, xscale, yscale, color, hardradius, tempsurf;
//Set the arguments to the variables.
surface = argument0;
xscale = argument1;
yscale = argument2;
color = argument3;
alpha = argument4;
hardradius = argument5 + 1;
softradius = argument6;
//Set the width and height of the drawing board.
width = (surface_get_width(surface) * xscale) + ((softradius + hardradius) * 2) + 2;
height = (surface_get_height(surface) * yscale) + ((softradius + hardradius) * 2) + 2;
//Create the new surface.
newsurf = surface_create(width, height);
//Start drawing on the new surface.
surface_set_target(newsurf);
//Set the drawing board to clear white.
draw_clear_alpha(c_white, 0);
//Turn d3d fog on so that the image drawn is just white.
d3d_set_fog(true, c_white, 0, 0);
//Turn on additive blending so the new alpha values won't replace the old ones, but instead blend with them.
draw_set_blend_mode(bm_add);
//Draw the hard radius.
var blurinc;
blurinc = hardradius + 10;
for(ii = 0; ii < hardradius; ii += 1;)
{
for(i = 0; i < 360; i += 360 / blurinc;)
{
draw_surface_ext(surface, lengthdir_x(ii, i), - lengthdir_y(ii, i), xscale, yscale, 0, c_white, 1);
}
}
//Draw the soft radius.
var blurrad, blurinc, alpha, tempalpha;
blurrad = hardradius + softradius;
blurinc = softradius + hardradius + 10;
tempalpha = 1 / blurinc;
for(ii = hardradius; ii < blurrad; ii += 1;)
{
for(i = 0; i < 360; i += 360 / blurinc;)
{
draw_surface_ext(surface, lengthdir_x(ii, i), - lengthdir_y(ii, i), xscale, yscale, 0, c_white, tempalpha);
}
}
//Turn fog off.
d3d_set_fog(false, 0, 0, 0);
//Turn off additive blending so that the new image will replace the old one and images will be drawn to the screen normally.
draw_set_blend_mode(bm_normal);
//Create a temporary surface for editing.
tempsurf = surface_create(width, height);
//Start drawing on the temporary surface.
surface_set_target(tempsurf);
//Duplicate the previous surface to this one in the correct alpha and color.
draw_surface_ext(newsurf, 0, 0, 1, 1, 0, color, alpha);
//Start drawing on the new surface.
surface_set_target(newsurf);
//Set the drawing board to a transparent version of the final color.
draw_clear_alpha(color, 0);
//Draw the duplicated surface back onto the original.
draw_surface_ext(tempsurf, 0, 0, 1, 1, 0, c_white, 1);
//Set drawing to be on the screen.
surface_reset_target();
//Delete the temporary surface.
surface_free(tempsurf);
//Return the ID of the new surface.
return newsurf;Old code:
Spoiler



Find content
Male

