選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

TrueColor.java 1.1 KiB

1234567891011121314151617181920212223242526272829303132333435363738
  1. /**
  2. * libcaca Java bindings for libcaca
  3. * Copyright (c) 2009 Adrien Grand <jpountz@dinauz.org>
  4. *
  5. * $Id$
  6. *
  7. * This library is free software. It comes without any warranty, to
  8. * the extent permitted by applicable law. You can redistribute it
  9. * and/or modify it under the terms of the Do What The Fuck You Want
  10. * To Public License, Version 2, as published by Sam Hocevar. See
  11. * http://sam.zoy.org/wtfpl/COPYING for more details.
  12. */
  13. import org.zoy.caca.Canvas;
  14. import org.zoy.caca.Color;
  15. import org.zoy.caca.Display;
  16. import org.zoy.caca.Event;
  17. public class TrueColor {
  18. public static void main(String[] args) {
  19. Canvas cv = new Canvas(32, 16);
  20. Display dp = new Display(cv);
  21. for (int y = 0; y < 16; y++) {
  22. for (int x = 0; x < 16; x++) {
  23. int bgcolor = 0xff00 | (y << 4) | x;
  24. int fgcolor = 0xf000 | ((15 - y) << 4) | ((15 - x) << 8);
  25. cv.setColor(new Color.Argb(bgcolor), new Color.Argb(fgcolor));
  26. cv.put(x*2, y, "CA");
  27. }
  28. }
  29. cv.setColor(Color.Ansi.WHITE, Color.Ansi.LIGHTBLUE);
  30. cv.put(2, 1, "truecolor libcaca");
  31. dp.refresh();
  32. dp.getEvent(Event.Type.KEY_PRESS, -1);
  33. }
  34. }