top of page

Level I Division

Public·12 members
Sibyl Fendley
Sibyl Fendley

React Draw Shapes


React Draw Shapes

All react-konva components correspond to Konva components of the same name.All the parameters available for Konva objects are valid props forcorresponding react-konva components, unless noted otherwise.

is an HTML element that helps you to draw shapes. You can draw shapes inside a canvas element using the Canvas API provided by your browser. This element acts as a container in which you can draw different shapes. To draw inside a canvas element, a context for the element is required. A context is an entity that we can draw shapes on. We can use getContext to get the CanvasRenderingContext2D that returns the 2-D context.

The process that we are going to follow is very similar to what we had in the Square component. In the square component, we made use of the onClick attribute of the canvas element to draw a rectangle on the mouse click event. Similarly, we are going to make use of the onMouseMove attribute of the canvas element.

After drawing a bit of inspiration from The Shapes of CSS I decided to see if I could remake some of these shapes with a subset of css. If you haven't been on css-tricks check them out, Chris Coyier is fantastic!

Of course we have access to react-art here so drawing shapes is pretty simple but my goal is to see if I can just use normal Views and all of the styles I have at my exposure to make as many shapes as I can off of the Shapes of CSS list.

Well we don't have the ability to do pseudo elements but they were just hacks anyway so we'll just create a wrapping View with 2 elements and style them.Now this is not exactly the same, and it's partially due to the way border-radius are managed in react-native vs the web but it's closeish.

You can add various shapes to your map. A shape is an object on the map, tied to a latitude/longitude coordinate. The following shapes are available: lines, polygons, circles and rectangles. You can also configure your shapes so that users can edit or drag them.

To draw a line on your map, use a polyline. The Polyline class defines a linear overlay of connected line segments on the map. A Polyline object consists of an array of LatLng locations, and creates a series of line segments that connect those locations in an ordered sequence.

Polyline objects are drawn as a series of straight segments on the map. You can specify custom colors, weights, and opacities for the stroke of the line within the PolylineOptions when constructing your line, or you can change those properties after construction. A polyline supports the following stroke styles:

A polygon represents an area enclosed by a closed path (or loop), which is defined by a series of coordinates. Polygon objects are similar to Polyline objects in that they consist of a series of coordinates in an ordered sequence. Polygons are drawn with a stroke and a fill. You can define custom colors, weights, and opacities for the edge of the polygon (the stroke) and custom colors and opacities for the enclosed area (the fill). Colors should be indicated in hexadecimal HTML format. Color names are not supported.

The Polygon in the example above consists of four sets of LatLng coordinates, but notice that the first and last sets define the same location, which completes the loop. In practice, however, since polygons define closed areas, you don't need to specify the last set of coordinates. The Maps JavaScript API will automatically complete the polygon by drawing a stroke connecting the last location back to the first location for any given path.

In a geodesic polyline, the segments of the polyline are drawn as the shortest path between two points on the Earth's surface, assuming the Earth is a sphere, as opposed to straight lines on the Mercator projection.

To draw a shape, set the JSON of that shape to the drawType property of the diagram and activate the drawing tool by using the tool property. The following code example illustrates how to draw a rectangle at runtime.

To draw connectors, set the JSON of


Welcome to the Level I Division group! Here, you can connect...


bottom of page