Blend.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. //
  2. // System.Drawing.Drawing2D.Blend.cs
  3. //
  4. // Author:
  5. // Dennis Hayes ([email protected])
  6. //
  7. // (C) 2002/3 Ximian, Inc
  8. //
  9. using System;
  10. namespace System.Drawing.Drawing2D
  11. {
  12. /// <summary>
  13. /// Summary description for Blend.
  14. /// </summary>
  15. public sealed class Blend
  16. {
  17. private int count;
  18. private float [] positions;
  19. private float [] factors;
  20. public Blend(int count) {
  21. this.count = count;
  22. if(count < 2){
  23. throw new ArgumentOutOfRangeException("Count", count, "Must be at least 2");
  24. }
  25. positions = new float [count];
  26. factors = new float [count];
  27. //FIXME: call Blend!
  28. for (int i = 0; i < count; i++){
  29. positions[i] = (1.0F/count) * i;
  30. factors[i] = (1.0F/count) * i;
  31. }
  32. //fix any rounding errors that would generate an invald list.
  33. positions[0] = 0.0F;
  34. positions[1] = 1.0F;
  35. factors[0] = 0.0F;
  36. factors[1] = 1.0F;
  37. }
  38. public Blend() {
  39. count = 2;
  40. positions = new float [2];
  41. factors = new float [2];
  42. positions[0] = 0.0F;
  43. positions[1] = 1.0F;
  44. factors[0] = 0.0F;
  45. factors[1] = 1.0F;
  46. }
  47. public float [] Factors{
  48. get {
  49. return factors;
  50. }
  51. set{
  52. count = value.GetUpperBound(0) + 1;
  53. if((value[0] !=0) | (value[count-1] != 1.0F)){
  54. throw new ArgumentException(" First value must be 0.0, last value must be 1.0","Factors");
  55. }
  56. factors = value;
  57. }
  58. }
  59. public float [] Positions{
  60. get {
  61. return positions;
  62. }
  63. set{
  64. count = value.GetUpperBound(0) + 1;
  65. if((value[0] !=0) | (value[count-1] != 1.0F)){
  66. throw new ArgumentException(" First value must be 0.0, last value must be 1.0","Positon");
  67. }
  68. positions = value;
  69. }
  70. }
  71. }
  72. }