-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add support for gradient patterns.
git-svn-id: svn+ssh://svn.dotswitch.net/var/svn/dotswitch/projects/library/plugins/purl@2117 c432a1ab-ec09-0410-8e5f-fb625be92370
- Loading branch information
nanki
committed
Oct 23, 2008
1 parent
e4857e2
commit f82b179
Showing
3 changed files
with
48 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
module Purl | ||
module Features::CairoGradient | ||
class << self | ||
def operators | ||
[ | ||
Op.new(:'grad.linear', 4, :grad_linear), | ||
Op.new(:'grad.radial', 6, :grad_radial), | ||
Op.new(:'grad.concentric', 4, :grad_concentric), | ||
Op.new(:rgbo, 5, :rgb_stop), | ||
Op.new(:rgbao, 6, :rgba_stop), | ||
] | ||
end | ||
|
||
def grad_linear(x1, y1, x2, y2) | ||
Result.new(::Cairo::LinearPattern.new(x1, y1, x2, y2)) | ||
end | ||
|
||
def grad_radial(x1, y1, r1, x2, y2, r2) | ||
Result.new(::Cairo::RadialPattern.new(x1, y1, r1, x2, y2, r2)) | ||
end | ||
|
||
def grad_concentric(x, y, r1, r2) | ||
Result.new(::Cairo::RadialPattern.new(x, y, r1, x, y, r2)) | ||
end | ||
|
||
def rgb_stop(grad, r, g, b, offset) | ||
raise UnexpectedArgument unless ::Cairo::GradientPattern === grad | ||
grad.add_color_stop_rgb offset, r, g, b | ||
|
||
Result.new(grad) | ||
end | ||
|
||
def rgba_stop(grad, r, g, b, a, offset) | ||
raise UnexpectedArgument unless ::Cairo::GradientPattern === grad | ||
grad.add_color_stop_rgba offset, r, g, b, a | ||
|
||
Result.new(grad) | ||
end | ||
end | ||
end | ||
end |