X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=ETL%2Ftest%2Fsurface.cpp;fp=ETL%2Ftest%2Fsurface.cpp;h=e2dd0e5e27942fbf6827a4dbf0d430634c754196;hb=a095981e18cc37a8ecc7cd237cc22b9c10329264;hp=0000000000000000000000000000000000000000;hpb=9459638ad6797b8139f1e9f0715c96076dbf0890;p=synfig.git diff --git a/ETL/test/surface.cpp b/ETL/test/surface.cpp new file mode 100644 index 0000000..e2dd0e5 --- /dev/null +++ b/ETL/test/surface.cpp @@ -0,0 +1,221 @@ +/*! ======================================================================== +** Extended Template and Library Test Suite +** Surface Class Test +** $Id$ +** +** Copyright (c) 2002 Robert B. Quattlebaum Jr. +** +** This package 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; either version 2 of +** the License, or (at your option) any later version. +** +** This package 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. +** +** === N O T E S =========================================================== +** +** ========================================================================= */ + +/* === H E A D E R S ======================================================= */ + +#include +#include +#include +#include + +/* === M A C R O S ========================================================= */ + +using namespace etl; +using namespace std; + +/* === C L A S S E S ======================================================= */ + + +/* === P R O C E D U R E S ================================================= */ + +int display_pen(generic_pen pen, int w, int h) +{ + int ret=0; + int x, y; + // print out the after pic + for(y=0;y=2.0f) + printf("#"); + else if(pen.get_value()>=1.0f) + printf("@"); + else if(pen.get_value()>=0.8f) + printf("%%"); + else if(pen.get_value()>=0.6f) + printf("O"); + else if(pen.get_value()>=0.4f) + printf(":"); + else if(pen.get_value()>=0.2f) + printf("."); + else if(pen.get_value()>=-0.1f) + printf(" "); + else + printf("X"),ret++; + } + pen.dec_x(x); + printf("|\n"); + } + pen.dec_y(y); + return ret; +} + +void make_pattern(generic_pen pen, int w, int h) +{ + int x,y; + for(y=0;y my_surface(100,100); + + gaussian_blur(my_surface.begin(),my_surface.end(),10,10); + + surface my_surface2(my_surface); + + my_surface2.fill(0.5); + my_surface2.clear(); + + my_surface2=my_surface; + + my_surface2.fill(0.5); + my_surface2.clear(); + + my_surface.fill(0.5); + my_surface.clear(); + + surface my_surface3; + my_surface3.mirror(my_surface2); + + my_surface3.fill(0.5); + my_surface3.clear(); + + my_surface3=my_surface; + + my_surface3.mirror(my_surface); + + printf("Surface:basic_test(): %d errors.\n",ret); + + return ret; +} + +int linear_sample_test() +{ + printf("Surface:linear_sample_test(): Running...\n"); + + int ret=0; + + surface my_surface(16,16); + + my_surface.fill(0.0f); + + make_pattern(my_surface.begin(),my_surface.get_w(),my_surface.get_h()); + + int extra(5); + surface dest(18+extra*2,18+extra*2); + + int x,y; + for(x=-extra;x my_surface(16,16); + + my_surface.fill(0.0f); + + make_pattern(my_surface.begin(),my_surface.get_w(),my_surface.get_h()); + + { + surface dest(24,24); + + int x,y; + for(x=0;x dest(16,16); + + int x,y; + for(x=0;x