I'm looking a way to draw shapes in a Region (JavaFX8)
I've seen some examples that set the region style like this:
-fx-shape : "M 3.0313 0 L 0 74 L 7.9688 74 L 4.9375 0 L 3.0313 0 Z";
Can anyone give an explanation of the meaning of this string?
Is there any way to create this type of string using Visual Software?
The shape string is an SVG Path.
Note the shape string for a region is the shape of the region, not a shape in a region. If you want to create shapes based on paths to put in a region, then use an SVGPath and not a Region.
You can use an SVG editor to create SVG paths.
Recommending particular SVG editors is off topic for StackOverflow, try Google and you may find Inkscape (and it's option Path | Object to Path).
Related
i am working on generating vector tiles for world .well i supposed to use some shape files( like ocean,water,landcover,waterway) with different files for different zoom levels
for example : ne_110m_glaciated_areas for zoom level 0 and ne_50m_glaciated_areas for zoomlevel 2 ...ect..its from osm schema
i got some general files from some Natural earth data websites..but could not get all of them.So please help me to get all required shape files or do we have to generate them with any tools ?
Thanks
I found them from below websites
1.https://www.naturalearthdata.com/downloads/
2.https://github.com/nvkelso/natural-earth-vector/tree/master/10m_cultural
I've grabbed some code from somewhere to create an interactive UK map using SVG.
You can see it here:
I'm wondering how I can get the blue area into one big polygon as opposed to separate areas. Any help would seriously appreciated!
Many thanks in advance.
You can group the smaller polygon paths like
<g id="England">
<path .... />
<path .... />
<path .... />
</g>
and then treat them as 1 larger polygon for the purposes of color fill and click area. If you want to remove the inner borders just set the stroke to the same color as the fill.
The only thing you can't do is stroke the outer group since it itself doesn't have a shape, its just the collection of the inner shapes and theres no way to just stroke the edges that do not border another group member. For that you probably would need to actually merge the polygons, which might be easier to do in Inkscape or Adobe Illustrator
See my example here where I've grouped the western US states. Click anywhere in the group to change the color. In the svg(html panel) code, the CA-WA-OR are the last 3 paths at the bottom...
http://jsfiddle.net/webchemist/K9jdD/
Get the original geographic data file in a 'shapefile' or other geospatial data format, load into a GIS package (Quantum GIS is free, open source, and featureful) then do a polygon dissolve operation.
You can also do this with the GEOS library which has an interface to C, Python and R if you can program in any of those languages.
Im trying to create a + sign as an SVG path for a google maps project. The plus symbol will be plotted along a polyline using the Icon path property. So far I've manage to get close, my plus symbol currently looks like a horizontal line with the vertical set at one end "-|". I need it to appear in the middle of the horizontal line to make it look like a plus.
My current path is set using the following path command:
path: 'M 0,-1 0,1 H -1,1 0,1'
How should I alter this to achieve my plus symbol? I can find lots of examples for much more complex shapes, curves, gradient fills and such forth but with my limited knowledge Im struggling to find the correct coordinates to express my shape!
I think what you want is:
path: 'M0,-1 V1 M-1,0 H1'
Which translates as start at (0, -1), draw vertically 1 unit, then move to (-1, 0) and draw horizontally 1 unit.
Whilst Im fairly sure this isn't the most succinct way to describe this path Ive managed to construct a plus sign using the following path statement [More by trial and error and some very fuzzy memories of Turtle]:
path: 'M 0,0 H 0.5,0.5 1,1 M 0,0 V 0.5,0.5 1,1 M 0,0 H -0.5,-0.5 -1,-1 M 0,0 V -0.5,-0.5 -1,-1',
A question from a novice. Is it possible to design a tool to select color range and create a vector map within that given range to integrate into a flash tool? basically a feature that mimics the wand tool effect in photoshop, but creating a vector outline of the range selected. Any reading material to help with this would be greatly appreciated.
I think you are looking for either 2D segmentation, if you want all the selected colors in the image to be selected, or flood fill if you want to find the region surrounding some initial point where all the colors are in the desired range.
When you say vector map, I imagine you mean the outline of the pixels to select. In which case it's probably easier to find the pixels you want and then draw round then rather than explicitly creating a polygon to contain them.
This question already has an answer here:
Can I get vector data back out out of a Graphics object?
(1 answer)
Closed 9 years ago.
EDIT (for clarification):
I have a vector image with a simple contour, an irregular closed polygon.
I need to import it into Flash in a way that I can then programmatically access each of the segments that form the polygon.
Importing the vector image into the library as a MovieClip wasn't good because all I get is a shape from which I can take no geometry information at all.
My goal is being able to calculate the polygon's area and also calculating the intersection between the polygon and another polygon.
I guess I could write an Illustrator script that reads all the segments and writes a CSV files with their coordinates, but there has to be a simpler way, I mean, they're both vectorial, they should understand each other.
Thanks!
.
-- Old Post: --
I have a contour in vector graphics that I imported to the Flash library as a movieclip.
I Instanciate the movieclip and it has a Shape child which is the actual contour.
I need to be able to access the contour segments, i.e. the polygon's sides, to be able to get their starting and ending points, is there a way?
the Graphics class only allows to draw but what you draw, as with the Shape class, are not objects, it's not a polygon with sides or whatever.
Am I being clear?
Thanks
There is no way to read the data of a Graphics object (which is essentially what contains the information that you are after.) This applies to any vector graphics object that has already been drawn, either by the Graphics/drawing API itself, or in Flash CS3/CS4, or was embedded using the [Embed] meta-tag.
Your best bet if you need to calculate the algebraic area, or for some other reason retain the vectors in your algorithms, is definitely exporting an SVG or some single-purpose format (like a CSV of the points) from Illustrator, and parsing that in ActionScript.
Another option is to use a BitmapData, and draw the Shape object onto that, then counting the colored (opaque) pixels to numerically calculate it's area.
var bmp : BitmapData = new BitmapData(myShape.width, myShape.height, true, 0);
bmp.draw(myShape);
var i : uint;
var area : uint = 0;
var num_pixels : uint = bmp.width*bmp.height;
for (i=0; i<num_pixels; i++) {
var px : uint = bmp.getPixel32(i%bmp.width, Math.floor(i/bmp.height));
// Determine from px color/alpha whether it's part of the shape or not.
// This particular if statement should determine whether the alpha
// component (first 8 bits of the px integer) are greater than zero, i.e.
// not transparent.
if ((px >> 24) > 0)
area++;
}
trace('number of opaque pixels (area): '+area);
Depending on your application, you might also be able to use the BitmapData.hitTest() method for your collision detection.
I believe the best you can do is to retrieve a rectangular bounding box on the Shape object. Depending on how you imported it, you may or may not have direct access to the Shape object as an instance variable; however, if you do, you can call shapeVar.transform.getBounds() or shapeVar.transform.getRect() (bounds returns a rectangle inclusive of strokes on the shape, rect does not).
I'm curious, so I'm doing a bit of research on alternate means of getting some pixel bounds. I'll edit this further if I find something useful.