Exemple #1
0
    private function sketch($rawdata)
    {
        //Before I do all of this, get information about the artist and display before showing sketches of other similar artists
        $artist = string_to_ascii($_GET['artist']);
        $user = string_to_ascii($_GET['username']);
        $primer = $artist / $user * 100;
        ?>
			<script type="text/javascript">
				$(function() {
					$("#one").slider({
						value: <?php 
        $level = $primer * rand(0.7, 1.6);
        echo $level;
        ?>
,
						min: 0,
						max: 255,
						step: 1,
						slide: function(event, ui) {
							$("#one_amount").val(ui.value);
						}
						});
					});
			
				$(function() {
					$("#two").slider({
						orientation: "vertical",
						value: <?php 
        $level = $primer * rand(0.7, 1.6);
        echo $level;
        ?>
,
						min: 0,
						max: 255,
						step: 1,
						slide: function(event, ui) {
							$("#two_amount").val(ui.value);
						}
					});
				});
				
				$(function() {
					$("#three").slider({
						orientation: "vertical",
						value: <?php 
        $level = $primer * rand(0.7, 1.6);
        echo $level;
        ?>
,
						min: 0,
						max: 255,
						step: 1,
						slide: function(event, ui) {
							$("#three_amount").val(ui.value);
						}
					});
				});

				$(function() {
					$("#four").slider({
						orientation: "vertical",
						value: <?php 
        $level = $primer * rand(0.7, 1.6);
        echo $level;
        ?>
,
						min: 0,
						max: 255,
						step: 1,
						slide: function(event, ui) {
							$("#four_amount").val(ui.value);
						}
					});
				});

				$(function() {
					$("#five").slider({
						orientation: "vertical",
						value: <?php 
        $level = $primer * rand(0.7, 1.6);
        echo $level;
        ?>
,
						min: 0,
						max: 255,
						step: 1,
						slide: function(event, ui) {
							$("#five_amount").val(ui.value);
						}
					});
				});

				$(function() {
					$("#six").slider({
						orientation: "vertical",
						value: <?php 
        $level = $primer * rand(0.7, 1.6);
        echo $level;
        ?>
,
						min: 0,
						max: 255,
						step: 1,
						slide: function(event, ui) {
							$("#six_amount").val(ui.value);
						}
					});
				});
			
			</script>
																		
			<?php 
        lastfm::getArtistInfo($_GET['artist']);
        ?>
			
			<div id="eq">
				<div id="one" 				style="width: 200px; margin: 15px;"></div>			
				<div id="two" 				style="height:100px; margin: 15px; float: left;"></div>
				<div id="three" 			style="height:100px; margin: 15px; float: left;"></div>		
				<div id="four" 				style="height:100px; margin: 15px; float: left;"></div>	
				<div id="five" 				style="height:100px; margin: 15px; float: left;"></div>	
				<div id="six" 				style="height:100px; margin: 15px; float: left;"></div>	
			</div>
			
			<?php 
        $xml = new SimpleXMLElement($rawdata);
        $i = 1;
        foreach ($xml->similarartists->artist as $artist) {
            $artistcln = str_replace(' ', '%20', $artist->name);
            $artistTags = "http://ws.audioscrobbler.com/2.0/?method=artist.gettoptags&";
            $artistTags .= "artist={$artistcln}&";
            $artistTags .= "api_key={$this->apikey}&";
            $rawdata = lastfm::talkToLastFM($artistTags);
            $tags = new SimpleXMLElement($rawdata);
            $name = string_to_ascii($artistcln);
            $genre = string_to_ascii($tags->toptags->tag[0]->name);
            $count = $tags->toptags->tag[0]->count;
            ?>
			
<script id="script<?php 
            echo $i;
            ?>
" type="application/processing">

float center1 = 2;
float center2 = 2;

void setup(){
  size(500,800);
  smooth();
  frameRate(8);
}

void draw(){


int genre = <?php 
            echo $genre;
            ?>
; 
int name = <?php 
            echo $name;
            ?>
;
int sound = <?php 
            $tone = strlen($genre * $name) * rand(1, $name) / 100 + rand(1, $genre);
            echo $tone;
            ?>
;
int one = $("#one").slider("value");
int two = $("#two").slider("value");
int three = $("#three").slider("value");
int four = $("#four").slider("value");
int five = $("#five").slider("value");
int six = $("#six").slider("value");

background(two+sound, three+sound, four+sound, five+sound);
 
  float inc = random(-one, one);
  float inc2 = random(-one , one);

  float big = six;

  float end2 = center2 + inc2;
  float end = center1 + inc;
  
  stroke(0,50);
  strokeWeight(name/30);
  line(center1, center2, end, end2);
  
  strokeWeight(name*genre/1000);
  stroke(255-two+sound, 255-three+sound, 255-four+sound, 255-five+sound);
  
  if(big < genre){
		fill(255 - genre, name);
		rect(center1, center2, big, big);
  } else if (big > genre) {
		fill(255 - genre, name);
		ellipse(center1, center2, big, big);
  } 
  rectMode(CENTER);
	  center1 += inc;
	  center2 += inc2;
	 
	  if(center2 > 600){
	    center2 = 300;
	  }
	  if(center2 < 0 ){
	    center2 = 300;
	  }
	
	  if(center1 > 600 ){
	    center1 = 300;
	  }
	  if(center1 < 0){
	    center1 = 500;
	  }
}
				</script>	
				<div class="sketch">
				<a class="viz" title="<?php 
            echo $artist->name;
            ?>
" href="/your/site/url/AV-Browser/?username=<?php 
            echo $this->user;
            ?>
&view=related&artist=<?php 
            echo $artist->name;
            ?>
&type=info" >
				<h2><?php 
            echo $artist->name;
            ?>
</h2></a>
				
				<a class="viz" title="<?php 
            echo $artist->name;
            ?>
" href="/your/site/url/AV-Browser/?username=<?php 
            echo $this->user;
            ?>
&view=related&artist=<?php 
            echo $artist->name;
            ?>
" >
				<canvas title="<?php 
            echo $artist->name;
            ?>
" id="canvas<?php 
            echo $i;
            ?>
" width="800px" height="500px"></canvas></a>
				</div>
				<script>
				  canvas<?php 
            echo $i;
            ?>
 = document.getElementById("canvas<?php 
            echo $i;
            ?>
");
				  script<?php 
            echo $i;
            ?>
 = document.getElementById("script<?php 
            echo $i;
            ?>
").text;
				  Processing(canvas<?php 
            echo $i;
            ?>
, script<?php 
            echo $i;
            ?>
);
				</script>     			
				<?php 
            $i++;
        }
    }
Exemple #2
0
			<?php 
    $music = new lastfm($username, $period);
    $limit = 300;
    $recent = $music->getSimilarArtistsTag($tag, $limit, 'albumArtRelatedTag');
    echo $recent;
}
?>
	

<?php 
if (isset($_GET['username']) && isset($_GET['view']) && $_GET['view'] == 'related' && isset($_GET['artist']) && isset($_GET['type']) && $_GET['type'] == 'info') {
    ?>
		<h1><a href="index.php">home</a></h1>
			<div id="sketch_wrapper">
			<?php 
    $music = new lastfm($username, $period);
    $limit = 5;
    $recent = $music->getSimilarArtists($artist, $limit, 'sketch');
    echo $recent;
    ?>
			</div>
			<?php 
}
?>
	
			
			
<?php 
if (!isset($_GET['username'])) {
    ?>
		<form id="info" method="get" action="/your/site/url/AV-Browser">