/////////////////////////////////////////////////////////////////////////////// // DrawLib.cpp - Demonstrate Drawing on a C++/CLI form // // // // Jim Fawcett, CSE681 - Software Modeling and Analysis, Fall 2008 // /////////////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include #include #include "DrawLib.h" using namespace Drawer; /////////////////////////////////////////////////////////////////////////////// // Native C++ code for generating drawing goes here // // - This simple demo shows how to generate drawings by // generating points for random rectangles. // - You can easily reference other native C++ modules from this file // by adding the header and implementation files to this project // and including the header here. class NativeDrawingInfo : public NativeDrawingInfoInterface { public: NativeDrawingInfo() { // Seed the random-number generator with the current time so that // the numbers will be different every time we run. // srand( (unsigned)time( NULL ) ); } int* getPoints() { // Generate random numbers in the half-closed interval // [range_min, range_max). In other words, // range_min <= random number < range_max const int range_min = 50; const int range_max = 300; static int points[4]; int i; for ( i = 0; i < 4; i++ ) { points[i] = (double)rand() / (RAND_MAX + 1) * (range_max - range_min) + range_min; } return points; } }; //----< factory function for creating instance of NativeDrawingInfo >---------- NativeDrawingInfoInterface* NativeDrawingInfoInterface::Create() { return new NativeDrawingInfo(); }