-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Spec] Shapes #8
Labels
t/enhancement ☀️
New feature or request
Comments
Moved to Xamarin.Forms. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Shapes
A Shape is a type of View that enables you to draw a shape to the screen.
But, hey, why Shapes?
Currently there are Views such as BoxView or Frame that allow us to create elements such as rectangles or ellipses but, there are many more complex shapes. Having a set of Shapes (lines, polygons, etc.) allows a greater number of possibilities when creating attractive and rich user interfaces.
Notice that in the design there are:
API
Next, the Shapes API definition.
NOTE: This API definition is based on WPF Shapes API: https://docs.microsoft.com/en-us/dotnet/framework/wpf/graphics-multimedia/shapes-and-basic-drawing-in-wpf-overview
Shape
To render a Shape, must set the Fill property of the Shape to the Color you want. A Shape can also have a Stroke, which is a line that is drawn around the shape's perimeter. A Stroke also requires a Color that defines its appearance, and should have a non-zero value for StrokeThickness. StrokeThickness is a property that defines the perimeter's thickness around the shape edge.
Ellipse
An Ellipse is a shape with a curved perimeter. To create a basic Ellipse, specify a WidthRequest, HeightRequest, and a Color for the Fill.
Example:
Rectangle
A Rectangle is a four-sided shape with its opposite sides being equal. To create a basic Rectangle, specify a WidthRequest, a HeightRequest, and a Fill.
You can round the corners of a Rectangle. To create rounded corners, specify a value for the RadiusX and RadiusY properties. These properties specify the x-axis and y-axis of an ellipse that defines the curve of the corners.
Example:
Polygon
A Polygon is a shape with a boundary defined by an arbitrary number of points. The boundary is created by connecting a line from one point to the next, with the last point connected to the first point. The Points property defines the collection of points that make up the boundary.
The FillRule property specifies a "rule" which the composite shape uses to determine whether a given point is part of the geometry. There are two possible values for FillRule: EvenOdd and Nonzero.
Example:
Line
A Line is simply a line drawn between two points in coordinate space. For a Line, make sure to specify values for the Stroke and StrokeThickness properties, because otherwise the Line won't render.
Example:
Polyline
A Polyline is similar to a Polygon in that the boundary of the shape is defined by a set of points, except the last point in a Polyline is not connected to the first point.
Example:
Path
A Path is the most versatile Shape because you can use it to define an arbitrary geometry. But with this versatility comes complexity. Define the geometry of a path with the Data property.
Geometry
Where Geometry provides a base class for objects that define geometric shapes.
There will be:
LineGeometry
Represents the geometry of a line.
EllipseGeometry
Represents the geometry of a circle or ellipse.
RectangleGeometry
Describes a two-dimensional rectangle.
PathGeometry
Represents a complex shape that may be composed of arcs, curves, ellipses, lines, and rectangles.
Example:
Clip Views
All views (inherited from IView) have the Clip property of type
Geometry
.(In the previous sample, the header background image is clipped to achieve the diagonal effect).
The following example shows an Image without a defined clip region.
In the next example, an identical Image is created, except that it has a defined clip region.
Applying Styles
We can customize the appearance of Shapes using styles. We can create the styles using XAML or CSS.
Using XAML:
Using CSS:
Difficulty : Medium
The text was updated successfully, but these errors were encountered: