diff --git a/photon.mm b/photon.mm index d0659a9..9087315 100644 --- a/photon.mm +++ b/photon.mm @@ -40,29 +40,22 @@ - - + - - - - - - + - + - @@ -77,7 +70,8 @@ - + + @@ -90,7 +84,6 @@ - @@ -103,7 +96,7 @@ - + diff --git a/src/math/Vector2.cpp b/src/math/Vector2.cpp index 3404180..d06886b 100644 --- a/src/math/Vector2.cpp +++ b/src/math/Vector2.cpp @@ -5,7 +5,7 @@ // James Turk (jpt2433@rit.edu) // // Version: -// $Id: Vector2.cpp,v 1.2 2005/07/06 04:27:23 cozman Exp $ +// $Id: Vector2.cpp,v 1.3 2005/07/17 05:38:44 cozman Exp $ #include "math/Vector2.hpp" @@ -36,7 +36,7 @@ void Vector2::set(scalar nx, scalar ny) void Vector2::resolveDeg(scalar magnitude, scalar angle) { - angle = degToRad(clamp(angle,0,360)); + angle = degToRad(angle); x = magnitude*std::cos(angle); y = magnitude*-std::sin(angle); } diff --git a/test/Pen_test.cpp b/test/Pen_test.cpp new file mode 100644 index 0000000..e559c36 --- /dev/null +++ b/test/Pen_test.cpp @@ -0,0 +1,109 @@ +//This file is part of Photon (http://photon.sourceforge.net) +//Copyright (C) 2004-2005 James Turk +// +// Author: +// James Turk (jpt2433@rit.edu) +// +// Version: +// $Id: Pen_test.cpp,v 1.1 2005/07/17 05:38:44 cozman Exp $ + +#include "photon.hpp" +using namespace photon; +#include + +class MainTask : public Task +{ + +public: + MainTask() : + Task("MainTask"), + app(AppCore::getInstance()), + video(video::VideoCore::getInstance()) + { + LogSinkPtr csp( new ConsoleSink("console") ); + log.addSink(csp); + + video.setOrthoView(800,600); + + r.setColor(255, 0, 0); + g.setColor(0, 255, 0); + b.setColor(0, 0, 255); + } + + void update() + { + static double t=0; + static const math::Point2 center(400, 300); + + if(app.getTime() - t > 1.0) + { + app.setTitle("FPS: " + + boost::lexical_cast(app.getFramerate()) ); + t = app.getTime(); + } + + video.clear(); + + unsigned int i,j; //used throughout demo + + // points + for(i=0; i < 400; ++i) + { + r.drawPoint(math::Point2(i, 2*i)); + g.drawPoint(math::Point2(i, 3*i)); + b.drawPoint(math::Point2(i, 4*i)); + } + + // lines + for(i=100; i <= 200; i += 10) + { + for(j=100; j <= 200; j += 10) + { + g.drawLine(math::Point2(100,i), math::Point2(j, 200)); + } + } + + // circles + b.fillCircle(math::Circle(center, 60)); + g.drawCircle(math::Circle(center, 60)); + g.drawCircle(math::Circle(center, 50)); + + // vectors + math::Vector2 clockHand; + clockHand.resolveDeg(50, 20*app.getTime()); + r.drawVector(center, clockHand); + + // rectangles + math::Rect rect1(math::Point2(500, 300), 200, 100); + math::Rect rect2(math::Point2(550, 375), 100, 200); + r.drawRectangle(rect1); + b.drawRectangle(rect2); + g.fillRectangle(rect1.calcIntersection(rect2)); + } + +private: + video::Pen r,g,b; + + + Log log; + AppCore& app; + video::VideoCore& video; +}; + +class FontTest : public Application +{ +public: + + int main(const StrVec& args) + { + AppCore::getInstance().createDisplay(800,600,32,0,0,false); + + Kernel::getInstance().addTask(TaskPtr(new MainTask())); + + Kernel::getInstance().run(); + + return 0; + } +}; + +ENTRYPOINT(FontTest)