vector2.vala 516 B

1234567891011121314151617181920212223242526272829303132
  1. /*
  2. * Copyright (c) 2012-2016 Daniele Bartolini and individual contributors.
  3. * License: https://github.com/taylor001/crown/blob/master/LICENSE-GPLv2
  4. */
  5. using Gee;
  6. namespace Crown
  7. {
  8. public struct Vector2
  9. {
  10. public double x;
  11. public double y;
  12. public Vector2(double x, double y)
  13. {
  14. this.x = x;
  15. this.y = y;
  16. }
  17. public Vector2.from_array(ArrayList<Value?> arr)
  18. {
  19. this.x = (double)arr[0];
  20. this.y = (double)arr[1];
  21. }
  22. public string to_string()
  23. {
  24. return "%f, %f".printf(x, y);
  25. }
  26. }
  27. }