From: Carlos Lopez Date: Wed, 30 Jun 2010 16:32:09 +0000 (+0200) Subject: Merge branch 'nikitakit_master' X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=ac5caa76ff6cc25a7923c86350851a84bb40a93a;hp=e7e506afaa868e76c2dfa74dd33614a9a029bb85;p=synfig.git Merge branch 'nikitakit_master' --- diff --git a/autobuild/api.sh b/autobuild/api.sh old mode 100755 new mode 100644 index 8cd2355..2c5e49e --- a/autobuild/api.sh +++ b/autobuild/api.sh @@ -2,15 +2,19 @@ # # Script to generate API documentation and send it to sf.net # -# Copyright 2009 Konstantin Dmitriev +# Copyright 2009-2010 Konstantin Dmitriev +# Copyright 2010 Carlos López # # 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; either version 2 of # the License, or (at your option) any later version. +# +# This script has been redesigned to be used in a cron work. +# Adapt the following macros to the proper directories values. -export HTMLDIR=$HOME/synfig/api/html -export SOURCEDIR=$HOME/synfig/api/source +export HTMLDIR=$HOME/synfig/synfig-repository/api +export SOURCEDIR=$HOME/synfig/synfig-repository/code/synfig set -e @@ -28,15 +32,9 @@ fi if [ ! -d $SOURCEDIR ]; then mkdir -p `dirname $SOURCEDIR` cd `dirname $SOURCEDIR` - git clone git://synfig.git.sourceforge.net/gitroot/synfig `basename $SOURCEDIR` + git clone --depth 1 git://synfig.git.sourceforge.net/gitroot/synfig/synfig `basename $SOURCEDIR` fi -getversion(){ - VERSION=`cat configure| egrep PACKAGE_VERSION=\'` - VERSION=${VERSION#*\'} - VERSION=${VERSION%\'} -} - mkdir -p $HTMLDIR cd $SOURCEDIR @@ -45,18 +43,30 @@ git checkout remotes/origin/master #generating api to htmldir for module in ETL synfig-core synfig-studio; do -cd $module/trunk +cd $module echo "Generating API for $module..." -autoreconf --install --force || ( sed -i 's/^AC_CONFIG_SUBDIRS/# AC_CONFIG_SUBDIRS/' configure.ac && autoreconf --install --force ) -getversion +case $module in + ETL) + MODULETITLE='Extended Template Library' + ;; + synfig-core) + MODULETITLE='Synfig Core' + ;; + synfig-studio) + MODULETITLE='Synfig Studio' + ;; +esac + VERSION=`cat configure.ac |egrep "AC_INIT\(\[$MODULETITLE\],"| sed "s|.*$MODULETITLE\],\[||" | sed "s|\],\[.*||"` + VERSION=${VERSION#*\'} + VERSION=${VERSION%\'} cp -f doxygen.cfg.in doxygen.cfg sed -i "s/@VERSION@/$VERSION/" doxygen.cfg sed -i "s/@PACKAGE@/$module/" doxygen.cfg doxygen doxygen.cfg rm -rf $HTMLDIR/$module mv doc/html $HTMLDIR/$module -cp $SOURCEDIR/$module/trunk/doxygen.cfg $HTMLDIR/$module -cd ../.. +cp $SOURCEDIR/$module/doxygen.cfg $HTMLDIR/$module +cd .. done #index.html @@ -66,20 +76,11 @@ cat > $HTMLDIR/index.html <

ETL, synfig, synfigstudio API docs

Generated on: $DATE.

EOF -#beep (because we asking password) -echo -e "\a"; sleep 0.2; echo -e "\a"; sleep 0.2; echo -e "\a" - -echo -n "Enter your sf.net username: " -read USERNAME - -#push to sf.net -rsync -avP -e ssh $HTMLDIR/ $USERNAME,synfig@web.sourceforge.net:htdocs/api/ - diff --git a/synfig-core/configure.ac b/synfig-core/configure.ac index 6907d20..1136ee5 100644 --- a/synfig-core/configure.ac +++ b/synfig-core/configure.ac @@ -683,7 +683,7 @@ src/modules/mod_png/Makefile src/modules/mod_ppm/Makefile src/modules/mod_yuv420p/Makefile src/modules/mod_svg/Makefile -src/modules/example/Makefile +src/modules/mod_example/Makefile src/tool/Makefile src/modules/synfig_modules.cfg examples/walk/Makefile diff --git a/synfig-core/po/POTFILES.in b/synfig-core/po/POTFILES.in index ad8b051..65c7398 100644 --- a/synfig-core/po/POTFILES.in +++ b/synfig-core/po/POTFILES.in @@ -1,12 +1,11 @@ # FIXME: move libsynfig into a separate domain -src/modules/example/filledrect.cpp -src/modules/example/filledrect.cpp -src/modules/example/filledrect.h -src/modules/example/main.cpp -src/modules/example/metaballs.cpp -src/modules/example/metaballs.h -src/modules/example/simplecircle.cpp -src/modules/example/simplecircle.h +src/modules/mod_example/filledrect.cpp +src/modules/mod_example/filledrect.h +src/modules/mod_example/main.cpp +src/modules/mod_example/metaballs.cpp +src/modules/mod_example/metaballs.h +src/modules/mod_example/simplecircle.cpp +src/modules/mod_example/simplecircle.h src/modules/lyr_freetype/lyr_freetype.cpp src/modules/lyr_freetype/lyr_freetype.h src/modules/lyr_freetype/main.cpp diff --git a/synfig-core/src/modules/Makefile.am b/synfig-core/src/modules/Makefile.am index 4a40d3e..4d84b1e 100644 --- a/synfig-core/src/modules/Makefile.am +++ b/synfig-core/src/modules/Makefile.am @@ -27,19 +27,19 @@ SUBDIRS = \ mod_mng \ mod_svg \ mod_magickpp \ - example + mod_example EXTRA_DIST = \ untemplate.nsh \ template.nsh \ - example/simplecircle.h \ - example/simplecircle.cpp \ - example/filledrect.h \ - example/main.cpp \ - example/Makefile.am \ - example/filledrect.cpp \ - example/metaballs.cpp \ - example/metaballs.h \ + mod_example/simplecircle.h \ + mod_example/simplecircle.cpp \ + mod_example/filledrect.h \ + mod_example/main.cpp \ + mod_example/Makefile.am \ + mod_example/filledrect.cpp \ + mod_example/metaballs.cpp \ + mod_example/metaballs.h \ mod_mng/trgt_mng.h \ mod_mng/unmod_mng.nsh \ mod_mng/main.cpp \ diff --git a/synfig-core/src/modules/example/Makefile.am b/synfig-core/src/modules/example/Makefile.am deleted file mode 100644 index 1d38d74..0000000 --- a/synfig-core/src/modules/example/Makefile.am +++ /dev/null @@ -1,34 +0,0 @@ -# $Id$ - -MAINTAINERCLEANFILES = \ - Makefile.in - -INCLUDES = \ - -I$(top_builddir) \ - -I$(top_srcdir)/src - - -moduledir = @MODULE_DIR@ - -module_LTLIBRARIES = libexample.la - -libexample_la_SOURCES = \ - main.cpp \ - simplecircle.cpp \ - simplecircle.h \ - filledrect.h \ - filledrect.cpp \ - metaballs.h \ - metaballs.cpp - -libexample_la_LIBADD = \ - ../../synfig/libsynfig.la \ - @SYNFIG_LIBS@ - -libexample_la_LDFLAGS = \ - -module \ - -no-undefined \ - -avoid-version - -libexample_la_CXXFLAGS = \ - @SYNFIG_CFLAGS@ diff --git a/synfig-core/src/modules/example/filledrect.cpp b/synfig-core/src/modules/example/filledrect.cpp deleted file mode 100644 index 329012f..0000000 --- a/synfig-core/src/modules/example/filledrect.cpp +++ /dev/null @@ -1,586 +0,0 @@ -/* === S Y N F I G ========================================================= */ -/*! \file filledrect.cpp -** \brief Implementation of the "Rectangle" layer -** -** $Id$ -** -** \legal -** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley -** Copyright (c) 2008 Chris Moore -** -** 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. -** \endlegal -*/ -/* ========================================================================= */ - -/* === H E A D E R S ======================================================= */ - -#ifdef USING_PCH -# include "pch.h" -#else -#ifdef HAVE_CONFIG_H -# include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "filledrect.h" - -#endif - -/* === U S I N G =========================================================== */ - -using namespace etl; -using namespace std; -using namespace synfig; - -/* === G L O B A L S ======================================================= */ - -SYNFIG_LAYER_INIT(FilledRect); -SYNFIG_LAYER_SET_NAME(FilledRect,"filled_rectangle"); -SYNFIG_LAYER_SET_LOCAL_NAME(FilledRect,N_("Filled Rectangle")); -SYNFIG_LAYER_SET_CATEGORY(FilledRect,N_("Example")); -SYNFIG_LAYER_SET_VERSION(FilledRect,"0.1"); -SYNFIG_LAYER_SET_CVS_ID(FilledRect,"$Id$"); - -/* === P R O C E D U R E S ================================================= */ - -/* === M E T H O D S ======================================================= */ - -/* === E N T R Y P O I N T ================================================= */ - -FilledRect::FilledRect(): - Layer_Composite(1.0,Color::BLEND_STRAIGHT), - color(Color::black()), - point1(0,0), - point2(1,1), - feather_x(0), - feather_y(0), - bevel(0), - bevCircle(0) -{ -} - -bool -FilledRect::set_param(const String & param, const ValueBase &value) -{ - IMPORT(color); - IMPORT(point1); - IMPORT(point2); - IMPORT_PLUS(feather_x, if(feather_x<0)feather_x=0;); - IMPORT_PLUS(feather_y, if(feather_y<0)feather_y=0;); - IMPORT(bevel); - IMPORT(bevCircle); - - return Layer_Composite::set_param(param,value); -} - -ValueBase -FilledRect::get_param(const String ¶m)const -{ - EXPORT(color); - EXPORT(point1); - EXPORT(point2); - EXPORT(feather_x); - EXPORT(feather_y); - EXPORT(bevel); - EXPORT(bevCircle); - - EXPORT_NAME(); - EXPORT_VERSION(); - - return Layer_Composite::get_param(param); -} - -Layer::Vocab -FilledRect::get_param_vocab()const -{ - Layer::Vocab ret(Layer_Composite::get_param_vocab()); - - ret.push_back(ParamDesc("color") - .set_local_name(_("Color")) - ); - - ret.push_back(ParamDesc("point1") - .set_local_name(_("Point 1")) - .set_box("point2") - ); - - ret.push_back(ParamDesc("point2") - .set_local_name(_("Point 2")) - ); - - ret.push_back(ParamDesc("feather_x") - .set_local_name(_("Feather X")) - ); - - ret.push_back(ParamDesc("feather_y") - .set_local_name(_("Feather Y")) - ); - - ret.push_back(ParamDesc("bevel") - .set_local_name(_("Bevel")) - ); - - ret.push_back(ParamDesc("bevCircle") - .set_local_name(_("Keep Bevel Circular")) - ); - - return ret; -} - -synfig::Layer::Handle -FilledRect::hit_check(synfig::Context context, const synfig::Point &point)const -{ - Color clr; - Real amt; - - if (!get_color(point,clr,amt)) - return context.hit_check(point); - - synfig::Layer::Handle tmp; - - if (get_blend_method()==Color::BLEND_BEHIND && (tmp=context.hit_check(point))) - return tmp; - - if (Color::is_onto(get_blend_method()) && !(context.hit_check(point))) - return 0; - - return const_cast(this); -} - -bool -FilledRect::get_color(const Point &pos, Color &out, Real &outamount) const -{ - Point p[2] = {point1,point2}; - Real swap; - - if(p[0][0] > p[1][0]) - { - swap = p[0][0]; - p[0][0] = p[1][0]; - p[1][0] = swap; - } - - if(p[0][1] > p[1][1]) - { - swap = p[0][1]; - p[0][1] = p[1][1]; - p[1][1] = swap; - } - - /* - p[0][0] -= feather_x; - p[1][0] += feather_x; - p[0][1] -= feather_y; - p[1][1] += feather_y;*/ - const Real w = p[1][0] - p[0][0]; - const Real h = p[1][1] - p[0][1]; - - if(pos[0] >= p[0][0] && pos[0] <= p[1][0] && pos[1] >= p[0][1] && pos[1] <= p[1][1]) - { - Real value = 1; - - if(feather_x > 0) - { - Real xdist = pos[0] - p[0][0]; - xdist = min(xdist,p[1][0]-pos[0]); - - if(xdist < feather_x) - { - value = xdist/feather_x; - } - } - - if(feather_y > 0) - { - Real ydist = pos[1]-p[0][1]; - ydist = min(ydist,p[1][1]-pos[1]); - - if(ydist < feather_y) - { - value = min(value,(ydist/feather_y)); - } - } - - //if we're beveled then check with ellipse code... - if(bevel > 0) - { - const Real bev = (bevel > 1) ? 1 : bevel; - const Real bevx = bevCircle ? min(w*bev/2,h*bev/2) : w*bev/2; - const Real bevy = bevCircle ? min(w*bev/2,h*bev/2) : h*bev/2;; - - Vector v(0,0); - bool in = false; - - //based on which quarter it is in (and because it's x/y symmetric) get a positive vector (x/y) - if(pos[0] < p[0][0] + bevx) - { - if(pos[1] < p[0][1] + bevy) - { - v[0] = p[0][0] + bevx - pos[0]; - v[1] = p[0][1] + bevy - pos[1]; - in = true; - }else if(pos[1] > p[1][1] - bevy) - { - v[0] = p[0][0] + bevx - pos[0]; - v[1] = pos[1] - (p[1][1] - bevy); - in = true; - } - } - else if(pos[0] > p[1][0] - bevx) - { - if(pos[1] < p[0][1] + bevy) - { - v[0] = pos[0] - (p[1][0] - bevx); - v[1] = p[0][1] + bevy - pos[1]; - in = true; - }else if(pos[1] > p[1][1] - bevy) - { - v[0] = pos[0] - (p[1][0] - bevx); - v[1] = pos[1] - (p[1][1] - bevy); - in = true; - } - } - - //if it's inside a bevelled block - if(in) - { - const Vector scale(bevx,bevy); - - Vector vc(v[0]/scale[0],v[1]/scale[1]); - Real d = vc.mag(); - - //if it's inside the ellipse - if(d < 1) - { - Real val = atan2(vc[1],vc[0]); - val /= (PI/2); //< will always be (0,pi/2) because both components are positive - - Real fthx=1,fthy=1; - - //change d into distance away from edge - d = 1 - d; - - if(feather_x > 0) - { - if(scale[0] < feather_x) - { - fthy = scale[0]/feather_x; - } - - if(d*scale[0] < feather_x) - { - fthx = d*scale[0]/feather_x; - } - } - - if(feather_y > 0) - { - if(scale[1] < feather_y) - { - fthx = min(fthx,scale[1]/feather_y); - } - - if(d*scale[1] < feather_y) - { - fthy = min(fthy,d*scale[1]/feather_y); - } - } - - //interpolate - outamount = min(value,((1-val)*fthx + val*fthy)) * get_amount(); - out = color; - return true; - - }else return false; - } - } - - outamount = value * get_amount(); - out = color; - - return true; - }else - return false; -} - -Color -FilledRect::get_color(Context context, const Point &pos)const -{ - Color clr; - Real amt; - - if(get_color(pos,clr,amt)) - { - if(amt==1.0 && get_blend_method()==Color::BLEND_STRAIGHT) - return clr; - else - return Color::blend(clr,context.get_color(pos),amt,get_blend_method()); - } - else - return context.get_color(pos); -} - -bool -FilledRect::accelerated_render(Context context,Surface *surface,int quality, const RendDesc &renddesc, ProgressCallback *cb)const -{ - // Width and Height of a pixel - const Point br(renddesc.get_br()), tl(renddesc.get_tl()); - const int w = renddesc.get_w(), h = renddesc.get_h(); - - Real wpp = (br[0]-tl[0])/w; - Real hpp = (br[1]-tl[1])/h; - //const Real xneg = wpp<0?-1:1; - //const Real yneg = hpp<0?-1:1; - - //the bounds of the rectangle - Point p[2] = {point1,point2}; - - if((p[0][0] > p[1][0]) ^ (wpp < 0)) - { - swap(p[0][0],p[1][0]); - } - - if((p[0][1] > p[1][1]) ^ (hpp < 0)) - { - swap(p[0][1],p[1][1]); - } - - /*p[0][0] -= xneg*feather_x; - p[1][0] += xneg*feather_x; - p[0][1] -= yneg*feather_y; - p[1][1] += yneg*feather_y;*/ - - //the integer coordinates - int y_start = (int)((p[0][1] - tl[1])/hpp +.5); //round start up - int x_start = (int)((p[0][0] - tl[0])/wpp +.5); - int y_end = (int)((p[1][1] - tl[1])/hpp +.5); //and ends up - int x_end = (int)((p[1][0] - tl[0])/wpp +.5); - - y_start = max(0,y_start); - x_start = max(0,x_start); - y_end = min(h,y_end); - x_end = min(w,x_end); - - SuperCallback supercb(cb,0,9000,10000); - - if(y_start >= h || x_start > w || x_end < 0 || y_end < 0) - { - if(!context.accelerated_render(surface,quality,renddesc,&supercb)) - { - if(cb)cb->error(strprintf(__FILE__"%d: Accelerated Renderer Failure",__LINE__)); - return false; - } - - return true; - } - - Real xf_start = tl[0] + x_start*wpp; - Point pos(xf_start,tl[1] + y_start*hpp); - - Color clr = Color::black(); - Real amt; - - if(!context.accelerated_render(surface,quality,renddesc,&supercb)) - { - if(cb)cb->error(strprintf(__FILE__"%d: Accelerated Renderer Failure",__LINE__)); - return false; - } - - for(int y = y_start; y < y_end; y++, pos[1] += hpp) - { - pos[0] = xf_start; - for(int x = x_start; x < x_end; x++, pos[0] += wpp) - { - if(get_color(pos,clr,amt)) - { - if(amt==1.0 && get_blend_method()==Color::BLEND_STRAIGHT) - (*surface)[y][x] = clr; - else - (*surface)[y][x] = Color::blend(clr,(*surface)[y][x],amt,get_blend_method()); - } - } - } - - return true; - -#if 0 - //faster version but much more complex - //the floating point - Real y1,y2,y3; - Real x1,x2,x3; - Real dx1,dx2; //reversed in 3rd y section, not used in 2nd - - //the transparent - Real fx = 0, fy = 0; - Real dfx,dfy; - - //Get the slopes of the lines we need to worry about - if(feather_x) - { - dfx = 1/(fxsize); - - if(fxsize*2 > xfw) - { - x1 = xfw/2; - x2 = 0; - x3 = xfw; - }else - { - x1 = fxsize; - x2 = xfw - fxsize; - x3 = xfw; - } - }else - { - fx = 1; - dfx = 0; - x1=0; - x2=xfw; - x3=0; - } - - if(feather_y) - { - dfy = 1/(fysize); - - if(fysize*2 > yfh) - { - y1 = yfh/2; - y2 = 0; - y3 = yfh; - }else - { - y1 = fysize; - y2 = yfh - fysize; - y3 = yfh; - } - - dx1 = ph*feather_x/feather_y; - dx2 = -2*dx1; - - }else - { - fy = 1; - dfy = 0; - y1=0; - y2=yfh; - y3=0; - } - - fy = yf*dfy; - - int x,y; - Real value = 0; - SuperCallback supercb(cb,0,9000,10000); - Surface::pen p; - - Real tx1 = 0,tx2 = - for(y = y_start;yf < y1; y++,yf++,fy+=dfy, tx1+=dx1) - { - fx = xf*dfx; - - p = surface->get_pen(x_start,y); - for(; xf < x1; xf++,p.inc_x(), fx+=dfx) - { - //we are in the x portion... use fx - value = fx*get_amount(); - if(value==1.0 && get_blend_method()==Color::BLEND_STRAIGHT) - p.put_value(color); - else - p.put_value(Color::blend(color,p.get_value(),value,get_blend_method())); - } - - for(;xf < x2; xf++,p.inc_x()) - { - //we are now in y... use fy - value = fy*get_amount(); - if(value==1.0 && get_blend_method()==Color::BLEND_STRAIGHT) - p.put_value(color); - else - p.put_value(Color::blend(color,p.get_value(),value,get_blend_method())); - } - - fx = xfw?(xfw - xf)/xfw:1; - for(;xf < x3 && ; xf++,p.inc_x(), fx-=dfx) - { - //we are in the x portion... use fx - value = max(0,fx*get_amount()); - if(value==1.0 && get_blend_method()==Color::BLEND_STRAIGHT) - p.put_value(color); - else - p.put_value(Color::blend(color,p.get_value(),value,get_blend_method())); - } - } - - x1 = - for(;fy < 1.0; y++,yf++,fy+=dfy) - { - fx = xf*dfx; - - p = surface->get_pen(x_start,y); - for(; xf < x1; xf++,p.inc_x(), fx+=dfx) - { - //we are in the x portion... use fx - value = fx*get_amount(); - if(value==1.0 && get_blend_method()==Color::BLEND_STRAIGHT) - p.put_value(color); - else - p.put_value(Color::blend(color,p.get_value(),value,get_blend_method())); - } - - for(;xf < x2; xf++,p.inc_x()) - { - //we are now in y... use fy - value = fy*get_amount(); - if(value==1.0 && get_blend_method()==Color::BLEND_STRAIGHT) - p.put_value(color); - else - p.put_value(Color::blend(color,p.get_value(),value,get_blend_method())); - } - - fx = xfw?(xfw - xf)/xfw:1; - for(;xf < x3 && ; xf++,p.inc_x(), fx-=dfx) - { - //we are in the x portion... use fx - value = max(0,fx*get_amount()); - if(value==1.0 && get_blend_method()==Color::BLEND_STRAIGHT) - p.put_value(color); - else - p.put_value(Color::blend(color,p.get_value(),value,get_blend_method())); - } - } - - for() - { - for(int x = x_start; x < x_end; x++) - { - - } - } - -#endif - - // Mark our progress as finished - if(cb && !cb->amount_complete(10000,10000)) - return false; - - return true; -} diff --git a/synfig-core/src/modules/example/filledrect.h b/synfig-core/src/modules/example/filledrect.h deleted file mode 100644 index b540105..0000000 --- a/synfig-core/src/modules/example/filledrect.h +++ /dev/null @@ -1,81 +0,0 @@ -/* === S Y N F I G ========================================================= */ -/*! \file filledrect.h -** \brief Header file for implementation of the "Rectangle" layer -** -** $Id$ -** -** \legal -** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley -** -** 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. -** \endlegal -*/ -/* ========================================================================= */ - -/* === S T A R T =========================================================== */ - -#ifndef __SYNFIG_FILLEDRECT_H -#define __SYNFIG_FILLEDRECT_H - -/* === H E A D E R S ======================================================= */ - -#include -#include -#include -#include -#include - -/* === M A C R O S ========================================================= */ - -/* === T Y P E D E F S ===================================================== */ - -/* === C L A S S E S & S T R U C T S ======================================= */ - -class FilledRect : public synfig::Layer_Composite -{ - SYNFIG_LAYER_MODULE_EXT - -private: - - synfig::Color color; - - synfig::Point point1; - synfig::Point point2; - - synfig::Real feather_x; - synfig::Real feather_y; - - synfig::Real bevel; - - bool bevCircle; - - bool get_color(const synfig::Point &pos, synfig::Color &out, synfig::Real &outamount)const; - -public: - - FilledRect(); - - virtual bool set_param(const synfig::String & param, const synfig::ValueBase &value); - - virtual synfig::ValueBase get_param(const synfig::String & param)const; - - virtual synfig::Color get_color(synfig::Context context, const synfig::Point &pos)const; - - virtual bool accelerated_render(synfig::Context context,synfig::Surface *surface,int quality, const synfig::RendDesc &renddesc, synfig::ProgressCallback *cb)const; - - virtual Vocab get_param_vocab()const; - - virtual synfig::Layer::Handle hit_check(synfig::Context context, const synfig::Point &point)const; -}; // END of class FilledRect - -/* === E N D =============================================================== */ - -#endif diff --git a/synfig-core/src/modules/example/main.cpp b/synfig-core/src/modules/example/main.cpp deleted file mode 100644 index 2a57384..0000000 --- a/synfig-core/src/modules/example/main.cpp +++ /dev/null @@ -1,61 +0,0 @@ -/* === S Y N F I G ========================================================= */ -/*! \file example/main.cpp -** \brief Template Header -** -** $Id$ -** -** \legal -** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley -** -** 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. -** \endlegal -** -** === N O T E S =========================================================== -** -** ========================================================================= */ - -/* === H E A D E R S ======================================================= */ - -#define SYNFIG_MODULE - -#ifdef USING_PCH -# include "pch.h" -#else -#ifdef HAVE_CONFIG_H -# include -#endif - -#include -#include -#include -#include "simplecircle.h" -#include "filledrect.h" -#include "metaballs.h" - -#endif - -/* === E N T R Y P O I N T ================================================= */ - -MODULE_DESC_BEGIN(example) - MODULE_NAME("Example Module") - MODULE_DESCRIPTION("A dummy module that serves as a starting point for writing other modules.") - MODULE_AUTHOR("Robert B. Quattlebaum") - MODULE_VERSION("1.0") - MODULE_COPYRIGHT(SYNFIG_COPYRIGHT) -MODULE_DESC_END - -MODULE_INVENTORY_BEGIN(example) - BEGIN_LAYERS - LAYER(SimpleCircle) - LAYER(FilledRect) - LAYER(Metaballs) - END_LAYERS -MODULE_INVENTORY_END diff --git a/synfig-core/src/modules/example/metaballs.cpp b/synfig-core/src/modules/example/metaballs.cpp deleted file mode 100644 index 0cfa6c3..0000000 --- a/synfig-core/src/modules/example/metaballs.cpp +++ /dev/null @@ -1,252 +0,0 @@ -/* === S Y N F I G ========================================================= */ -/*! \file metaballs.cpp -** \brief Implementation of the "Metaballs" layer -** -** $Id$ -** -** \legal -** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley -** -** 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. -** \endlegal -*/ -/* ========================================================================= */ - -/* === H E A D E R S ======================================================= */ - -#ifdef USING_PCH -# include "pch.h" -#else -#ifdef HAVE_CONFIG_H -# include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "metaballs.h" - -#endif - -/* === U S I N G =========================================================== */ - -using namespace etl; -using namespace std; -using namespace synfig; - -/* === G L O B A L S ======================================================= */ - -SYNFIG_LAYER_INIT(Metaballs); -SYNFIG_LAYER_SET_NAME(Metaballs,"metaballs"); -SYNFIG_LAYER_SET_LOCAL_NAME(Metaballs,N_("Metaballs")); -SYNFIG_LAYER_SET_CATEGORY(Metaballs,N_("Example")); -SYNFIG_LAYER_SET_VERSION(Metaballs,"0.1"); -SYNFIG_LAYER_SET_CVS_ID(Metaballs,"$Id$"); - -/* === P R O C E D U R E S ================================================= */ - -/* === M E T H O D S ======================================================= */ - -/* === E N T R Y P O I N T ================================================= */ - -Metaballs::Metaballs(): - Layer_Composite(1.0,Color::BLEND_STRAIGHT), - gradient(Color::black(), Color::white()), - threshold(0), - threshold2(1), - positive(false) -{ - centers.push_back(Point( 0, -1.5)); radii.push_back(2.5); weights.push_back(1); - centers.push_back(Point(-2, 1)); radii.push_back(2.5); weights.push_back(1); - centers.push_back(Point( 2, 1)); radii.push_back(2.5); weights.push_back(1); -} - -bool -Metaballs::set_param(const String & param, const ValueBase &value) -{ - if( param=="centers" && value.same_type_as(centers)) - { - centers = value; - return true; - } - - if( param=="weights" && value.same_type_as(weights)) - { - weights = value; - return true; - } - - if( param=="radii" && value.same_type_as(radii)) - { - radii = value; - return true; - } - - IMPORT(gradient); - IMPORT(threshold); - IMPORT(threshold2); - IMPORT(positive); - - return Layer_Composite::set_param(param,value); -} - -ValueBase -Metaballs::get_param(const String ¶m)const -{ - EXPORT(gradient); - - EXPORT(radii); - EXPORT(weights); - EXPORT(centers); - EXPORT(threshold); - EXPORT(threshold2); - EXPORT(positive); - - EXPORT_NAME(); - EXPORT_VERSION(); - - return Layer_Composite::get_param(param); -} - -Layer::Vocab -Metaballs::get_param_vocab()const -{ - Layer::Vocab ret(Layer_Composite::get_param_vocab()); - - ret.push_back(ParamDesc("gradient") - .set_local_name(_("Gradient")) - ); - - ret.push_back(ParamDesc("centers") - .set_local_name(_("Points")) - ); - - ret.push_back(ParamDesc("radii") - .set_local_name(_("Radii")) - ); - - ret.push_back(ParamDesc("weights") - .set_local_name(_("Weights")) - ); - - ret.push_back(ParamDesc("threshold") - .set_local_name(_("Gradient Left")) - ); - - ret.push_back(ParamDesc("threshold2") - .set_local_name(_("Gradient Right")) - ); - - ret.push_back(ParamDesc("positive") - .set_local_name(_("Positive Only")) - ); - - return ret; -} - -synfig::Layer::Handle -Metaballs::hit_check(synfig::Context context, const synfig::Point &point)const -{ - Real density(totaldensity(point)); - - if (density <= 0 || density > 1 || get_amount() == 0) - return context.hit_check(point); - - synfig::Layer::Handle tmp; - - if (get_blend_method()==Color::BLEND_BEHIND && (tmp=context.hit_check(point))) - return tmp; - - if (Color::is_onto(get_blend_method()) && !(context.hit_check(point))) - return 0; - - return const_cast(this); -} - -Real -Metaballs::densityfunc(const synfig::Point &p, const synfig::Point &c, Real R)const -{ - const Real dx = p[0] - c[0]; - const Real dy = p[1] - c[1]; - - const Real n = (1 - (dx*dx + dy*dy)/(R*R)); - if (positive && n < 0) return 0; - return (n*n*n); - - /* - f(d) = (1 - d^2)^3 - f'(d) = -6d * (1 - d^2)^2 - - could use this too... - f(d) = (1 - d^2)^2 - f'(d) = -6d * (1 - d^2) - */ -} - -Real -Metaballs::totaldensity(const Point &pos)const -{ - Real density = 0; - - //sum up weighted functions - for(unsigned int i=0;ierror(strprintf(__FILE__"%d: Accelerated Renderer Failure",__LINE__)); - return false; - } - - for(int y = 0; y < h; y++, pos[1] += ph) - { - pos[0] = tl[0]; - for(int x = 0; x < w; x++, pos[0] += pw) - (*surface)[y][x] = Color::blend(gradient(totaldensity(pos)),(*surface)[y][x],get_amount(),get_blend_method()); - } - - // Mark our progress as finished - if(cb && !cb->amount_complete(10000,10000)) - return false; - - return true; -} diff --git a/synfig-core/src/modules/example/metaballs.h b/synfig-core/src/modules/example/metaballs.h deleted file mode 100644 index d9ae649..0000000 --- a/synfig-core/src/modules/example/metaballs.h +++ /dev/null @@ -1,81 +0,0 @@ -/* === S Y N F I G ========================================================= */ -/*! \file metaballs.h -** \brief Header file for implementation of the "Metaballs" layer -** -** $Id$ -** -** \legal -** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley -** -** 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. -** \endlegal -*/ -/* ========================================================================= */ - -/* === S T A R T =========================================================== */ - -#ifndef __SYNFIG_METABALLS_H -#define __SYNFIG_METABALLS_H - -/* === H E A D E R S ======================================================= */ - -#include -#include -#include -#include -#include - -/* === M A C R O S ========================================================= */ - -/* === T Y P E D E F S ===================================================== */ - -/* === C L A S S E S & S T R U C T S ======================================= */ -class Metaballs : public synfig::Layer_Composite -{ - SYNFIG_LAYER_MODULE_EXT - -private: - - synfig::Gradient gradient; - - std::vector centers; - std::vector radii; - std::vector weights; - - synfig::Real threshold; - synfig::Real threshold2; - - bool positive; - - synfig::Real densityfunc(const synfig::Point &p, const synfig::Point &c, synfig::Real R)const; - - synfig::Real totaldensity(const synfig::Point &pos)const; - -public: - - Metaballs(); - - virtual bool set_param(const synfig::String & param, const synfig::ValueBase &value); - - virtual synfig::ValueBase get_param(const synfig::String & param)const; - - virtual synfig::Color get_color(synfig::Context context, const synfig::Point &pos)const; - - virtual bool accelerated_render(synfig::Context context,synfig::Surface *surface,int quality, const synfig::RendDesc &renddesc, synfig::ProgressCallback *cb)const; - - virtual Vocab get_param_vocab()const; - - virtual synfig::Layer::Handle hit_check(synfig::Context context, const synfig::Point &point)const; -}; // END of class Metaballs - -/* === E N D =============================================================== */ - -#endif diff --git a/synfig-core/src/modules/example/simplecircle.cpp b/synfig-core/src/modules/example/simplecircle.cpp deleted file mode 100644 index e2eb896..0000000 --- a/synfig-core/src/modules/example/simplecircle.cpp +++ /dev/null @@ -1,187 +0,0 @@ -/* === S Y N F I G ========================================================= */ -/*! \file simplecircle.cpp -** \brief Implementation of the "Simple Circle" layer -** -** $Id$ -** -** \legal -** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley -** Copyright (c) 2008 Chris Moore -** -** 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. -** \endlegal -*/ -/* ========================================================================= */ - -/* === H E A D E R S ======================================================= */ - -#ifdef USING_PCH -# include "pch.h" -#else -#ifdef HAVE_CONFIG_H -# include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "simplecircle.h" - -#endif - -/* === U S I N G =========================================================== */ - -using namespace etl; -using namespace std; -using namespace synfig; - -/* === G L O B A L S ======================================================= */ - -SYNFIG_LAYER_INIT(SimpleCircle); -SYNFIG_LAYER_SET_NAME(SimpleCircle,"simple_circle"); -SYNFIG_LAYER_SET_LOCAL_NAME(SimpleCircle,N_("Simple Circle")); -SYNFIG_LAYER_SET_CATEGORY(SimpleCircle,N_("Example")); -SYNFIG_LAYER_SET_VERSION(SimpleCircle,"0.1"); -SYNFIG_LAYER_SET_CVS_ID(SimpleCircle,"$Id$"); - -/* === P R O C E D U R E S ================================================= */ - -/* === M E T H O D S ======================================================= */ - -/* === E N T R Y P O I N T ================================================= */ - -SimpleCircle::SimpleCircle(): - Layer_Composite(1.0,Color::BLEND_STRAIGHT), - color(Color::black()), - center(0,0), - radius(0.5) -{ -} - -bool -SimpleCircle::set_param(const String & param, const ValueBase &value) -{ - IMPORT(color); - IMPORT(center); - IMPORT(radius); - - return Layer_Composite::set_param(param,value); -} - -ValueBase -SimpleCircle::get_param(const String ¶m)const -{ - EXPORT(color); - EXPORT(center); - EXPORT(radius); - - EXPORT_NAME(); - EXPORT_VERSION(); - - return Layer_Composite::get_param(param); -} - -Layer::Vocab -SimpleCircle::get_param_vocab()const -{ - Layer::Vocab ret(Layer_Composite::get_param_vocab()); - - ret.push_back(ParamDesc("color") - .set_local_name(_("Color")) - ); - - ret.push_back(ParamDesc("center") - .set_local_name(_("Center")) - ); - - ret.push_back(ParamDesc("radius") - .set_local_name(_("Radius")) - .set_description(_("This is the radius of the circle")) - .set_origin("center") - ); - - return ret; -} - -Color -SimpleCircle::get_color(Context context, const Point &pos)const -{ - - if((pos-center).mag()(this); - else - return context.hit_check(pos); -} - -/* -bool -SimpleCircle::accelerated_render(Context context,Surface *surface,int quality, const RendDesc &renddesc, ProgressCallback *cb)const -{ - if(get_amount()==1.0 && get_blend_method()==Color::BLEND_STRAIGHT) - { - // Mark our progress as starting - if(cb && !cb->amount_complete(0,1000)) - return false; - - surface->set_wh(renddesc.get_w(),renddesc.get_h()); - surface->fill(color); - - // Mark our progress as finished - if(cb && !cb->amount_complete(1000,1000)) - return false; - - return true; - } - - SuperCallback supercb(cb,0,9500,10000); - - if(!context.accelerated_render(surface,quality,renddesc,&supercb)) - return false; - - int x,y; - - Surface::alpha_pen apen(surface->begin()); - - apen.set_value(color); - apen.set_alpha(get_amount()); - apen.set_blend_method(get_blend_method()); - - for(y=0;yamount_complete(10000,10000)) - return false; - - return true; -} -*/ diff --git a/synfig-core/src/modules/example/simplecircle.h b/synfig-core/src/modules/example/simplecircle.h deleted file mode 100644 index 48c555c..0000000 --- a/synfig-core/src/modules/example/simplecircle.h +++ /dev/null @@ -1,73 +0,0 @@ -/* === S Y N F I G ========================================================= */ -/*! \file simplecircle.h -** \brief Header file for implementation of the "Simple Circle" layer -** -** $Id$ -** -** \legal -** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley -** -** 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. -** \endlegal -*/ -/* ========================================================================= */ - -/* === S T A R T =========================================================== */ - -#ifndef __SYNFIG_SIMPLECIRCLE_H -#define __SYNFIG_SIMPLECIRCLE_H - -/* === H E A D E R S ======================================================= */ - -#include -#include -#include -#include -#include - -/* === M A C R O S ========================================================= */ - -/* === T Y P E D E F S ===================================================== */ - -/* === C L A S S E S & S T R U C T S ======================================= */ - -class SimpleCircle : public synfig::Layer_Composite -{ - SYNFIG_LAYER_MODULE_EXT - -private: - - synfig::Color color; - - synfig::Point center; - - synfig::Real radius; - -public: - - SimpleCircle(); - - virtual bool set_param(const synfig::String & param, const synfig::ValueBase &value); - - virtual synfig::ValueBase get_param(const synfig::String & param)const; - - virtual synfig::Color get_color(synfig::Context context, const synfig::Point &pos)const; - - //virtual bool accelerated_render(synfig::Context context,synfig::Surface *surface,int quality, const synfig::RendDesc &renddesc, synfig::ProgressCallback *cb)const; - - synfig::Layer::Handle hit_check(synfig::Context context, const synfig::Point &point)const; - - virtual Vocab get_param_vocab()const; -}; // END of class SimpleCircle - -/* === E N D =============================================================== */ - -#endif diff --git a/synfig-core/src/modules/mod_example/Makefile.am b/synfig-core/src/modules/mod_example/Makefile.am new file mode 100644 index 0000000..bd4566f --- /dev/null +++ b/synfig-core/src/modules/mod_example/Makefile.am @@ -0,0 +1,38 @@ +# $Id$ + +MAINTAINERCLEANFILES = \ + Makefile.in + +INCLUDES = \ + -I$(top_builddir) \ + -I$(top_srcdir)/src + + +moduledir = @MODULE_DIR@ + +module_LTLIBRARIES = libmod_example.la + +libmod_example_la_SOURCES = \ + main.cpp \ + simplecircle.cpp \ + simplecircle.h \ + filledrect.h \ + filledrect.cpp \ + metaballs.h \ + metaballs.cpp + +libmod_example_la_LIBADD = \ + ../../synfig/libsynfig.la \ + @SYNFIG_LIBS@ + +libmod_example_la_LDFLAGS = \ + -module \ + -no-undefined \ + -avoid-version + +libmod_example_la_CXXFLAGS = \ + @SYNFIG_CFLAGS@ + +EXTRA_DIST = \ + mod_example.nsh \ + unmod_example.nsh diff --git a/synfig-core/src/modules/mod_example/filledrect.cpp b/synfig-core/src/modules/mod_example/filledrect.cpp new file mode 100644 index 0000000..329012f --- /dev/null +++ b/synfig-core/src/modules/mod_example/filledrect.cpp @@ -0,0 +1,586 @@ +/* === S Y N F I G ========================================================= */ +/*! \file filledrect.cpp +** \brief Implementation of the "Rectangle" layer +** +** $Id$ +** +** \legal +** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley +** Copyright (c) 2008 Chris Moore +** +** 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. +** \endlegal +*/ +/* ========================================================================= */ + +/* === H E A D E R S ======================================================= */ + +#ifdef USING_PCH +# include "pch.h" +#else +#ifdef HAVE_CONFIG_H +# include +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "filledrect.h" + +#endif + +/* === U S I N G =========================================================== */ + +using namespace etl; +using namespace std; +using namespace synfig; + +/* === G L O B A L S ======================================================= */ + +SYNFIG_LAYER_INIT(FilledRect); +SYNFIG_LAYER_SET_NAME(FilledRect,"filled_rectangle"); +SYNFIG_LAYER_SET_LOCAL_NAME(FilledRect,N_("Filled Rectangle")); +SYNFIG_LAYER_SET_CATEGORY(FilledRect,N_("Example")); +SYNFIG_LAYER_SET_VERSION(FilledRect,"0.1"); +SYNFIG_LAYER_SET_CVS_ID(FilledRect,"$Id$"); + +/* === P R O C E D U R E S ================================================= */ + +/* === M E T H O D S ======================================================= */ + +/* === E N T R Y P O I N T ================================================= */ + +FilledRect::FilledRect(): + Layer_Composite(1.0,Color::BLEND_STRAIGHT), + color(Color::black()), + point1(0,0), + point2(1,1), + feather_x(0), + feather_y(0), + bevel(0), + bevCircle(0) +{ +} + +bool +FilledRect::set_param(const String & param, const ValueBase &value) +{ + IMPORT(color); + IMPORT(point1); + IMPORT(point2); + IMPORT_PLUS(feather_x, if(feather_x<0)feather_x=0;); + IMPORT_PLUS(feather_y, if(feather_y<0)feather_y=0;); + IMPORT(bevel); + IMPORT(bevCircle); + + return Layer_Composite::set_param(param,value); +} + +ValueBase +FilledRect::get_param(const String ¶m)const +{ + EXPORT(color); + EXPORT(point1); + EXPORT(point2); + EXPORT(feather_x); + EXPORT(feather_y); + EXPORT(bevel); + EXPORT(bevCircle); + + EXPORT_NAME(); + EXPORT_VERSION(); + + return Layer_Composite::get_param(param); +} + +Layer::Vocab +FilledRect::get_param_vocab()const +{ + Layer::Vocab ret(Layer_Composite::get_param_vocab()); + + ret.push_back(ParamDesc("color") + .set_local_name(_("Color")) + ); + + ret.push_back(ParamDesc("point1") + .set_local_name(_("Point 1")) + .set_box("point2") + ); + + ret.push_back(ParamDesc("point2") + .set_local_name(_("Point 2")) + ); + + ret.push_back(ParamDesc("feather_x") + .set_local_name(_("Feather X")) + ); + + ret.push_back(ParamDesc("feather_y") + .set_local_name(_("Feather Y")) + ); + + ret.push_back(ParamDesc("bevel") + .set_local_name(_("Bevel")) + ); + + ret.push_back(ParamDesc("bevCircle") + .set_local_name(_("Keep Bevel Circular")) + ); + + return ret; +} + +synfig::Layer::Handle +FilledRect::hit_check(synfig::Context context, const synfig::Point &point)const +{ + Color clr; + Real amt; + + if (!get_color(point,clr,amt)) + return context.hit_check(point); + + synfig::Layer::Handle tmp; + + if (get_blend_method()==Color::BLEND_BEHIND && (tmp=context.hit_check(point))) + return tmp; + + if (Color::is_onto(get_blend_method()) && !(context.hit_check(point))) + return 0; + + return const_cast(this); +} + +bool +FilledRect::get_color(const Point &pos, Color &out, Real &outamount) const +{ + Point p[2] = {point1,point2}; + Real swap; + + if(p[0][0] > p[1][0]) + { + swap = p[0][0]; + p[0][0] = p[1][0]; + p[1][0] = swap; + } + + if(p[0][1] > p[1][1]) + { + swap = p[0][1]; + p[0][1] = p[1][1]; + p[1][1] = swap; + } + + /* + p[0][0] -= feather_x; + p[1][0] += feather_x; + p[0][1] -= feather_y; + p[1][1] += feather_y;*/ + const Real w = p[1][0] - p[0][0]; + const Real h = p[1][1] - p[0][1]; + + if(pos[0] >= p[0][0] && pos[0] <= p[1][0] && pos[1] >= p[0][1] && pos[1] <= p[1][1]) + { + Real value = 1; + + if(feather_x > 0) + { + Real xdist = pos[0] - p[0][0]; + xdist = min(xdist,p[1][0]-pos[0]); + + if(xdist < feather_x) + { + value = xdist/feather_x; + } + } + + if(feather_y > 0) + { + Real ydist = pos[1]-p[0][1]; + ydist = min(ydist,p[1][1]-pos[1]); + + if(ydist < feather_y) + { + value = min(value,(ydist/feather_y)); + } + } + + //if we're beveled then check with ellipse code... + if(bevel > 0) + { + const Real bev = (bevel > 1) ? 1 : bevel; + const Real bevx = bevCircle ? min(w*bev/2,h*bev/2) : w*bev/2; + const Real bevy = bevCircle ? min(w*bev/2,h*bev/2) : h*bev/2;; + + Vector v(0,0); + bool in = false; + + //based on which quarter it is in (and because it's x/y symmetric) get a positive vector (x/y) + if(pos[0] < p[0][0] + bevx) + { + if(pos[1] < p[0][1] + bevy) + { + v[0] = p[0][0] + bevx - pos[0]; + v[1] = p[0][1] + bevy - pos[1]; + in = true; + }else if(pos[1] > p[1][1] - bevy) + { + v[0] = p[0][0] + bevx - pos[0]; + v[1] = pos[1] - (p[1][1] - bevy); + in = true; + } + } + else if(pos[0] > p[1][0] - bevx) + { + if(pos[1] < p[0][1] + bevy) + { + v[0] = pos[0] - (p[1][0] - bevx); + v[1] = p[0][1] + bevy - pos[1]; + in = true; + }else if(pos[1] > p[1][1] - bevy) + { + v[0] = pos[0] - (p[1][0] - bevx); + v[1] = pos[1] - (p[1][1] - bevy); + in = true; + } + } + + //if it's inside a bevelled block + if(in) + { + const Vector scale(bevx,bevy); + + Vector vc(v[0]/scale[0],v[1]/scale[1]); + Real d = vc.mag(); + + //if it's inside the ellipse + if(d < 1) + { + Real val = atan2(vc[1],vc[0]); + val /= (PI/2); //< will always be (0,pi/2) because both components are positive + + Real fthx=1,fthy=1; + + //change d into distance away from edge + d = 1 - d; + + if(feather_x > 0) + { + if(scale[0] < feather_x) + { + fthy = scale[0]/feather_x; + } + + if(d*scale[0] < feather_x) + { + fthx = d*scale[0]/feather_x; + } + } + + if(feather_y > 0) + { + if(scale[1] < feather_y) + { + fthx = min(fthx,scale[1]/feather_y); + } + + if(d*scale[1] < feather_y) + { + fthy = min(fthy,d*scale[1]/feather_y); + } + } + + //interpolate + outamount = min(value,((1-val)*fthx + val*fthy)) * get_amount(); + out = color; + return true; + + }else return false; + } + } + + outamount = value * get_amount(); + out = color; + + return true; + }else + return false; +} + +Color +FilledRect::get_color(Context context, const Point &pos)const +{ + Color clr; + Real amt; + + if(get_color(pos,clr,amt)) + { + if(amt==1.0 && get_blend_method()==Color::BLEND_STRAIGHT) + return clr; + else + return Color::blend(clr,context.get_color(pos),amt,get_blend_method()); + } + else + return context.get_color(pos); +} + +bool +FilledRect::accelerated_render(Context context,Surface *surface,int quality, const RendDesc &renddesc, ProgressCallback *cb)const +{ + // Width and Height of a pixel + const Point br(renddesc.get_br()), tl(renddesc.get_tl()); + const int w = renddesc.get_w(), h = renddesc.get_h(); + + Real wpp = (br[0]-tl[0])/w; + Real hpp = (br[1]-tl[1])/h; + //const Real xneg = wpp<0?-1:1; + //const Real yneg = hpp<0?-1:1; + + //the bounds of the rectangle + Point p[2] = {point1,point2}; + + if((p[0][0] > p[1][0]) ^ (wpp < 0)) + { + swap(p[0][0],p[1][0]); + } + + if((p[0][1] > p[1][1]) ^ (hpp < 0)) + { + swap(p[0][1],p[1][1]); + } + + /*p[0][0] -= xneg*feather_x; + p[1][0] += xneg*feather_x; + p[0][1] -= yneg*feather_y; + p[1][1] += yneg*feather_y;*/ + + //the integer coordinates + int y_start = (int)((p[0][1] - tl[1])/hpp +.5); //round start up + int x_start = (int)((p[0][0] - tl[0])/wpp +.5); + int y_end = (int)((p[1][1] - tl[1])/hpp +.5); //and ends up + int x_end = (int)((p[1][0] - tl[0])/wpp +.5); + + y_start = max(0,y_start); + x_start = max(0,x_start); + y_end = min(h,y_end); + x_end = min(w,x_end); + + SuperCallback supercb(cb,0,9000,10000); + + if(y_start >= h || x_start > w || x_end < 0 || y_end < 0) + { + if(!context.accelerated_render(surface,quality,renddesc,&supercb)) + { + if(cb)cb->error(strprintf(__FILE__"%d: Accelerated Renderer Failure",__LINE__)); + return false; + } + + return true; + } + + Real xf_start = tl[0] + x_start*wpp; + Point pos(xf_start,tl[1] + y_start*hpp); + + Color clr = Color::black(); + Real amt; + + if(!context.accelerated_render(surface,quality,renddesc,&supercb)) + { + if(cb)cb->error(strprintf(__FILE__"%d: Accelerated Renderer Failure",__LINE__)); + return false; + } + + for(int y = y_start; y < y_end; y++, pos[1] += hpp) + { + pos[0] = xf_start; + for(int x = x_start; x < x_end; x++, pos[0] += wpp) + { + if(get_color(pos,clr,amt)) + { + if(amt==1.0 && get_blend_method()==Color::BLEND_STRAIGHT) + (*surface)[y][x] = clr; + else + (*surface)[y][x] = Color::blend(clr,(*surface)[y][x],amt,get_blend_method()); + } + } + } + + return true; + +#if 0 + //faster version but much more complex + //the floating point + Real y1,y2,y3; + Real x1,x2,x3; + Real dx1,dx2; //reversed in 3rd y section, not used in 2nd + + //the transparent + Real fx = 0, fy = 0; + Real dfx,dfy; + + //Get the slopes of the lines we need to worry about + if(feather_x) + { + dfx = 1/(fxsize); + + if(fxsize*2 > xfw) + { + x1 = xfw/2; + x2 = 0; + x3 = xfw; + }else + { + x1 = fxsize; + x2 = xfw - fxsize; + x3 = xfw; + } + }else + { + fx = 1; + dfx = 0; + x1=0; + x2=xfw; + x3=0; + } + + if(feather_y) + { + dfy = 1/(fysize); + + if(fysize*2 > yfh) + { + y1 = yfh/2; + y2 = 0; + y3 = yfh; + }else + { + y1 = fysize; + y2 = yfh - fysize; + y3 = yfh; + } + + dx1 = ph*feather_x/feather_y; + dx2 = -2*dx1; + + }else + { + fy = 1; + dfy = 0; + y1=0; + y2=yfh; + y3=0; + } + + fy = yf*dfy; + + int x,y; + Real value = 0; + SuperCallback supercb(cb,0,9000,10000); + Surface::pen p; + + Real tx1 = 0,tx2 = + for(y = y_start;yf < y1; y++,yf++,fy+=dfy, tx1+=dx1) + { + fx = xf*dfx; + + p = surface->get_pen(x_start,y); + for(; xf < x1; xf++,p.inc_x(), fx+=dfx) + { + //we are in the x portion... use fx + value = fx*get_amount(); + if(value==1.0 && get_blend_method()==Color::BLEND_STRAIGHT) + p.put_value(color); + else + p.put_value(Color::blend(color,p.get_value(),value,get_blend_method())); + } + + for(;xf < x2; xf++,p.inc_x()) + { + //we are now in y... use fy + value = fy*get_amount(); + if(value==1.0 && get_blend_method()==Color::BLEND_STRAIGHT) + p.put_value(color); + else + p.put_value(Color::blend(color,p.get_value(),value,get_blend_method())); + } + + fx = xfw?(xfw - xf)/xfw:1; + for(;xf < x3 && ; xf++,p.inc_x(), fx-=dfx) + { + //we are in the x portion... use fx + value = max(0,fx*get_amount()); + if(value==1.0 && get_blend_method()==Color::BLEND_STRAIGHT) + p.put_value(color); + else + p.put_value(Color::blend(color,p.get_value(),value,get_blend_method())); + } + } + + x1 = + for(;fy < 1.0; y++,yf++,fy+=dfy) + { + fx = xf*dfx; + + p = surface->get_pen(x_start,y); + for(; xf < x1; xf++,p.inc_x(), fx+=dfx) + { + //we are in the x portion... use fx + value = fx*get_amount(); + if(value==1.0 && get_blend_method()==Color::BLEND_STRAIGHT) + p.put_value(color); + else + p.put_value(Color::blend(color,p.get_value(),value,get_blend_method())); + } + + for(;xf < x2; xf++,p.inc_x()) + { + //we are now in y... use fy + value = fy*get_amount(); + if(value==1.0 && get_blend_method()==Color::BLEND_STRAIGHT) + p.put_value(color); + else + p.put_value(Color::blend(color,p.get_value(),value,get_blend_method())); + } + + fx = xfw?(xfw - xf)/xfw:1; + for(;xf < x3 && ; xf++,p.inc_x(), fx-=dfx) + { + //we are in the x portion... use fx + value = max(0,fx*get_amount()); + if(value==1.0 && get_blend_method()==Color::BLEND_STRAIGHT) + p.put_value(color); + else + p.put_value(Color::blend(color,p.get_value(),value,get_blend_method())); + } + } + + for() + { + for(int x = x_start; x < x_end; x++) + { + + } + } + +#endif + + // Mark our progress as finished + if(cb && !cb->amount_complete(10000,10000)) + return false; + + return true; +} diff --git a/synfig-core/src/modules/mod_example/filledrect.h b/synfig-core/src/modules/mod_example/filledrect.h new file mode 100644 index 0000000..b540105 --- /dev/null +++ b/synfig-core/src/modules/mod_example/filledrect.h @@ -0,0 +1,81 @@ +/* === S Y N F I G ========================================================= */ +/*! \file filledrect.h +** \brief Header file for implementation of the "Rectangle" layer +** +** $Id$ +** +** \legal +** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley +** +** 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. +** \endlegal +*/ +/* ========================================================================= */ + +/* === S T A R T =========================================================== */ + +#ifndef __SYNFIG_FILLEDRECT_H +#define __SYNFIG_FILLEDRECT_H + +/* === H E A D E R S ======================================================= */ + +#include +#include +#include +#include +#include + +/* === M A C R O S ========================================================= */ + +/* === T Y P E D E F S ===================================================== */ + +/* === C L A S S E S & S T R U C T S ======================================= */ + +class FilledRect : public synfig::Layer_Composite +{ + SYNFIG_LAYER_MODULE_EXT + +private: + + synfig::Color color; + + synfig::Point point1; + synfig::Point point2; + + synfig::Real feather_x; + synfig::Real feather_y; + + synfig::Real bevel; + + bool bevCircle; + + bool get_color(const synfig::Point &pos, synfig::Color &out, synfig::Real &outamount)const; + +public: + + FilledRect(); + + virtual bool set_param(const synfig::String & param, const synfig::ValueBase &value); + + virtual synfig::ValueBase get_param(const synfig::String & param)const; + + virtual synfig::Color get_color(synfig::Context context, const synfig::Point &pos)const; + + virtual bool accelerated_render(synfig::Context context,synfig::Surface *surface,int quality, const synfig::RendDesc &renddesc, synfig::ProgressCallback *cb)const; + + virtual Vocab get_param_vocab()const; + + virtual synfig::Layer::Handle hit_check(synfig::Context context, const synfig::Point &point)const; +}; // END of class FilledRect + +/* === E N D =============================================================== */ + +#endif diff --git a/synfig-core/src/modules/mod_example/main.cpp b/synfig-core/src/modules/mod_example/main.cpp new file mode 100644 index 0000000..614a078 --- /dev/null +++ b/synfig-core/src/modules/mod_example/main.cpp @@ -0,0 +1,61 @@ +/* === S Y N F I G ========================================================= */ +/*! \file example/main.cpp +** \brief Template Header +** +** $Id$ +** +** \legal +** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley +** +** 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. +** \endlegal +** +** === N O T E S =========================================================== +** +** ========================================================================= */ + +/* === H E A D E R S ======================================================= */ + +#define SYNFIG_MODULE + +#ifdef USING_PCH +# include "pch.h" +#else +#ifdef HAVE_CONFIG_H +# include +#endif + +#include +#include +#include +#include "simplecircle.h" +#include "filledrect.h" +#include "metaballs.h" + +#endif + +/* === E N T R Y P O I N T ================================================= */ + +MODULE_DESC_BEGIN(libmod_example) + MODULE_NAME("Example Module") + MODULE_DESCRIPTION("A dummy module that serves as a starting point for writing other modules.") + MODULE_AUTHOR("Robert B. Quattlebaum") + MODULE_VERSION("1.0") + MODULE_COPYRIGHT(SYNFIG_COPYRIGHT) +MODULE_DESC_END + +MODULE_INVENTORY_BEGIN(libmod_example) + BEGIN_LAYERS + LAYER(SimpleCircle) + LAYER(FilledRect) + LAYER(Metaballs) + END_LAYERS +MODULE_INVENTORY_END diff --git a/synfig-core/src/modules/mod_example/metaballs.cpp b/synfig-core/src/modules/mod_example/metaballs.cpp new file mode 100644 index 0000000..0cfa6c3 --- /dev/null +++ b/synfig-core/src/modules/mod_example/metaballs.cpp @@ -0,0 +1,252 @@ +/* === S Y N F I G ========================================================= */ +/*! \file metaballs.cpp +** \brief Implementation of the "Metaballs" layer +** +** $Id$ +** +** \legal +** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley +** +** 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. +** \endlegal +*/ +/* ========================================================================= */ + +/* === H E A D E R S ======================================================= */ + +#ifdef USING_PCH +# include "pch.h" +#else +#ifdef HAVE_CONFIG_H +# include +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "metaballs.h" + +#endif + +/* === U S I N G =========================================================== */ + +using namespace etl; +using namespace std; +using namespace synfig; + +/* === G L O B A L S ======================================================= */ + +SYNFIG_LAYER_INIT(Metaballs); +SYNFIG_LAYER_SET_NAME(Metaballs,"metaballs"); +SYNFIG_LAYER_SET_LOCAL_NAME(Metaballs,N_("Metaballs")); +SYNFIG_LAYER_SET_CATEGORY(Metaballs,N_("Example")); +SYNFIG_LAYER_SET_VERSION(Metaballs,"0.1"); +SYNFIG_LAYER_SET_CVS_ID(Metaballs,"$Id$"); + +/* === P R O C E D U R E S ================================================= */ + +/* === M E T H O D S ======================================================= */ + +/* === E N T R Y P O I N T ================================================= */ + +Metaballs::Metaballs(): + Layer_Composite(1.0,Color::BLEND_STRAIGHT), + gradient(Color::black(), Color::white()), + threshold(0), + threshold2(1), + positive(false) +{ + centers.push_back(Point( 0, -1.5)); radii.push_back(2.5); weights.push_back(1); + centers.push_back(Point(-2, 1)); radii.push_back(2.5); weights.push_back(1); + centers.push_back(Point( 2, 1)); radii.push_back(2.5); weights.push_back(1); +} + +bool +Metaballs::set_param(const String & param, const ValueBase &value) +{ + if( param=="centers" && value.same_type_as(centers)) + { + centers = value; + return true; + } + + if( param=="weights" && value.same_type_as(weights)) + { + weights = value; + return true; + } + + if( param=="radii" && value.same_type_as(radii)) + { + radii = value; + return true; + } + + IMPORT(gradient); + IMPORT(threshold); + IMPORT(threshold2); + IMPORT(positive); + + return Layer_Composite::set_param(param,value); +} + +ValueBase +Metaballs::get_param(const String ¶m)const +{ + EXPORT(gradient); + + EXPORT(radii); + EXPORT(weights); + EXPORT(centers); + EXPORT(threshold); + EXPORT(threshold2); + EXPORT(positive); + + EXPORT_NAME(); + EXPORT_VERSION(); + + return Layer_Composite::get_param(param); +} + +Layer::Vocab +Metaballs::get_param_vocab()const +{ + Layer::Vocab ret(Layer_Composite::get_param_vocab()); + + ret.push_back(ParamDesc("gradient") + .set_local_name(_("Gradient")) + ); + + ret.push_back(ParamDesc("centers") + .set_local_name(_("Points")) + ); + + ret.push_back(ParamDesc("radii") + .set_local_name(_("Radii")) + ); + + ret.push_back(ParamDesc("weights") + .set_local_name(_("Weights")) + ); + + ret.push_back(ParamDesc("threshold") + .set_local_name(_("Gradient Left")) + ); + + ret.push_back(ParamDesc("threshold2") + .set_local_name(_("Gradient Right")) + ); + + ret.push_back(ParamDesc("positive") + .set_local_name(_("Positive Only")) + ); + + return ret; +} + +synfig::Layer::Handle +Metaballs::hit_check(synfig::Context context, const synfig::Point &point)const +{ + Real density(totaldensity(point)); + + if (density <= 0 || density > 1 || get_amount() == 0) + return context.hit_check(point); + + synfig::Layer::Handle tmp; + + if (get_blend_method()==Color::BLEND_BEHIND && (tmp=context.hit_check(point))) + return tmp; + + if (Color::is_onto(get_blend_method()) && !(context.hit_check(point))) + return 0; + + return const_cast(this); +} + +Real +Metaballs::densityfunc(const synfig::Point &p, const synfig::Point &c, Real R)const +{ + const Real dx = p[0] - c[0]; + const Real dy = p[1] - c[1]; + + const Real n = (1 - (dx*dx + dy*dy)/(R*R)); + if (positive && n < 0) return 0; + return (n*n*n); + + /* + f(d) = (1 - d^2)^3 + f'(d) = -6d * (1 - d^2)^2 + + could use this too... + f(d) = (1 - d^2)^2 + f'(d) = -6d * (1 - d^2) + */ +} + +Real +Metaballs::totaldensity(const Point &pos)const +{ + Real density = 0; + + //sum up weighted functions + for(unsigned int i=0;ierror(strprintf(__FILE__"%d: Accelerated Renderer Failure",__LINE__)); + return false; + } + + for(int y = 0; y < h; y++, pos[1] += ph) + { + pos[0] = tl[0]; + for(int x = 0; x < w; x++, pos[0] += pw) + (*surface)[y][x] = Color::blend(gradient(totaldensity(pos)),(*surface)[y][x],get_amount(),get_blend_method()); + } + + // Mark our progress as finished + if(cb && !cb->amount_complete(10000,10000)) + return false; + + return true; +} diff --git a/synfig-core/src/modules/mod_example/metaballs.h b/synfig-core/src/modules/mod_example/metaballs.h new file mode 100644 index 0000000..d9ae649 --- /dev/null +++ b/synfig-core/src/modules/mod_example/metaballs.h @@ -0,0 +1,81 @@ +/* === S Y N F I G ========================================================= */ +/*! \file metaballs.h +** \brief Header file for implementation of the "Metaballs" layer +** +** $Id$ +** +** \legal +** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley +** +** 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. +** \endlegal +*/ +/* ========================================================================= */ + +/* === S T A R T =========================================================== */ + +#ifndef __SYNFIG_METABALLS_H +#define __SYNFIG_METABALLS_H + +/* === H E A D E R S ======================================================= */ + +#include +#include +#include +#include +#include + +/* === M A C R O S ========================================================= */ + +/* === T Y P E D E F S ===================================================== */ + +/* === C L A S S E S & S T R U C T S ======================================= */ +class Metaballs : public synfig::Layer_Composite +{ + SYNFIG_LAYER_MODULE_EXT + +private: + + synfig::Gradient gradient; + + std::vector centers; + std::vector radii; + std::vector weights; + + synfig::Real threshold; + synfig::Real threshold2; + + bool positive; + + synfig::Real densityfunc(const synfig::Point &p, const synfig::Point &c, synfig::Real R)const; + + synfig::Real totaldensity(const synfig::Point &pos)const; + +public: + + Metaballs(); + + virtual bool set_param(const synfig::String & param, const synfig::ValueBase &value); + + virtual synfig::ValueBase get_param(const synfig::String & param)const; + + virtual synfig::Color get_color(synfig::Context context, const synfig::Point &pos)const; + + virtual bool accelerated_render(synfig::Context context,synfig::Surface *surface,int quality, const synfig::RendDesc &renddesc, synfig::ProgressCallback *cb)const; + + virtual Vocab get_param_vocab()const; + + virtual synfig::Layer::Handle hit_check(synfig::Context context, const synfig::Point &point)const; +}; // END of class Metaballs + +/* === E N D =============================================================== */ + +#endif diff --git a/synfig-core/src/modules/mod_example/mod_example.nsh b/synfig-core/src/modules/mod_example/mod_example.nsh new file mode 100644 index 0000000..c79179c --- /dev/null +++ b/synfig-core/src/modules/mod_example/mod_example.nsh @@ -0,0 +1,21 @@ +; The stuff to install +Section "mod_example" Sec_mod_example + +; SectionIn RO + + ; Set output path to the installation directory. + SetOutPath "$INSTDIR\lib\synfig\modules" + + ; Put file there + File /oname=mod_example.dll "src\modules\mod_example\.libs\libmod_example.dll" + + + FileOpen $0 $INSTDIR\etc\synfig_modules.cfg a + FileSeek $0 0 END + FileWrite $0 "mod_example" + FileWriteByte $0 "13" + FileWriteByte $0 "10" + FileClose $0 + +SectionEnd + diff --git a/synfig-core/src/modules/mod_example/simplecircle.cpp b/synfig-core/src/modules/mod_example/simplecircle.cpp new file mode 100644 index 0000000..e2eb896 --- /dev/null +++ b/synfig-core/src/modules/mod_example/simplecircle.cpp @@ -0,0 +1,187 @@ +/* === S Y N F I G ========================================================= */ +/*! \file simplecircle.cpp +** \brief Implementation of the "Simple Circle" layer +** +** $Id$ +** +** \legal +** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley +** Copyright (c) 2008 Chris Moore +** +** 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. +** \endlegal +*/ +/* ========================================================================= */ + +/* === H E A D E R S ======================================================= */ + +#ifdef USING_PCH +# include "pch.h" +#else +#ifdef HAVE_CONFIG_H +# include +#endif + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "simplecircle.h" + +#endif + +/* === U S I N G =========================================================== */ + +using namespace etl; +using namespace std; +using namespace synfig; + +/* === G L O B A L S ======================================================= */ + +SYNFIG_LAYER_INIT(SimpleCircle); +SYNFIG_LAYER_SET_NAME(SimpleCircle,"simple_circle"); +SYNFIG_LAYER_SET_LOCAL_NAME(SimpleCircle,N_("Simple Circle")); +SYNFIG_LAYER_SET_CATEGORY(SimpleCircle,N_("Example")); +SYNFIG_LAYER_SET_VERSION(SimpleCircle,"0.1"); +SYNFIG_LAYER_SET_CVS_ID(SimpleCircle,"$Id$"); + +/* === P R O C E D U R E S ================================================= */ + +/* === M E T H O D S ======================================================= */ + +/* === E N T R Y P O I N T ================================================= */ + +SimpleCircle::SimpleCircle(): + Layer_Composite(1.0,Color::BLEND_STRAIGHT), + color(Color::black()), + center(0,0), + radius(0.5) +{ +} + +bool +SimpleCircle::set_param(const String & param, const ValueBase &value) +{ + IMPORT(color); + IMPORT(center); + IMPORT(radius); + + return Layer_Composite::set_param(param,value); +} + +ValueBase +SimpleCircle::get_param(const String ¶m)const +{ + EXPORT(color); + EXPORT(center); + EXPORT(radius); + + EXPORT_NAME(); + EXPORT_VERSION(); + + return Layer_Composite::get_param(param); +} + +Layer::Vocab +SimpleCircle::get_param_vocab()const +{ + Layer::Vocab ret(Layer_Composite::get_param_vocab()); + + ret.push_back(ParamDesc("color") + .set_local_name(_("Color")) + ); + + ret.push_back(ParamDesc("center") + .set_local_name(_("Center")) + ); + + ret.push_back(ParamDesc("radius") + .set_local_name(_("Radius")) + .set_description(_("This is the radius of the circle")) + .set_origin("center") + ); + + return ret; +} + +Color +SimpleCircle::get_color(Context context, const Point &pos)const +{ + + if((pos-center).mag()(this); + else + return context.hit_check(pos); +} + +/* +bool +SimpleCircle::accelerated_render(Context context,Surface *surface,int quality, const RendDesc &renddesc, ProgressCallback *cb)const +{ + if(get_amount()==1.0 && get_blend_method()==Color::BLEND_STRAIGHT) + { + // Mark our progress as starting + if(cb && !cb->amount_complete(0,1000)) + return false; + + surface->set_wh(renddesc.get_w(),renddesc.get_h()); + surface->fill(color); + + // Mark our progress as finished + if(cb && !cb->amount_complete(1000,1000)) + return false; + + return true; + } + + SuperCallback supercb(cb,0,9500,10000); + + if(!context.accelerated_render(surface,quality,renddesc,&supercb)) + return false; + + int x,y; + + Surface::alpha_pen apen(surface->begin()); + + apen.set_value(color); + apen.set_alpha(get_amount()); + apen.set_blend_method(get_blend_method()); + + for(y=0;yamount_complete(10000,10000)) + return false; + + return true; +} +*/ diff --git a/synfig-core/src/modules/mod_example/simplecircle.h b/synfig-core/src/modules/mod_example/simplecircle.h new file mode 100644 index 0000000..48c555c --- /dev/null +++ b/synfig-core/src/modules/mod_example/simplecircle.h @@ -0,0 +1,73 @@ +/* === S Y N F I G ========================================================= */ +/*! \file simplecircle.h +** \brief Header file for implementation of the "Simple Circle" layer +** +** $Id$ +** +** \legal +** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley +** +** 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. +** \endlegal +*/ +/* ========================================================================= */ + +/* === S T A R T =========================================================== */ + +#ifndef __SYNFIG_SIMPLECIRCLE_H +#define __SYNFIG_SIMPLECIRCLE_H + +/* === H E A D E R S ======================================================= */ + +#include +#include +#include +#include +#include + +/* === M A C R O S ========================================================= */ + +/* === T Y P E D E F S ===================================================== */ + +/* === C L A S S E S & S T R U C T S ======================================= */ + +class SimpleCircle : public synfig::Layer_Composite +{ + SYNFIG_LAYER_MODULE_EXT + +private: + + synfig::Color color; + + synfig::Point center; + + synfig::Real radius; + +public: + + SimpleCircle(); + + virtual bool set_param(const synfig::String & param, const synfig::ValueBase &value); + + virtual synfig::ValueBase get_param(const synfig::String & param)const; + + virtual synfig::Color get_color(synfig::Context context, const synfig::Point &pos)const; + + //virtual bool accelerated_render(synfig::Context context,synfig::Surface *surface,int quality, const synfig::RendDesc &renddesc, synfig::ProgressCallback *cb)const; + + synfig::Layer::Handle hit_check(synfig::Context context, const synfig::Point &point)const; + + virtual Vocab get_param_vocab()const; +}; // END of class SimpleCircle + +/* === E N D =============================================================== */ + +#endif diff --git a/synfig-core/src/modules/mod_example/unmod_example.nsh b/synfig-core/src/modules/mod_example/unmod_example.nsh new file mode 100644 index 0000000..ba88283 --- /dev/null +++ b/synfig-core/src/modules/mod_example/unmod_example.nsh @@ -0,0 +1,8 @@ +Section "un.mod_example" + Delete "$INSTDIR\lib\synfig\modules\mod_example.dll" + RMDir "$INSTDIR\lib\synfig\modules" + RMDir "$INSTDIR\lib\synfig" + RMDir "$INSTDIR\lib" + RMDir "$INSTDIR" +SectionEnd + diff --git a/synfig-core/src/modules/synfig_modules.cfg.in b/synfig-core/src/modules/synfig_modules.cfg.in index 899e295..529460e 100644 --- a/synfig-core/src/modules/synfig_modules.cfg.in +++ b/synfig-core/src/modules/synfig_modules.cfg.in @@ -1,4 +1,4 @@ -example +mod_example mod_gif mod_imagemagick mod_magickpp diff --git a/synfig-core/src/tool/main.cpp b/synfig-core/src/tool/main.cpp index c587496..1bd614e 100644 --- a/synfig-core/src/tool/main.cpp +++ b/synfig-core/src/tool/main.cpp @@ -7,6 +7,7 @@ ** \legal ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley ** Copyright (c) 2007, 2008 Chris Moore +** Copyright (c) 2009-2010 Diego Barrios ** ** This package is free software; you can redistribute it and/or ** modify it under the terms of the GNU General Public License as diff --git a/synfig-core/src/tool/renderprogress.h b/synfig-core/src/tool/renderprogress.h index 34aee80..fa67ebe 100644 --- a/synfig-core/src/tool/renderprogress.h +++ b/synfig-core/src/tool/renderprogress.h @@ -120,15 +120,20 @@ public: } if(weeks) - cerr< > module_list_; bool studio::App::use_colorspace_gamma=true; #ifdef SINGLE_THREADED -bool studio::App::single_threaded=false; -#endif + #ifdef WIN32 + bool studio::App::single_threaded=true; + #else + bool studio::App::single_threaded=false; + #endif // WIN32 +#endif // SINGLE THREADED bool studio::App::restrict_radius_ducks=false; bool studio::App::resize_imported_images=false; String studio::App::custom_filename_prefix(DEFAULT_FILENAME_PREFIX); diff --git a/synfig-studio/src/gui/trees/keyframetreestore.cpp b/synfig-studio/src/gui/trees/keyframetreestore.cpp index d1925b4..dd6a50d 100644 --- a/synfig-studio/src/gui/trees/keyframetreestore.cpp +++ b/synfig-studio/src/gui/trees/keyframetreestore.cpp @@ -798,7 +798,7 @@ KeyframeTreeStore::find_row(const synfig::Keyframe &keyframe) synfig::KeyframeList &keyframe_list(canvas_interface()->get_canvas()->keyframe_list()); if(keyframe_list.empty()) - throw std::runtime_error(_("There are no keyframes n this canvas")); + throw std::runtime_error(_("There are no keyframes in this canvas")); iter->index=0; diff --git a/synfig-studio/src/gui/trees/layertree.cpp b/synfig-studio/src/gui/trees/layertree.cpp index ee976da..690d4aa 100644 --- a/synfig-studio/src/gui/trees/layertree.cpp +++ b/synfig-studio/src/gui/trees/layertree.cpp @@ -186,16 +186,11 @@ LayerTree::create_layer_tree() const LayerTreeStore::Model model; { // --- O N / O F F ---------------------------------------------------- - //int index; - //index=get_layer_tree_view().append_column_editable(_(" "),layer_model.active); - //Gtk::TreeView::Column* column = get_layer_tree_view().get_column(index-1); - Gtk::TreeView::Column* column = Gtk::manage( new Gtk::TreeView::Column(_(" ")) ); - // Set up the icon cell-renderer + // Set up the on/off cell-renderer Gtk::CellRendererToggle* cellrenderer = Gtk::manage( new Gtk::CellRendererToggle() ); cellrenderer->signal_toggled().connect(sigc::mem_fun(*this, &studio::LayerTree::on_layer_toggle)); - column->pack_start(*cellrenderer,false); column->add_attribute(cellrenderer->property_active(), layer_model.active); get_layer_tree_view().append_column(*column); @@ -203,24 +198,15 @@ LayerTree::create_layer_tree() { // --- I C O N -------------------------------------------------------- int index; - index=get_layer_tree_view().append_column(_("Z"),layer_model.icon); + // Set up the icon cell-renderer + index=get_layer_tree_view().append_column(_("Icon"),layer_model.icon); Gtk::TreeView::Column* column = get_layer_tree_view().get_column(index-1); get_layer_tree_view().set_expander_column(*column); - - column->set_sort_column(layer_model.z_depth); - //column->set_reorderable(); - //column->set_resizable(); - //column->set_clickable(); - - //Gtk::CellRendererPixbuf* icon_cellrenderer = Gtk::manage( new Gtk::CellRendererPixbuf() ); - //column->pack_start(*icon_cellrenderer,false); - //column->add_attribute(icon_cellrenderer->property_pixbuf(), layer_model.icon); } - //get_layer_tree_view().append_column(_("Z"),layer_model.z_depth); { // --- N A M E -------------------------------------------------------- Gtk::TreeView::Column* column = Gtk::manage( new Gtk::TreeView::Column(_("Name")) ); - // Set up the icon cell-renderer + // Set up the Layer label cell-renderer Gtk::CellRendererText* cellrenderer = Gtk::manage( new Gtk::CellRendererText() ); column->pack_start(*cellrenderer,false); column->add_attribute(cellrenderer->property_text(), layer_model.label); @@ -228,27 +214,18 @@ LayerTree::create_layer_tree() cellrenderer->property_editable()=true; column->set_reorderable(); - // column->set_resizable(); + column->set_resizable(); column->set_clickable(true); column->set_sort_column(layer_model.label); get_layer_tree_view().append_column(*column); - - // int index; -// index=get_layer_tree_view().append_column_editable(_("Layer"),layer_model.label); - //Gtk::TreeView::Column* column = get_layer_tree_view().get_column(index-1); - - //get_layer_tree_view().set_expander_column(*column); - - //Gtk::CellRendererPixbuf* icon_cellrenderer = Gtk::manage( new Gtk::CellRendererPixbuf() ); - //column->pack_start(*icon_cellrenderer,false); - //column->add_attribute(icon_cellrenderer->property_pixbuf(), layer_model.icon); } { // --- Z D E P T H ---------------------------------------------------- int index; - index=get_layer_tree_view().append_column(_("Z"),layer_model.z_depth); - column_z_depth=get_layer_tree_view().get_column(index-1); + index=get_layer_tree_view().append_column(_("Z Depth"),layer_model.z_depth); + // Set up the Z-Depth label cell-renderer + column_z_depth=get_layer_tree_view().get_column(index-1); column_z_depth->set_reorderable(); column_z_depth->set_resizable(); column_z_depth->set_clickable();