HTML5 bezier curve animation - html5-canvas

I am a little bit of new in HTML5 area and I have a question to make. I am trying to create a drawing, like pencil, bezier curve in HTML5 canvas. While i have already created my curve i can't make it drawn itself when window is loaded.
Any suggestions cause I've searched all web for this.
Thanks

To clarify: you want to animate the drawing of a bezier curve, so that it looks like it is being drawn on the screen?
If so, please see this answer. This shows you how to draw a part of a bezier curve.
What you want to do is draw part of the curve repeatedly (say once every 50 milliseconds, or whatever interval you choose). Each time you draw it, though, you draw a bigger portion of the curve, until you have drawn the entire thing.

On window.onload event draw your bezier curve on canvas.
window.onload=function()
{
// here your your code
}
for more help check this check this ans
using bezier curves

Related

Isometric Sprites

This might be a stupid question but I'm stuck and can't get passed it. I'm making a isometric game and I have my map built using tiles, I just followed this tutorial to build the map, http://www.binpress.com/tutorial/creating-a-city-building-game-with-sfml/137. But now I don't know how to add character sprites. Do I have to add these sprites using tiles as well or do I just draw the the sprites into position of the screen. Any help would be much appreciated.
As far as I can tell from the engine, just follow the "Textures and Animations" guide and draw the Animation to the screen after you have drawn the tiles. This isn't a complicated engine, so you are only working with 2D sprites being drawn to the screen (the 3D effect is merely tricks of painter's algorithm to make it work...there is no z-axis from what the tutorial indicates)
The depth is done by the order of tile rendering
The same goes for objects,players,etc... Let assume plane XY is parallel with the ground and Z axis is the altitude. Then your grid would be something like this (assuming diamond shape layout):
Order of rendering
You have to handle object,players and stuff sprites in the same way as tiles (and in the same time). so you should render all cells in specific order dependent on your grid layout and sprite combination equation. If your sprites can overwrite already rendered stuff then you should render from the most distant tiles to the closest to the "camera". In that case the blue direction arrow on above image is correct and Z axis should be increasing in the most inner loop.
So now if you got any object,player or stuff placed in cell (x,y,z) then you should render it directly after the cell (x,y,z) was rendered prior to rendering any other cell.
To speed up is a good idea to have objects and players in your tile map as a cell. But for that you have to have the tiles in the right manner and also your map representations must be capable of doing so.

LibGDX - The best way detect colission

I have an airplane. I use rectangle for bounding this airplane to detect collision and it works great. When the airplane begin falling down I rotate airplane's texture, but rectangle remains unchanged. I don't know how to rotate it. I need to rotate it with airplane's texture because my shell doesn't collide the airplane's tail and cabine.
How to rotate rectangle or perhaps create polygon shape to wrap all airplane? Any help will be appreciated!
#jellyfication's answer points to raycasting, but a different and also simple approach you could implement is the Separating Axis Theorem. The links below will show you in detail what the algorithm is about and how to implement it. They also have some interactive demos so you get the 'feel' for what the algorithm is doing.
http://www.metanetsoftware.com/technique/tutorialA.html
http://www.sevenson.com.au/actionscript/sat/
http://www.codezealot.org/archives/55 (this one has a lot of code)
http://gamedev.tutsplus.com/tutorials/implementation/collision-detection-with-the-separating-axis-theorem/
Good luck!
Use the polygon class to and draw your bounding Box.
Then within the polygon class there is a method to rotate.
Rotate and move the polygon with the plane.

Drawing simple shapes or using sprites with OpenGL

I want to create a simple shape, let's say, a circle, it might have transparency, colors, etc. but it's still a simple circle.
In every tutorial I see, people use sprites. I am not sure what should I use for my case.
Should I use a sprite with a circle or should I try and draw the shape myself?
What are the advantages of each method?
Is there a line dividing them or is it just experience to know which one to use?
GPU geometry is composed of triangles or line segments so it'll be inefficient to draw a circle in this way, it'll require too many triangles for it to look smooth.
The two more efficient ways to do that are:
Use a sprite
Use a shader and draw the circle. Check ShaderToy, more specifically the "Shapes" preset.

SIMPLE Ruby library for drawing shapes and managing clicks

I am looking for simple library for Ruby that could help me drawing things on the screen. I am not developing a game, I just want to display some graphs, so I need to
draw circles on a certain position,
put a label on these circles,
being notified that circle XYZ has been selected (I want to know the circle, not the coords),
draw lines connecting circles' borders,
change the color of the these circles,
(optional) animate moving a circle from position (x1,y1) to (x2,y2) in X seconds,
(even more optional) zoom on part of this scene.
Do you know anything that could help me with this?
Check out the green_shoes gem. Here's an example of some code to get you started, too!

polyline with gradient

Is there a way to draw a line along a curved path with a gradient that varies in a direction perpendicular to the direction of the line? I am using the GDI+ framework for my graphics.
The simple answer is no. You can create a GraphicsPath in order to describe what you would like to draw, using AddPoint/AddLine/AddBezier and so forth as needed to describe the complex path of what you want to draw. When you draw the path you can provide a Brush which can be something like LinearGradientBrush or RadialGradientBrush. Neither of those gradient brushes reacts to the actual path being drawn in the sense of changing direction as the drawing occurs. You have to specify the angles etc as constant for the entire gradient area.
One possible method you can use is to set the clip region of the Graphics object to be that of the line only. Then draw a Linear Gradient over the extremes of the line e.g.
GraphicsPath gp = new GraphicsPath();
gp.AddArc(); // etc...
graphics.SetClip( gp );
graphics.FillRectangle( myLinearGradientBrush, gp.GetBounds());
The above code might give you what you are looking for.

Resources