Package com.oorian.css
Class ClipPath
java.lang.Object
com.oorian.css.ClipPath
A builder for composing CSS
clip-path property values.
ClipPath provides a type-safe, fluent API for building CSS clip-path strings. Only one shape can be active at a time — each shape method replaces the current value.
Usage:
// Circle clip
element.setClipPath(new ClipPath().circle("50%"));
// Result: clip-path: circle(50%)
// Polygon clip (triangle)
element.setClipPath(new ClipPath()
.polygon("50% 0%", "100% 100%", "0% 100%"));
// Result: clip-path: polygon(50% 0%, 100% 100%, 0% 100%)
// Inset with rounded corners
element.setClipPath(new ClipPath()
.insetRound("10px 20px 30px 40px", "5px"));
// Result: clip-path: inset(10px 20px 30px 40px round 5px)
// Use with CssRule
CssRule rule = new CssRule(".clipped");
rule.setClipPath(new ClipPath().ellipse("50%", "40%"));
- Since:
- 2026
- Version:
- 1.0
- Author:
- Marvin P. Warble Jr.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncircle(int pixels) Sets acircle()clip shape with a pixel radius.Sets acircle()clip shape with aUnitsradius.Sets acircle()clip shape.Sets acircle()clip shape with a pixel radius and position.Sets acircle()clip shape with aUnitsradius and position.Sets acircle()clip shape with a position.ellipse(int rx, int ry) Sets anellipse()clip shape with pixel radii.Sets anellipse()clip shape withUnitsradii.Sets anellipse()clip shape.Sets anellipse()clip shape with pixel radii and a position.Sets anellipse()clip shape withUnitsradii and a position.Sets anellipse()clip shape with a position.inset(int pixels) Sets a uniforminset()clip shape with a pixel value.inset(int top, int right, int bottom, int left) Sets aninset()clip shape with individual pixel values for each side.Sets a uniforminset()clip shape with aUnitsvalue.Sets aninset()clip shape with individualUnitsvalues for each side.Sets aninset()clip shape.insetRound(int pixels, int borderRadiusPx) Sets aninset()clip shape with a pixel inset and pixel border radius.insetRound(String values, String borderRadius) Sets aninset()clip shape with rounded corners.Sets apath()clip shape using an SVG path string.Sets apolygon()clip shape.toString()Returns the CSS clip-path string.Sets aurl()reference to an SVG clipPath element.
-
Constructor Details
-
ClipPath
public ClipPath()Constructs an empty ClipPath.
-
-
Method Details
-
circle
Sets acircle()clip shape.- Parameters:
radius- the circle radius (e.g.,"50%","100px","closest-side")- Returns:
- this ClipPath for method chaining
-
circle
Sets acircle()clip shape with a pixel radius.- Parameters:
pixels- the circle radius in pixels- Returns:
- this ClipPath for method chaining
-
circle
Sets acircle()clip shape with aUnitsradius.- Parameters:
radius- the circle radius as a Units value (e.g.,new Px(100),new Percent(50))- Returns:
- this ClipPath for method chaining
-
circleAt
Sets acircle()clip shape with a position.- Parameters:
radius- the circle radius (e.g.,"50%","100px")position- the center position (e.g.,"50% 50%","center")- Returns:
- this ClipPath for method chaining
-
circleAt
Sets acircle()clip shape with a pixel radius and position.- Parameters:
pixels- the circle radius in pixelsposition- the center position (e.g.,"50% 50%","center")- Returns:
- this ClipPath for method chaining
-
circleAt
Sets acircle()clip shape with aUnitsradius and position.- Parameters:
radius- the circle radius as a Units valueposition- the center position (e.g.,"50% 50%","center")- Returns:
- this ClipPath for method chaining
-
ellipse
Sets anellipse()clip shape.- Parameters:
rx- the horizontal radius (e.g.,"50%","100px")ry- the vertical radius (e.g.,"40%","80px")- Returns:
- this ClipPath for method chaining
-
ellipse
Sets anellipse()clip shape with pixel radii.- Parameters:
rx- the horizontal radius in pixelsry- the vertical radius in pixels- Returns:
- this ClipPath for method chaining
-
ellipse
Sets anellipse()clip shape withUnitsradii.- Parameters:
rx- the horizontal radius as a Units valuery- the vertical radius as a Units value- Returns:
- this ClipPath for method chaining
-
ellipseAt
Sets anellipse()clip shape with a position.- Parameters:
rx- the horizontal radius (e.g.,"50%")ry- the vertical radius (e.g.,"40%")position- the center position (e.g.,"50% 50%","center")- Returns:
- this ClipPath for method chaining
-
ellipseAt
Sets anellipse()clip shape with pixel radii and a position.- Parameters:
rx- the horizontal radius in pixelsry- the vertical radius in pixelsposition- the center position (e.g.,"50% 50%","center")- Returns:
- this ClipPath for method chaining
-
ellipseAt
Sets anellipse()clip shape withUnitsradii and a position.- Parameters:
rx- the horizontal radius as a Units valuery- the vertical radius as a Units valueposition- the center position (e.g.,"50% 50%","center")- Returns:
- this ClipPath for method chaining
-
inset
Sets aninset()clip shape.- Parameters:
values- the inset values (e.g.,"10px","10px 20px 30px 40px")- Returns:
- this ClipPath for method chaining
-
inset
Sets a uniforminset()clip shape with a pixel value.- Parameters:
pixels- the uniform inset distance in pixels- Returns:
- this ClipPath for method chaining
-
inset
Sets a uniforminset()clip shape with aUnitsvalue.- Parameters:
inset- the uniform inset distance as a Units value- Returns:
- this ClipPath for method chaining
-
inset
Sets aninset()clip shape with individual pixel values for each side.- Parameters:
top- the top inset in pixelsright- the right inset in pixelsbottom- the bottom inset in pixelsleft- the left inset in pixels- Returns:
- this ClipPath for method chaining
-
inset
Sets aninset()clip shape with individualUnitsvalues for each side.- Parameters:
top- the top inset as a Units valueright- the right inset as a Units valuebottom- the bottom inset as a Units valueleft- the left inset as a Units value- Returns:
- this ClipPath for method chaining
-
insetRound
Sets aninset()clip shape with rounded corners.- Parameters:
values- the inset values (e.g.,"10px 20px 30px 40px")borderRadius- the border-radius for the inset (e.g.,"5px","10px 20px")- Returns:
- this ClipPath for method chaining
-
insetRound
Sets aninset()clip shape with a pixel inset and pixel border radius.- Parameters:
pixels- the uniform inset distance in pixelsborderRadiusPx- the border-radius in pixels- Returns:
- this ClipPath for method chaining
-
polygon
Sets apolygon()clip shape.- Parameters:
points- the polygon vertex points (e.g.,"50% 0%", "100% 100%", "0% 100%")- Returns:
- this ClipPath for method chaining
-
path
Sets apath()clip shape using an SVG path string.- Parameters:
svgPath- the SVG path data (e.g.,"M0,0 L100,0 L100,100 Z")- Returns:
- this ClipPath for method chaining
-
url
Sets aurl()reference to an SVG clipPath element.- Parameters:
url- the URL or fragment reference (e.g.,"#clipId","clip.svg#myClip")- Returns:
- this ClipPath for method chaining
-
toString
Returns the CSS clip-path string.
-