/** *

Demonstration of the Sutherland-Hodgeman 2D polygon clipping algorithm * introduced with toxiclibscore-0019. The screen is divided into a grid * of small rectangles which are used to define virtual viewports and act * as clipping shapes for moving particles (rendered as polygons).

* *

Usage:
* Press any key to turn clipping on/off

*/ /* * Copyright (c) 2010 Karsten Schmidt * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * http://creativecommons.org/licenses/LGPL/2.1/ * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ import toxi.geom.*; import toxi.math.waves.*; import toxi.processing.*; int COLS = 8; int ROWS = 6; List cells = new ArrayList(); ToxiclibsSupport gfx; boolean isClipped=true; void setup() { size(680,382); gfx=new ToxiclibsSupport(this); strokeWeight(2); Vec2D cellSize = new Vec2D((float)width/COLS,(float)height/ROWS); for(float y=0; y