croppy library

Classes

Aabb2
Defines a 2-dimensional axis-aligned bounding box between a min and a max position.
Aabb3
Defines a 3-dimensional axis-aligned bounding box between a min and a max position.
AnimatedCroppableImageViewport
BaseCroppableImageController
A base class for controllers that can be used with this package.
BaseTransformations
A set of base transformations that can be applied to an image.
CropAspectRatio
A crop aspect ratio.
CropImageResult
The result of a crop operation.
CroppableImageController
An abstract controller for images that can be cropped, that provides the different transformations (pan and scale, resize, rotate, etc).
CroppableImageControllerWithMixins
An abstract controller for images with mixins for the different display properties (aspect ratio, resize static layout, viewport scale).
CroppableImageData
CroppableImageDataTween
A tween that interpolates between two CroppableImageDatas.
CroppableImageGestureDetector
A GestureDetector that handles panning and scaling of the image.
CroppableImagePageAnimator
Animates a page transition for a croppable image.
CroppableImagePageAnimatorState
CroppableImageRenderObject
CroppableImageViewport
A widget that displays the croppable image.
CroppableImageWidget
TODO: Document this
CroppedHeroImageRenderObject
CroppedHeroImageWidget
TODO: Document this
CroppyLocalizationProvider
CroppyLocalizations
CroppyLocalizationsAr
CroppyLocalizationsEn
CroppyLocalizationsKk
CroppyLocalizationsPt
CroppyLocalizationsRu
CroppyLocalizationsVi
CropShape
A shape of the crop area. It can be either:
CropShapeClipper
A CustomClipper that clips a region to the shape of a CropShape.
CupertinoAspectRatioIcon
A SFSymbols aspectratio-fill icon.
CupertinoCroppableImageController
A croppable image controller that is similar to the iOS Photos app.
CupertinoFlipHorizontalIcon
A SFSymbols arrow-left-and-right-righttriangle-left-righttriangle-right-fill icon.
CupertinoImageAspectRatioToolbar
CupertinoImageCropHandles
CupertinoImageCropperBottomAppBar
CupertinoImageCropperPage
CupertinoImageCropperWithHeroRoute<T>
CupertinoImageTransformationToolbar
CupertinoKnob
CupertinoKnobButton
CupertinoPerspectiveXIcon
A SFSymbols trapezoid-and-line-vertical-fill icon.
CupertinoPerspectiveYIcon
A SFSymbols trapezoid-and-line-horizontal-fill icon.
CupertinoRotationSlider
CupertinoStraightenIcon
A SFSymbols circle-and-line-horizontal-fill icon.
CupertinoToolbar
DefaultCupertinoCroppableImageController
DefaultMaterialCroppableImageController
Ellipse2
FitPolygonInQuadSolver
Frustum
Defines a frustum constructed out of six Planes.
FutureButton
A button that executes a future when tapped.
IntersectionResult
Defines a result of an intersection test.
LineSegment2
MaterialAspectRatioBottomSheet
MaterialCroppableImageController
MaterialImageCropperBottomAppBar
MaterialImageCropperHandles
MaterialImageCropperPage
MaterialImageCropperToolbar
Matrix2
2D Matrix. Values are stored in column major order.
Matrix3
3D Matrix. Values are stored in column major order.
Matrix4
4D Matrix. Values are stored in column major order.
Obb3
Defines a 3-dimensional oriented bounding box defined with a center, halfExtents and axes.
Plane
Polygon2
Quad
Defines a quad by four points.
Quad2
A 2D quadrilateral.
Quaternion
Defines a Quaternion (a four-dimensional vector) for efficient rotation calculations.
Ray
Defines a Ray by an origin and a direction.
ResizableGestureDetector
A GestureDetector that allows resizing an AABB crop rect from its corners and sides.
SimplexNoise
Sphere
Defines a sphere with a center and a radius.
Triangle
Defines a triangle by three points.
Vector
Base class for vectors
Vector2
2D column vector.
Vector3
3D column vector.
Vector4
4D column vector.

Enums

Corner
Enum for the corners of a rectangle.
CropShapeType
The shape type of a CropShape.
CupertinoCroppableImageToolbar
EditableImageSlot
LocalizationDirection
ResizeDirection
Enum for the direction of a resize.
Transformation
Enum for the different transformations that can be applied to an image.

Mixins

AnimatedControllerMixin
AspectRatioMixin
A mixin for the CroppableImageController that allows to keep the aspect ratio of the crop rect.
MirrorTransformation
Provides methods for mirroring the image.
PanAndScaleTransformation
A mixin for BaseCroppableImageController that adds pan and scale functionality.
ResizeStaticLayoutMixin
A mixin for the CroppableImageController that allows to keep the layout static while resizing.
ResizeTransformation
A mixin that provides resizing functionality to a BaseCroppableImageController.
RotateTransformation
Provides methods for rotating the image.
StraightenAndPerspectiveTransformation
A mixin that adds straightening and perspective functionality to a BaseCroppableImageController.
TransformationFrictionMixin
ViewportScaleComputerMixin

Extensions

Aabb2Utils on Aabb2
Some utility methods for working with Aabb2.
RectToAabb2 on Rect
Some utility methods for working with Rect and Aabb2.
RectTransform on Rect
SizeArea on Size
ToEulerAngles on Quaternion
Converts a Quaternion to Euler angles.
TriangleContainsPoint on Triangle
Some utility methods for working with Triangle.
Vector2FromVector3 on Vector3
Some utility methods for working with Vector3
Vector2Utils on Vector2
Some utility methods for working with Vector2
VectorFromOffset on Offset
Some utility methods for working with Offset

Constants

degrees2Radians → const double
Constant factor to convert and angle from degrees to radians.
epsilon → const double
A small value used as the default epsilon for comparisons.
kCupertinoImageCropperBackgroundColor → const Color
kCupertinoImageCropperPageTransitionDuration → const Duration
radians2Degrees → const double
Constant factor to convert and angle from radians to degrees.

Properties

croppyForceUseCassowaryDartImpl bool
If true, the Dart implementation of fitPolygonInQuadImpl will be used instead of the C++ implementation.
getter/setter pair

Functions

aabbCropShapeFn(PathBuilder builder, Size size) CropShape
A function that provides a rectangular crop path for a given size.
absoluteError(dynamic calculated, dynamic correct) double
Returns absolute error between calculated and correct. The type of calculated and correct must match and can be any vector, matrix, or quaternion.
buildPlaneVectors(Vector3 planeNormal, Vector3 u, Vector3 v) → void
Sets u and v to be two vectors orthogonal to each other and planeNormal.
catmullRom(double edge0, double edge1, double edge2, double edge3, double amount) double
Do a catmull rom spline interpolation with edge0, edge1, edge2 and edge3 by amount.
clampAngle(double angleRad) double
Clamps an angle to the range of 0 to 2pi
cropImage(Image image, CroppableImageData data) Future<CropImageResult>
Crops an ui.Image using the CroppableImageData and returns the cropped image as a CropImageResult.
cross2(Vector2 x, Vector2 y) double
2D cross product. vec2 x vec2.
cross2A(double x, Vector2 y, Vector2 out) → void
2D cross product. double x vec2.
cross2B(Vector2 x, double y, Vector2 out) → void
2D cross product. vec2 x double.
cross3(Vector3 x, Vector3 y, Vector3 out) → void
3D Cross product.
degrees(double radians) double
Convert radians to degrees.
dot2(Vector2 x, Vector2 y) double
2D dot product.
dot3(Vector3 x, Vector3 y) double
3D dot product.
ellipseCropShapeFn(PathBuilder builder, Size size) CropShape
A function that provides an elliptical crop path for a given size.
generateMaterialImageCropperTheme(BuildContext context) ThemeData
lerpMatrix4(Matrix4? a, Matrix4? b, double t) Matrix4
Linearly interpolates between two Matrix4s using Matrix4Tween.
lookupCroppyLocalizations(Locale locale) CroppyLocalizations
makeFrustumMatrix(double left, double right, double bottom, double top, double near, double far) Matrix4
Constructs a new OpenGL perspective projection matrix.
makeInfiniteMatrix(double fovYRadians, double aspectRatio, double zNear) Matrix4
Constructs a new OpenGL infinite projection matrix.
makeOrthographicMatrix(double left, double right, double bottom, double top, double near, double far) Matrix4
Constructs a new OpenGL orthographic projection matrix.
makePerspectiveMatrix(double fovYRadians, double aspectRatio, double zNear, double zFar) Matrix4
Constructs a new OpenGL perspective projection matrix.
makePlaneProjection(Vector3 planeNormal, Vector3 planePoint) Matrix4
Returns a transformation matrix that transforms points onto the plane specified with planeNormal and planePoint.
makePlaneReflection(Vector3 planeNormal, Vector3 planePoint) Matrix4
Returns a transformation matrix that transforms points by reflecting them through the plane specified with planeNormal and planePoint.
makeViewMatrix(Vector3 cameraPosition, Vector3 cameraFocusPosition, Vector3 upDirection) Matrix4
Constructs a new OpenGL view matrix.
matrix3Adj(Matrix3 m) Matrix3
Computes an adjugate matrix.
mix(double min, double max, double a) double
Interpolate between min and max with the amount of a using a linear interpolation. The computation is equivalent to the GLSL function mix.
obtainImage(ImageProvider<Object> provider) Future<Image>
Obtains an ui.Image from an ImageProvider.
pickRay(Matrix4 cameraMatrix, num viewportX, num viewportWidth, num viewportY, num viewportHeight, num pickX, num pickY, Vector3 rayNear, Vector3 rayFar) bool
On success, rayNear and rayFar are the points where the screen space pickX, pickY intersect with the near and far planes respectively.
polygonFromPath(Path path) Polygon2
radians(double degrees) double
Convert degrees to radians.
relativeError(dynamic calculated, dynamic correct) double
Returns relative error between calculated and correct. The type of calculated and correct must match and can be any vector, matrix, or quaternion.
resizeCropRectWithAspectRatio(Rect cropRect, CropAspectRatio? newAspectRatio) Rect
Resizes a given cropRect to match the given newAspectRatio.
setFrustumMatrix(Matrix4 perspectiveMatrix, double left, double right, double bottom, double top, double near, double far) → void
Constructs an OpenGL perspective projection matrix in perspectiveMatrix.
setInfiniteMatrix(Matrix4 infiniteMatrix, double fovYRadians, double aspectRatio, double zNear) → void
Constructs an OpenGL infinite projection matrix in infiniteMatrix. fovYRadians specifies the field of view angle, in radians, in the y direction. aspectRatio specifies the aspect ratio that determines the field of view in the x direction. The aspect ratio of x (width) to y (height). zNear specifies the distance from the viewer to the near plane (always positive).
setModelMatrix(Matrix4 modelMatrix, Vector3 forwardDirection, Vector3 upDirection, double tx, double ty, double tz) → void
Constructs an OpenGL model matrix in modelMatrix. Model transformation is the inverse of the view transformation. Model transformation is also known as "camera" transformation. Model matrix is commonly used to compute a object location/orientation into the full model-view stack.
setOrthographicMatrix(Matrix4 orthographicMatrix, double left, double right, double bottom, double top, double near, double far) → void
Constructs an OpenGL orthographic projection matrix in orthographicMatrix.
setPerspectiveMatrix(Matrix4 perspectiveMatrix, double fovYRadians, double aspectRatio, double zNear, double zFar) → void
Constructs an OpenGL perspective projection matrix in perspectiveMatrix.
setRotationMatrix(Matrix4 rotationMatrix, Vector3 forwardDirection, Vector3 upDirection) → void
Constructs a rotation matrix in rotationMatrix.
setViewMatrix(Matrix4 viewMatrix, Vector3 cameraPosition, Vector3 cameraFocusPosition, Vector3 upDirection) → void
Constructs an OpenGL view matrix in viewMatrix. View transformation is the inverse of the model transformation. View matrix is commonly used to compute the camera location/orientation into the full model-view stack.
showCupertinoImageCropper(BuildContext context, {required ImageProvider<Object> imageProvider, CroppableImageData? initialData, CroppableImagePostProcessFn? postProcessFn, CropShapeFn? cropPathFn, List<CropAspectRatio?>? allowedAspectRatios, List<Transformation>? enabledTransformations, Object? heroTag, bool shouldPopAfterCrop = true, Locale? locale}) Future<CropImageResult?>
Shows a CupertinoImageCropperPage and returns the cropped image.
showMaterialImageCropper(BuildContext context, {required ImageProvider<Object> imageProvider, CroppableImageData? initialData, CroppableImagePostProcessFn? postProcessFn, CropShapeFn? cropPathFn, List<CropAspectRatio?>? allowedAspectRatios, List<Transformation>? enabledTransformations, Object? heroTag, bool shouldPopAfterCrop = true, Locale? locale}) Future<CropImageResult?>
Shows a CupertinoImageCropperPage and returns the cropped image.
smoothStep(double edge0, double edge1, double amount) double
Do a smooth step (hermite interpolation) interpolation with edge0 and edge1 by amount. The computation is equivalent to the GLSL function smoothstep.
starCropShapeFn(PathBuilder builder, Size size) CropShape
A function that provides a star crop path for a given size.
unproject(Matrix4 cameraMatrix, num viewportX, num viewportWidth, num viewportY, num viewportHeight, num pickX, num pickY, num pickZ, Vector3 pickWorld) bool
On success, Sets pickWorld to be the world space position of the screen space pickX, pickY, and pickZ.

Typedefs

CroppableImagePostProcessFn = Future<CropImageResult> Function(CropImageResult result)
A function that is called in crop as a post-processing function. Use it to, for example, compress the image, or update the state in the preview page.
CropShapeFn = CropShape Function(PathBuilder builder, Size size)
A function that provides the crop path for a given size.