diff options
Diffstat (limited to 'helium/tracer.cpp')
-rw-r--r-- | helium/tracer.cpp | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/helium/tracer.cpp b/helium/tracer.cpp new file mode 100644 index 0000000..4e7d54d --- /dev/null +++ b/helium/tracer.cpp @@ -0,0 +1,38 @@ +// Copyright 2006 Google Inc. +// All Rights Reserved. +// Author: <renn@google.com> (Marius Renn) +// +#include "debugging.h" +#include "image.h" +#include "trace.h" +#include "tracer.h" + +using namespace helium; + +const uint8 kMark = 0x01; + +Tracer::Tracer() : scrap_(NULL), trace_map_(NULL) { +} + +void Tracer::SetScrap(Image* scrap) { + scrap_ = scrap; + ASSERT(scrap_); + + int w = scrap->width(); + neighbor_[0] = 1; + neighbor_[1] = w + 1; + neighbor_[2] = w; + neighbor_[3] = w - 1; + neighbor_[4] = -1; + neighbor_[5] = -w - 1; + neighbor_[6] = -w; + neighbor_[7] = -w + 1; +} + +void Tracer::Engrave(const Trace& trace, Color* scrap_ptr) const { + for (unsigned i = 0; i < trace.size(); i++) { + SetAlphaAt(scrap_ptr, kMark); + scrap_ptr += neighbor_[trace.ValueAt(i)]; + } + SetAlphaAt(scrap_ptr, kMark); +} |