Debian Codegraph @

Oodle/src/CPixel.cpp

raw
1 #include "oodle.h"
2
3 CPixel::CPixel(CVector v, CVector p, const CColor &c)
4 : CParticle(v, p), color(c), lock(1)
5 {
6 }
7
8 CPixel::CPixel(CVector v, CVector p, const CColor &c, const CRect &r)
9 : CParticle(v, p, r), color(c), lock(1)
10 {
11 }
12
13 CPixel::CPixel(const CPixel &p)
14 : CParticle(p), color(p.color), lock(1)
15 {
16 }
17
18 CPixel::CPixel(const CPixel &p, const CColor &c)
19 : CParticle(p), color(c), lock(1)
20 {
21 }
22
23 const CPixel &CPixel::operator=(const CPixel &p)
24 {
25 if (&p != this) // don't allow assignment to self
26 {
27 velocity = p.velocity;
28 pos = p.pos;
29 moving = p.moving;
30 timer = p.timer;
31 box = p.box;
32 color = p.color;
33 lock = p.lock;
34 }
35
36 return *this;
37 }
38
39 void CPixel::draw(CSurface &surface)
40 {
41 CTimer timer;
42 try
43 {
44 // Only draw if the pixel will end up on the surface; off the
45 // surface causes exceptions
46 if (surface.onSurface(pos))
47 {
48 if (lock)
49 {
50 surface.lock();
51 }
52
53 surface.setPixel((int) pos.getX(), (int) pos.getY(),
54 color);
55
56 if (lock)
57 {
58 surface.unlock();
59 }
60 }
61 }
62 catch (ex_Generic e)
63 {
64 _ADDTRACEINFO(e, "CPixel", "draw",
65 "surface = " << (void *) &surface);
66 throw e;
67 }
68 // cout << "draw one pixel: " << timer.getElapsed() << endl;
69 }
70
71 void CPixel::lockBeforeDraw(bool l)
72 {
73 lock = l;
74 }
75
76 const CColor &CPixel::getColor()
77 {
78 return color;
79 }
80
81 void CPixel::setColor(const CColor &c)
82 {
83 color = CColor(c);
84 }