How to draw a polyline with rounded ends using Google Maps iOS SDK? - rounding

I want to draw a polyline in Google Maps SDK for iOS but the ends of the line look pretty ugly to me. Is there a way I could smooth them out or round them off? I tried adding a GMSCircle to the end of the line but the circle gets zoomed in differently than the polyline, ruining the whole effect.
I am sorry but I don't have enough reputation to post images of it yet.
Is there another way I could achieve this whole "rounding-off" effect?

Related

Making a drawing game using phaser

I am developing a game using Phaser where a user is rendered a triangular canvas. User can crop this canvas to any possible shape by drawing any crop pattern on the canvas. Besides this, i need to get this cropped canvas in suitable data format to be used as an image to render and also trace changes made on this canvas for undoing puspose.
Any help to get this through will be appreciated.
Thanks in advance.
Initial canvas
Canvas after crop
Cropped canvas used to create new canvas
So it's like folding a piece of paper and then cutting it so it looks like a snowflake? Interesting idea.
I think you could either use BitmapData to draw the initial cut out, then copy that bitmap 6 (or 12?) times and rotate and flip x-axis to construct the rest. Though maybe there will be seems, so like small lines, between the parts idk.
Another appproach would be to keep track of the initial cutlines like vectors. Then use math/trigonometry to calculate the result. No idea how to do this though, sorry.

Add a label to the center of a polygon in kml

Can anyone tell me how I would add a label to the center of a polygon by way of kml like the ones in the link: http://maps.huge.info/zip.htm.. I don't want a marker and I don't need the info to pop up when its clicked, I need it to be there from load, it would just have the zip code for the particular polygon. I wont be drawing the entire US zip code, maybe just a few at a time. Oh, and I'm using mapquest API not google or anything else
Use the Leaflet.label plugin, that does exactly this.

Can I create a Calligraphy look with SVG?

is it possible to create a stroke with a dynamic width with SVG? I want to achieve a Calligraphy look like here, here or here.
Is this even possible? It seems customization of strokes in SVG is fairly limited. Even gradients in strokes seem to be non-trivial (see here).
There is a proposal to add into SVG standard a mechanism, that does exactly what you want:
http://www.w3.org/Graphics/SVG/WG/wiki/Proposals/Variable_width_stroke
http://lists.w3.org/Archives/Public/www-svg/2013May/0041.html
There's even an example implementation available here:
https://rawgit.com/birtles/curvy/master/index.html
It is, however, by no means official and we cannot be even sure it'll ever be.
Until then you'll need to stick to Bezier curves and object filling:
You can also use calligraphic fonts, for example - Tangerine available on Google CDN:
This approach requires less work since you don't need to draw everything from scratch, but then again, using third party fonts leaves you with little control over the final result.
You can't dynamically adjust the stroke of a path element. However you could draw a path, use a fill color on it instead of stroke, then double back upon the letters at a slight distance away from the original line.
Also, if you are using the SVG on the web then you can use css fonts on text elements. There are some pretty good cursive fonts that you can use for free... just check google web fonts.

Rotating a circle image shifts it's position

I am trying to rotate a circle image using jquery rotate plugin. But, I observe that the circle image appears to be oscillating about it's center while rotating. Something like a linear movement.
In IE7, it's pretty much observable. In Chrome/Firefox, if you zoom a bit, this wobbling issue can be observed.
I tried to rotate the image using Raphael library too. But still, the circle was wobbling.
Then I rotated the image with a c# program to see if the problem is with the browsers' graphic engine. But even here this issue is observed. I even took various images to see if the circle was imperfect. But, all the images show this behavior.
Can this be happening because of anti aliasing? Or, is it just an optical illusion?
If not, then what else can be the reason?
I am using jqueryrotate plugin rotate method to do this. $('#circleimg').rotate(Position);
Check this jsFiddle. Btw, this is the kind of source code you can include yourself in your question to make answering it easier for others.
http://jsfiddle.net/KyJzQ/
I used this rotate plugin since you did not specify which one you used.
HTML
<img id="circleimg" src="http://i.imgur.com/KgUDClr.png">
<img id="circleimg2" src="http://i.imgur.com/sK4qP6z.png">
JAVASCRIPT
var rot = 0;
window.setInterval(function() {
$('#circleimg').rotate(rot);
$('#circleimg2').rotate(rot);
rot += 1;
},
5
);
I think the circle you've provided is not actually a perfect circle, hence the tiny "oscillations" you see.
I added another circle that I rendered myself. If you zoom in closely enough you will see jagged pixels moving around the edge of my circle, but I don't see any way around this since the jQuery plugin is not actually re-rendering the image. I don't see any of the "oscillating" you mention in my circle.
This issue is more about vector art than it is about programming. Get a nice vector graphics program and render the nicest circle you can. Even the one I made is not really that good. Or use HTML5 and canvas to draw dynamically, rather than moving a static image around.

Not able to get stencil to work

Was trying to get Stencil to work in my app. I use Sprites to render content on to the Device. Content could be movies, pictures or text.
Can I set the stencil buffer using these Sprites, which can be used in later passes to stencil out other Sprites being rendered?
I'm even not able to stencil out any of the Sprites by setting StencilFunction = Compare.Never! Anything wrong that I might be doing?
I've already spent almost an entire day checking out posts related to Stencils in MDX, but just couldn't get it to work.
Bit more searching got me to a technique wherein we draw silhouette of the shapes to be added to the stencil buffer. Is this really required in my case? I just want to use the Sprites, and add them to stencil buffer to stencil out other Sprites.
EDIT: OK.. So I figured out how to get it done. Referred to this post - http://www.gamedev.net/community/forums/viewreply.asp?ID=1999276
But now the sprite is ignoring alpha values and rendering sprites opaque. Similar to the effect we get when alpha blending is set to false. Any ideas?
So, I finally figured it out. It's all related to Sprites and its Begin() method.
Sprite.Begin() will modify the RenderState and disable stencil. We can prevent it by setting SpriteFlags.DoNotModifyRenderState flag, but then the alpha blending is not supported when sprites are drawn.
What I did now was simply call Sprite.Begin() without SpriteFlags.DoNotModifyRenderState flag set. And before the call to Sprite.Draw(), enabled stencil on the device.

Resources