2005-03-02 10:55:29 +00:00
|
|
|
//This file is part of Photon (http://photon.sourceforge.net)
|
|
|
|
//Copyright (C) 2004-2005 James Turk
|
|
|
|
//
|
|
|
|
// Author:
|
|
|
|
// James Turk (jpt2433@rit.edu)
|
|
|
|
//
|
|
|
|
// Version:
|
2005-11-13 07:59:48 +00:00
|
|
|
// $Id: Pen.hpp,v 1.5 2005/11/13 07:59:49 cozman Exp $
|
2005-03-02 10:55:29 +00:00
|
|
|
|
|
|
|
#ifndef PHOTON_VIDEO_PEN_HPP
|
|
|
|
#define PHOTON_VIDEO_PEN_HPP
|
|
|
|
|
|
|
|
#include "types.hpp"
|
|
|
|
#include "video/Color.hpp"
|
|
|
|
#include "math/Rect.hpp"
|
|
|
|
#include "math/Vector2.hpp"
|
|
|
|
#include "math/Circle.hpp"
|
|
|
|
|
|
|
|
namespace photon
|
|
|
|
{
|
|
|
|
namespace video
|
|
|
|
{
|
|
|
|
|
|
|
|
// Class: Pen
|
|
|
|
// Class which is used for drawing primitives.
|
|
|
|
//
|
|
|
|
// Each instance of pen has a color, and the various members simply draw
|
2005-11-13 07:59:48 +00:00
|
|
|
// primitives in that color. Since it is possible to change the color
|
|
|
|
// associated with a pen, there is often no need for multiple instances of Pen.
|
2005-03-02 10:55:29 +00:00
|
|
|
class Pen
|
|
|
|
{
|
|
|
|
|
|
|
|
// Group: (Con/De)structors
|
|
|
|
public:
|
|
|
|
// Function: Pen
|
|
|
|
// Default constructor, sets color to white.
|
|
|
|
Pen();
|
|
|
|
|
|
|
|
// Function: Pen
|
|
|
|
// Initializing constructor, takes components of color to use for drawing.
|
|
|
|
//
|
|
|
|
// Parameters:
|
|
|
|
// r - Value for red component.
|
|
|
|
// g - Value for green component.
|
|
|
|
// b - Value for blue component.
|
|
|
|
// a - Value for alpha component. [default: 255]
|
|
|
|
//
|
|
|
|
// See Also:
|
|
|
|
// <setColor>
|
|
|
|
Pen(ubyte r, ubyte g, ubyte b, ubyte a=255);
|
|
|
|
|
|
|
|
// Function: Pen
|
|
|
|
// Initializing constructor, takes <Color> to use for drawing..
|
|
|
|
//
|
|
|
|
// Parameters:
|
|
|
|
// color - <Color> to use for drawing.
|
|
|
|
//
|
|
|
|
// See Also:
|
|
|
|
// <setColor>
|
2005-03-03 09:25:19 +00:00
|
|
|
Pen(const Color& color);
|
2005-03-02 10:55:29 +00:00
|
|
|
|
|
|
|
// Group: Color
|
|
|
|
public:
|
|
|
|
// Function: setColor
|
|
|
|
// Sets color to use for drawing.
|
|
|
|
//
|
|
|
|
// Parameters:
|
|
|
|
// r - Value for red component.
|
|
|
|
// g - Value for green component.
|
|
|
|
// b - Value for blue component.
|
|
|
|
// a - Value for alpha component. [default: 255]
|
|
|
|
void setColor(ubyte r, ubyte g, ubyte b, ubyte a=255);
|
|
|
|
|
|
|
|
// Function: setColor
|
|
|
|
// Sets color to use for drawing.
|
|
|
|
//
|
|
|
|
// Parameters:
|
|
|
|
// color - <Color> to use for drawing.
|
2005-03-03 09:25:19 +00:00
|
|
|
void setColor(const Color& color);
|
2005-03-02 10:55:29 +00:00
|
|
|
|
|
|
|
// Group: Drawing
|
|
|
|
public:
|
|
|
|
// Function: drawPoint
|
|
|
|
// Draws a single point.
|
|
|
|
//
|
|
|
|
// Parameters:
|
|
|
|
// point - Point to draw.
|
2005-03-03 09:25:19 +00:00
|
|
|
void drawPoint(const math::Point2& point) const;
|
2005-03-02 10:55:29 +00:00
|
|
|
|
|
|
|
// Function: drawLine
|
|
|
|
// Draw a line from one point to another.
|
|
|
|
//
|
|
|
|
// Parameters:
|
|
|
|
// p1 - First endpoint of line.
|
|
|
|
// p2 - Second endpoint of line.
|
2005-03-03 09:25:19 +00:00
|
|
|
void drawLine(const math::Point2& p1, const math::Point2& p2) const;
|
2005-03-02 10:55:29 +00:00
|
|
|
|
|
|
|
// Function: drawVector
|
|
|
|
// Draw a vector, including small arrow, with base at a given point.
|
|
|
|
//
|
|
|
|
// Parameters:
|
|
|
|
// point - Base point for vector.
|
|
|
|
// vector - Vector to draw.
|
2005-03-03 09:25:19 +00:00
|
|
|
void drawVector(const math::Point2& point,
|
|
|
|
const math::Vector2& vector) const;
|
2005-03-02 10:55:29 +00:00
|
|
|
|
2005-07-20 03:58:54 +00:00
|
|
|
// Function: drawRect
|
2005-03-02 10:55:29 +00:00
|
|
|
// Draw an empty rectangle.
|
|
|
|
//
|
|
|
|
// Parameters:
|
|
|
|
// rect - <Rect> to draw.
|
2005-07-20 03:58:54 +00:00
|
|
|
void drawRect(const math::Rect &rect) const;
|
2005-03-02 10:55:29 +00:00
|
|
|
|
2005-07-20 03:58:54 +00:00
|
|
|
// Function: fillRect
|
2005-03-02 10:55:29 +00:00
|
|
|
// Draw a filled rectangle.
|
|
|
|
//
|
|
|
|
// Parameters:
|
|
|
|
// rect - <Rect> to draw.
|
2005-07-20 03:58:54 +00:00
|
|
|
void fillRect(const math::Rect &rect) const;
|
2005-03-02 10:55:29 +00:00
|
|
|
|
|
|
|
// Function: drawCircle
|
|
|
|
// Draw an empty circle.
|
|
|
|
//
|
|
|
|
// Parameters:
|
|
|
|
// circle - <Circle> to draw.
|
|
|
|
void drawCircle(const math::Circle &circle) const;
|
|
|
|
|
|
|
|
// Function: fillCircle
|
|
|
|
// Draw a filled circle.
|
|
|
|
//
|
|
|
|
// Parameters:
|
|
|
|
// circle - <Circle> to draw.
|
|
|
|
void fillCircle(const math::Circle &circle) const;
|
|
|
|
|
|
|
|
// data members
|
|
|
|
private:
|
|
|
|
Color color_;
|
2005-08-23 21:55:03 +00:00
|
|
|
|
|
|
|
// 30 seems to be an even tradeoff between speed and roundness
|
|
|
|
static const int CIRCLE_RESOLUTION = 30;
|
2005-03-02 10:55:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif //PHOTON_VIDEO_PEN_HPP
|