mirror of
https://github.com/reanimate/reanimate.git
synced 2026-09-10 23:52:22 +00:00
Add 'withViewBox'
Former-commit-id: 1a763b558770bd865ea229dee9ed0388b4bb7126
This commit is contained in:
parent
ef8121d66e
commit
0a67c8d5a3
2 changed files with 22 additions and 0 deletions
|
|
@ -1,5 +1,9 @@
|
|||
# Revision history for reanimate
|
||||
|
||||
## 0.3.2.0 -- unreleased
|
||||
|
||||
* Add helper for creating custom viewboxes.
|
||||
|
||||
## 0.3.1.0 -- 2020-05-12
|
||||
|
||||
* Expose 'mkImage'
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ module Reanimate.Svg.Constructors
|
|||
, aroundCenterX
|
||||
, aroundCenterY
|
||||
, withTransformations
|
||||
, withViewBox
|
||||
-- * Other
|
||||
, mkColor
|
||||
, mkBackground
|
||||
|
|
@ -368,3 +369,20 @@ mkText str =
|
|||
-- be overwritten by the user.
|
||||
where
|
||||
span_ = defaultSvg & spanContent .~ [SpanText str]
|
||||
|
||||
-- | Switch from the default viewbox to a custom viewbox. Nesting custom viewboxes is
|
||||
-- unlikely to give good results. If you need nested custom viewboxes, you will have
|
||||
-- to configure them by hand.
|
||||
--
|
||||
-- The viewbox argument is (min-x, min-y, width, height).
|
||||
withViewBox :: (Double, Double, Double, Double) -> Tree -> Tree
|
||||
withViewBox vbox child = translate (-screenWidth/2) (-screenHeight/2) $
|
||||
SvgTree $ Document
|
||||
{ _viewBox = Just vbox
|
||||
, _width = Just (Num screenWidth)
|
||||
, _height = Just (Num screenHeight)
|
||||
, _elements = [child]
|
||||
, _description = ""
|
||||
, _documentLocation = ""
|
||||
, _documentAspectRatio = PreserveAspectRatio False AlignNone Nothing
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue