The gloop
function blends the current shape in the Sdf2d
drawing context with the previously stored shape, creating a smooth, organic transition between them. This blending technique is often used to produce fluid, blobby effects similar to metaballs.
Sdf2d
instance. The function modifies the internal shape
and old_shape
fields of self
to represent the blended shape.float
): The smoothing factor controlling the blend between the current shape and the previously stored shape. A larger k
value results in a smoother, more gradual transition.self
to reflect the blended shape.In this example:
Sdf2d
drawing context scaled to the size of the current rectangle (self.rect_size
).(40.0, 50.0)
with a radius of 30.0
.sdf.union()
to store the current shape in self.old_shape
, preparing for blending.(70.0, 50.0)
with the same radius.sdf.gloop(10.0)
, we blend the current shape (self.dist
) with the stored shape (self.old_shape
) using a smoothing factor of 10.0
. This creates a smooth transition between the two circles.sdf.fill(#f00)
to fill the blended shape with red color.sdf.result
, which contains the final rendered image with the blended shape.k
): The value of k
determines how smoothly the shapes blend together. A larger k
results in a softer, more fluid transition. Experiment with different values to achieve the desired effect.gloop
function blends the signed distance fields of two shapes, allowing for complex, organic forms.gloop
, ensure that you have defined both shapes you wish to blend and have stored the initial shape using sdf.union()
or another combining function.rotate
, translate
, or scale
to manipulate the shapes before or after blending.sdf.union()
, sdf.intersect()
, or sdf.subtract()
for other shape combination operations.gloop
function is useful in generating procedural graphics where smooth transitions between shapes are required, such as in fluid simulations, soft-body animations, or artistic effects.