File: stars.cpp

package info (click to toggle)
qonk 0.3.1-1
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 2,076 kB
  • ctags: 2,026
  • sloc: cpp: 14,978; sh: 3,464; makefile: 200
file content (40 lines) | stat: -rw-r--r-- 663 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Copyright 2005 by Anthony Liekens anthony@liekens.net

#include "coordinate.h"
#include "stars.h"
#include "canvas.h"

// ##### STAR METHODS #####

Star::Star() {
	c.setX( (double)rand() / RAND_MAX );
	c.setY( (double)rand() / RAND_MAX );
	brightness = rand() % ( 255 - 70 );
}

void
Star::render( ) const {
    Canvas::drawStar(c.getXMapped(), c.getYMapped(), brightness);
}

// ##### STARS METHODS #####

Stars::Stars() {
}

Stars::Stars( int n ) {
	addStars( n );
}

void
Stars::addStars( int n ) {
	for( int i = 0; i < n; i++ )
		push_back( Star() );
}

void 
Stars::render( ) const {
	for( const_iterator i = begin(); i != end(); i++ )
		i->render( );
}