Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Draws sinewave in PHP
- // Author: fastman92
- // Site: fastman92-site.tk
- // Input data
- $sizeX = 600;
- $sizeY = 300;
- $period = 200; // px
- // Code
- $im = imagecreatetruecolor($sizeX, $sizeY);
- $white = imagecolorallocate($im, 255, 255, 255);
- imagefilledrectangle($im, 0, 0, $sizeX, $sizeY, $white);
- $color = imagecolorallocate($im, 0, 0, 0);
- $previousY = 0.0;
- for($x = 0; $x < $sizeX; $x++)
- {
- $y = ($sizeY / 2.0) + $sizeY/2 * sin(2*M_PI*$x/$period);
- imageline($im, $x-1, $previousY, $x, $y, $color);
- $previousY = $y;
- }
- header('Content-Type: image/png');
- imagepng($im);
- imagecolordeallocate($im, $color);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement