Tag Archives: Curvature

Relative Points vs. Absolute Points


Relative Points:

In simple words, points that are relative to each other are called relative points.

 Absolute Points:

Absolute points contain exact values.

I started using the concept of “Relative Points” while within my first tool “Curvature” (I continued using it in “Canvas Designer“!) – where I allowed end-users to get auto-generated code in relative/absolute formats. Relative points helped them move/drag shapes easily by just changing two objects: x and y. (x-y coordinating system!)

My all tools contain this feature and personally I use it in my real experiments and projects, too.

Relative points help you in complex animations like flying bird, scene movement (rolling camera), rocket fire or any other kind of animating experiment!

See an example: http://muaz-khan.github.com/Everything/Canvas/Experiments/Flying-Bird/

The process of “Relative Points”:

I get topmost x-y coordinates and then I extract all other points from those coordinates accordingly.

In case of additional complex shapes like Bezier/quadratic curves, I get topmost four points (one starting point, two control points and one ending point) and I set these values to four variables and use them accordingly. You can see it in action in my tool “Curvature“.

———————————–

An absolute point specifies a unique point on the screen as measured from the top-left corner of the screen.

The difference between the two types of coordinates is their origin.

Absolute coordinates are always measured from the origin (top-left corner of the screen or a specific object), and relative coordinates are measured from the current position (or a specific position), where this might be.

Following statement draws a line using absolute coordinates:

context.moveTo(20, 20);

context.lineTo(500, 500);

Following statement draws a line using relative coordinates:

var x = 20, y = 20;context.moveTo(x, y);
context.lineTo( x + 480, y + 480);

Relative coordinates are using frequently in drawing closed shapes, be it’s easier to define an endpoint by its distance from the previous one.

Releasing Curvature second time!


Curvature is a designer allows you draw curves. It generates Canvas 2d APIs relevant code in different forms/styles.

http://muaz-khan.github.com/Curvature/

What is Curvature?

Today release contains following new features:
➛ Curves Alignment (align any point, to any coordinate of the screen)
➛ You can drag whole curve (as it is!)
➛ You can drag whole drawing (all curves – without any disturbance!)
➛ You can copy whole drawing exactly!
➛ You can get shortened code too!

Curvature: HTML5 Canvas Curves Generator/Tool


Today I am happy to announce the release of Curvature: a tool lets you design curves using Canvas 2d APIs!

Curvature lets you draw unlimited Bezier curves and also generates exact code for you in two formats:

1) Absolute Coordinates

context.moveTo(200, 300);

context.bezierCurveTo(200, 300, 400, 500, 600, 700);

These are absolutely positioned points/coordinates.

Now let’s make an assumption: you had drawn one hundred (100) curves. Could you easily move all curves (as they are) on any portion of the screen?

The answer is: No, never. Not so easy!

Why it is not easy to move absolutely positioned coordinates on the screen?

You are drawing Bezier curves; not a simple line, arc or rectangle! For Bezier curves you have to understand its two control points and one ending point.

Canvas 2d API for Bezier curve looks like this:

CanvasRenderingContext2D.bezierCurveTo = function(cp1x, cp1y, cp2x, cp2y, x, y);

So what is the solution? The solution is relative positioned coordinates. If you had drawn hundreds of thousands of curves; no matter; Curvaturewill do all job for you!

2) Relative Coordinates

/* First curve where we set default values for x and y ! */

/* All subsequent curves will be extracted from these two objects! */

context.moveTo( x = 359, y = 319 );

context.bezierCurveTo( x + 25, y – 164, x + 191, y – 169, x + 285, y – 57 );

// Second Curve

context.moveTo( x , y  );

context.bezierCurveTo( x + 25, y – 164, x + 157, y + 51, x + 285, y – 57 );

// Third Curve

context.moveTo( x , y  );

context.bezierCurveTo( x + 25, y – 164, x + 234, y – 256, x + 285, y – 57 );

As you saw in the above code; when we call context.moveTo Canvas 2d API first time; we initialize default position for two variables or objects: x and y.

All subsequent values/points are relative to these two objects.

Changing them will affect all others accordingly.

How relative positioned coordinates can helps me?

Just copy auto generated code and you have to change only two points or coordinates or values:

x = e.pageX    // or whatever

y = e.pageY      // or whatever

Curvature auto-generates code for you! – Just copy and you are done!

Just draw more than one Bezier curves copy auto-generated code and you are done! Happy!!!

Try the tool:

https://canvature.appspot.com/

Just try! – Don’t hesitate to feedback! – You are most welcome!

You feedback may help me bring something better!