/cc.creativecomputing/demo/cc/creativecomputing/demo/graphics/texture/video/CCQuicktimeCaptureDataTest.java

http://creativecomputing.googlecode.com/ · Java · 71 lines · 39 code · 12 blank · 20 comment · 3 complexity · 463fead59a12776afdcf2b260efd1bdb MD5 · raw file

  1. /*
  2. * Copyright (c) 2009 Christian Riekoff <info@texone.org>
  3. *
  4. * This file is free software: you may copy, redistribute and/or modify it
  5. * under the terms of the GNU General Public License as published by the
  6. * Free Software Foundation, either version 2 of the License, or (at your
  7. * option) any later version.
  8. *
  9. * This file is distributed in the hope that it will be useful, but
  10. * WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. *
  17. * This file incorporates work covered by the following copyright and
  18. * permission notice:
  19. */
  20. package cc.creativecomputing.demo.graphics.texture.video;
  21. import cc.creativecomputing.CCApp;
  22. import cc.creativecomputing.CCApplicationManager;
  23. import cc.creativecomputing.CCApplicationSettings;
  24. import cc.creativecomputing.graphics.CCColor;
  25. import cc.creativecomputing.graphics.texture.video.CCQuicktimeCaptureData;
  26. public class CCQuicktimeCaptureDataTest extends CCApp {
  27. private CCQuicktimeCaptureData _myData;
  28. @Override
  29. public void setup() {
  30. for(String myDevice : CCQuicktimeCaptureData.listCaptureDevices()) {
  31. System.out.println(myDevice);
  32. }
  33. _myData = new CCQuicktimeCaptureData(this, 640, 480, 30);
  34. }
  35. @Override
  36. public void update(final float theDeltaTime) {}
  37. @Override
  38. public void draw() {
  39. g.clearColor(1f);
  40. g.clear();
  41. // g.blend(CCBlendMode.ADD);
  42. g.translate(-width/2, -height/2);
  43. for(int x = 0; x < _myData.width() - 1;x+=9){
  44. for(int y = 0; y < _myData.height() - 1; y+=9){
  45. CCColor myPixel = _myData.getPixel(x,y);
  46. g.color(myPixel);
  47. float myRadius = (1 - myPixel.brightness()) * 10;
  48. g.ellipse(x, y, myRadius, myRadius);
  49. }
  50. }
  51. System.out.println(frameRate);
  52. }
  53. public static void main(String[] args) {
  54. CCApplicationManager<CCQuicktimeCaptureDataTest> myManager = new CCApplicationManager<CCQuicktimeCaptureDataTest>(CCQuicktimeCaptureDataTest.class);
  55. myManager.settings().size(640, 480);
  56. myManager.settings().antialiasing(8);
  57. myManager.start();
  58. }
  59. }