I'm trying to find a straightforward answer to this question, but the answers I find are often extremely conveluded, or require logic more complicated than what is required. My question is based on the following example:
Let's say I've got a series of points. They are all very tame and predictable, in that they always take on a mathematical curve pattern... (They always start bottom-left and end top-right)
How would I determine the area under this curve in PHP?
Note that I attempt to replicate this example in Javascript using Canvas but failed miserably (using examples like this)
<?php
//Example requires Imagick
$width = 800;
$height = 200;
$img = new Imagick();
$img->newImage( $width, $height, new ImagickPixel( 'transparent' ) );
$draw = new ImagickDraw();
$draw->setStrokeColor( new ImagickPixel( 'red' ) );
$draw->setStrokeWidth(4 );
$draw->setFillColor( new ImagickPixel( 'transparent' ) );
$points = array
(
array( 'x' => 0, 'y' => 200 ),
array( 'x' => 100, 'y' => 0 ),
array( 'x' => 200, 'y' => 200 ),
array( 'x' => 300, 'y' => 0 ),
array( 'x' => 400, 'y' => 10 ),
array( 'x' => 500, 'y' => 0 )
);
$draw->bezier($points);
$img->drawImage( $draw );
$img->setImageFormat( "png" );
header( "Content-Type: image/png" );
echo $img;
?>
I understand this question may take a few iterations for me to ask... I would have posted a JSFiddle to back up this example and make it easier to work with, however I could not convert it for use with js/bezierCurveTo, so if a user could help with that it would also be a very useful substitute