BlinkenArea - GitList
Repositories
Blog
Wiki
libetherpix
Code
Commits
Branches
Tags
Search
Tree:
5c70d9d
Branches
Tags
master
libetherpix
simulator
pixel.cpp
implement receiving packets
Stefan Schuermans
commited
5c70d9d
at 2017-06-11 15:48:14
pixel.cpp
Blame
History
Raw
/* * EtherPix simulator * * Copyright 2017 Stefan Schuermans <stefan schuermans info> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, version 3 of the License. * * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include <gtkmm.h> #include <stdint.h> #include "bbox.h" #include "pixel.h" #include "transform.h" /// default constructor Pixel::Pixel(): m_x(0.5), m_y(0.5), m_r(0.0), m_red (64), m_green(64), m_blue (64) { } /// constructor based on coordinates and radius Pixel::Pixel(double x, double y, double r): m_x(x), m_y(y), m_r(r), m_red (64), m_green(64), m_blue (64) { } /** * @brief add pixel to the bounding box * @param[in,out] bb bounding box */ void Pixel::updateBBox(BBox &bb) const { // add pixel plus some border to bounding box bb.add(m_x - 2 * m_r, m_y - 2 * m_r); bb.add(m_x + 2 * m_r, m_y + 2 * m_r); } /** * @brief draw pixel * @param[in] cairo cairo context for drawing * @param[in] tf coordinate transformation */ void Pixel::draw(Cairo::RefPtr<Cairo::Context> &cairo, Transform const &tf) const { double x, y, r; tf.apply(m_x, m_y, x, y); tf.applyZoom(m_r, r); cairo->set_source_rgb(m_red / 255.0, m_green / 255.0, m_blue / 255.0); cairo->arc(x, y, r, 0.0, 2.0 * M_PI); cairo->fill(); }