<?php /* * Site : http://www.ajornet.com/ * But : Tracé de courbes de Lissajous * * Copyright (c) 2001 Ajornet http://www.ajornet.com/ * Auteur : Daniel Lucazeau mailto:daniel.lucazeau@ajornet.com * * $Id: courbeLissajous.php,v 1.0 2001-10-22 23:32:23+02 lucazeau_daniel Exp lucazeau_daniel $ * */
function drawGraph( $nbPoints, $color, $a, $b) { global $hImg, $diagramWidth, $diagramHeight;
$plotScale = ($diagramHeight) / 2; $plotCenter = ($diagramHeight) / 2; for( $i = 0; $i <= $nbPoints; $i++) { $theta = $i * 2 * pi() / $nbPoints; $x = sin( $a * $theta); $y = sin( $b * $theta);
$x = $x * (float)$plotScale + (float)$plotCenter; $y = (float)$plotCenter - $y * (float)$plotScale;
if( $i > 0) imageLine( $hImg, $oldX, $oldY, $x, $y, $color);
$oldX = $x; $oldY = $y; } }
// Paramètres du graphique $diagramWidth = 300; $diagramHeight = 300; if( !isSet( $nbX)) $nbX =4; if( !isSet( $nbY)) $nbY =7;
// creation de l'image $hImg = imageCreate($diagramWidth, $diagramHeight);
//$colorBackgr = imageColorAllocate( $hImg, 192, 223, 224); $colorBackgr = imageColorAllocate( $hImg, 255, 255, 255); $colorCourbe = imageColorAllocate( $hImg, 88, 126, 127);
imageFilledRectangle( $hImg, 0, 0, $diagramWidth - 1, $diagramHeight - 1, $colorBackgr);
drawGraph( 1000, $colorCourbe, $nbX, $nbY); imageInterlace( $hImg, 1);
header("Content-type: image/png"); imagePng( $hImg); ?>
|