ClipPath
API reference › HTML SVG › ClipPath
Represents the SVG <clipPath> (clipping path) element for defining clipping paths.
Provides a concrete <clipPath> element implementation that returns SvgBlock::CLIP_PATH and provides opacity
and transform attribute methods.
The <clipPath> element defines a clipping path that can be applied to other SVG elements via the clip-path
property.
Usage example:
use UIAwesome\Html\Svg\{ClipPath, Circle};
$shape = Circle::tag() ->cx(50) ->cy(50) ->r(40) ->fill('currentColor') ->render();
echo ClipPath::tag()->id('clip')->content($shape)->render();See also: https://developer.mozilla.org/en-US/docs/Web/SVG/Element/clipPath (BaseBlock for the base block-level implementation.).
Properties
Section titled “Properties”| Property | Type | Description | Defined by |
|---|---|---|---|
$attributes protected | mixed[] | HTML attributes array used by the implementing class. Default: []. | UIAwesome\ |
$content protected | string | Content string assigned to the element. Default: ''. | UIAwesome\ |
Methods
Section titled “Methods”Method details
Section titled “Method details”clipPathUnits()
Section titled “clipPathUnits() ”public function clipPathUnits(UIAwesome\Html\Svg\Values\CoordinateUnits|string|null $value): staticSets the clipPathUnits attribute for the <clipPath> element.
Creates a new instance with the specified clip path units value for the rendered <clipPath> element.
Parameters
| Parameter | Type | Description |
|---|---|---|
$value | UIAwesome\| | Clip path units value (for example, ‘objectBoundingBox’ or ‘userSpaceOnUse’). |
Returns
static: New instance with the updated clipPathUnits property.
Throws
InvalidArgumentException: if the provided value is not a validCoordinateUnitsenum or string.
opacity()
Section titled “opacity() ”public function opacity(float|int|string|null $value): staticSets the SVG opacity attribute for the element.
Creates a new instance with the specified opacity value for the rendered element.
Parameters
| Parameter | Type | Description |
|---|---|---|
$value | float| | Opacity value (for example, ‘0.5’, or null to unset). |
Returns
static: New instance with the updated opacity attribute.
Throws
InvalidArgumentException: If the value is outside the allowed range (‘0’-‘1’) and notnull.
transform()
Section titled “transform() ”public function transform(string|null $value): staticSets the SVG transform attribute for the element.
Creates a new instance with the specified transform value for the rendered element.
Parameters
| Parameter | Type | Description |
|---|---|---|
$value | string| | Transform value (for example, ‘rotate(45)’, ‘scale(2)’, or null to unset). |
Returns
static: New instance with the updated transform attribute.
getTag()
Section titled “getTag() ”protected function getTag(): BackedEnumReturns the tag enumeration for the <clipPath> element.
Returns
BackedEnum: Tag enumeration instance for <clipPath>. SvgBlock for valid SVG block-level tags.