-
-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9e51210
commit d0a6ca4
Showing
36 changed files
with
1,539 additions
and
533 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
#pragma once | ||
|
||
#include <karm-mime/url.h> | ||
|
||
#include "angle.h" | ||
#include "color.h" | ||
#include "percent.h" | ||
|
||
// https://www.w3.org/TR/css-images-4/ | ||
|
||
namespace Vaev { | ||
|
||
struct Image; | ||
|
||
// MARK: Linear Gradient ------------------------------------------------------- | ||
// https://www.w3.org/TR/css-images-4/#linear-gradients | ||
|
||
struct LinearGradient { | ||
struct Stop { | ||
Gfx::Color color; | ||
Percent position; | ||
|
||
void repr(Io::Emit &e) const { | ||
e("({} {})", color, position); | ||
} | ||
}; | ||
|
||
Angle angle; | ||
ColorSpace colorSpace = ColorSpace::SRGB; | ||
Vec<Stop> stops; | ||
|
||
void repr(Io::Emit &e) const { | ||
e("(linear-gradient {} {} {}", angle, colorSpace, stops); | ||
} | ||
}; | ||
|
||
// MARK: Radial Gradient ------------------------------------------------------- | ||
// https://www.w3.org/TR/css-images-4/#radial-gradients | ||
|
||
struct RadialGradient { | ||
enum struct Shape { | ||
CIRCLE, | ||
ELLIPSE, | ||
|
||
_LEN, | ||
}; | ||
|
||
Math::Vec2f size; | ||
Math::Vec2f position; | ||
ColorSpace colorSpace = ColorSpace::SRGB; | ||
Vec<LinearGradient::Stop> stops; | ||
|
||
void repr(Io::Emit &e) const { | ||
e("(radial-gradient {} {} {} {}", size, position, colorSpace, stops); | ||
} | ||
}; | ||
|
||
// MARK: Conic Gradient -------------------------------------------------------- | ||
// https://www.w3.org/TR/css-images-4/#conic-gradients | ||
|
||
struct ConicGradient { | ||
struct Stop { | ||
Gfx::Color color; | ||
Angle angle; | ||
|
||
void repr(Io::Emit &e) const { | ||
e("({} {})", color, angle); | ||
} | ||
}; | ||
|
||
Angle angle; | ||
Math::Vec2f position; | ||
ColorSpace colorSpace = ColorSpace::SRGB; | ||
Vec<LinearGradient::Stop> stops; | ||
|
||
void repr(Io::Emit &e) const { | ||
e("(conic-gradient {} {} {} {}", angle, position, colorSpace, stops); | ||
} | ||
}; | ||
|
||
// MARK: Cross Fade ------------------------------------------------------------ | ||
// https://www.w3.org/TR/css-images-4/#cross-fade-function | ||
|
||
struct CrossFade { | ||
struct Layer { | ||
Box<Image> image; | ||
Percent opacity; | ||
|
||
void repr(Io::Emit &e) const { | ||
e("({} {})", image, opacity); | ||
} | ||
}; | ||
|
||
Vec<Layer> layers; | ||
|
||
void repr(Io::Emit &e) const { | ||
e("(cross-fade {}", layers); | ||
} | ||
}; | ||
|
||
// MARK: Stripes --------------------------------------------------------------- | ||
// https://www.w3.org/TR/css-images-4/#stripes | ||
|
||
struct Stripes { | ||
struct Strip { | ||
Gfx::Color color; | ||
Percent size; | ||
|
||
void repr(Io::Emit &e) const { | ||
e("({} {})", color, size); | ||
} | ||
}; | ||
|
||
Vec<Strip> stripes; | ||
|
||
void repr(Io::Emit &e) const { | ||
e("(stripes {}", stripes); | ||
} | ||
}; | ||
|
||
// MARK: Image ----------------------------------------------------------------- | ||
// https://www.w3.org/TR/css-images-4/#typedef-image | ||
|
||
using _Image = Union< | ||
Gfx::Color, | ||
LinearGradient, | ||
RadialGradient, | ||
ConicGradient, | ||
CrossFade, | ||
Stripes, | ||
Mime::Url>; | ||
|
||
struct Image : public _Image { | ||
using _Image::_Image; | ||
|
||
void repr(Io::Emit &e) const { | ||
visit([&](auto const &i) { | ||
e("{}", i); | ||
}); | ||
} | ||
}; | ||
|
||
} // namespace Vaev |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.