X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-core%2Ftrunk%2Fsrc%2Fmodules%2Fmod_filter%2Fhalftone.cpp;h=8e8ba9e7b3a5309b8887f1710332e1564a8da754;hb=9459638ad6797b8139f1e9f0715c96076dbf0890;hp=7cac70f03150d95de88552a77c53c9f614229a8e;hpb=28f28705612902c15cd0702cc891fba35bf2d2df;p=synfig.git diff --git a/synfig-core/trunk/src/modules/mod_filter/halftone.cpp b/synfig-core/trunk/src/modules/mod_filter/halftone.cpp index 7cac70f..8e8ba9e 100644 --- a/synfig-core/trunk/src/modules/mod_filter/halftone.cpp +++ b/synfig-core/trunk/src/modules/mod_filter/halftone.cpp @@ -2,19 +2,21 @@ /*! \file halftone.cpp ** \brief blehh ** -** $Id: halftone.cpp,v 1.1.1.1 2005/01/04 01:23:10 darco Exp $ +** $Id$ ** ** \legal -** Copyright (c) 2002 Robert B. Quattlebaum Jr. +** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley +** Copyright (c) 2008 Chris Moore ** -** This software and associated documentation -** are CONFIDENTIAL and PROPRIETARY property of -** the above-mentioned copyright holder. +** 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. ** -** You may not copy, print, publish, or in any -** other way distribute this software without -** a prior written agreement with -** the copyright holder. +** 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 */ /* ========================================================================= */ @@ -51,14 +53,14 @@ float Halftone::operator()(const Point &point, const float& luma, float supersample)const { float halftone(mask(point)); - + if(supersample>=0.5f) supersample=0.4999999999f; - + halftone=(halftone-0.5f)*(1.0f-supersample*2.0f)+0.5f; - + const float diff(halftone-luma); - + if(supersample) { const float amount(diff/(supersample*2.0f)+0.5f); @@ -86,13 +88,13 @@ Halftone::mask(synfig::Point point)const { float radius1; float radius2; - - point-=offset; + + point-=origin; { const float a(Angle::sin(-angle).get()), b(Angle::cos(-angle).get()); const float u(point[0]),v(point[1]); - + point[0]=b*u-a*v; point[1]=a*u+b*v; } @@ -108,7 +110,7 @@ Halftone::mask(synfig::Point point)const x*=2; return x; } - + { Point pnt(fmod(point[0],size[0]),fmod(point[1],size[1])); while(pnt[0]<0)pnt[0]+=abs(size[0]); @@ -117,13 +119,13 @@ Halftone::mask(synfig::Point point)const pnt*=2.0; pnt[0]/=size[0]; pnt[1]/=size[1]; - + radius1=pnt.mag()/SQRT2; radius1*=radius1; } if(type==TYPE_DARKONLIGHT || type== TYPE_LIGHTONDARK) return radius1; - + { Point pnt(fmod(point[0]+size[0]*0.5,size[0]),fmod(point[1]+size[0]*0.5,size[1])); while(pnt[0]<0)pnt[0]+=abs(size[0]); @@ -132,11 +134,11 @@ Halftone::mask(synfig::Point point)const pnt*=2.0; pnt[0]/=size[0]; pnt[1]/=size[1]; - + radius2=pnt.mag()/SQRT2; radius2*=radius2; } - + if(type==TYPE_DIAMOND) { //return (radius1+(1.0f-radius2))*0.5; @@ -145,19 +147,19 @@ Halftone::mask(synfig::Point point)const x-=0.5; x*=2.0; if(x<0)x=-sqrt(-x);else x=sqrt(x); - x*=1.01f; + x*=1.01f; x/=2.0; x+=0.5; return x; } - + if(type==TYPE_SYMMETRIC) { float x(((radius2-radius1)*((radius1+(1.0f-radius2))*0.5)+radius1)*2.0f); x-=0.5; x*=2.0; if(x<0)x=-sqrt(-x);else x=sqrt(x); - x*=1.01f; + x*=1.01f; x/=2.0; x+=0.5; return x;