SRadialGradient.ts 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /*
  2. * *********************************************************************************************************************
  3. *
  4. * !!
  5. * .F88X
  6. * X8888Y
  7. * .}888888N;
  8. * i888888N; .:! .I$WI:
  9. * R888888I .'N88~ i8}+8Y&8"l8i$8>8W~'>W8}8]KW+8IIN"8&
  10. * .R888888I .;N8888~ .X8' "8I.!,/8" !%NY8`"8I8~~8>,88I
  11. * +888888N; .8888888Y "&&8Y.}8,
  12. * ./888888N; .R888888Y .'}~ .>}'.`+> i}! "i' +/' .'i~ !11,.:">, .~]! .i}i
  13. * ~888888%: .I888888l .]88~`1/iY88Ii+1'.R$8$8]"888888888> Y8$ W8E X8E W8888'188Il}Y88$*
  14. * 18888888 E8888881 .]W%8$`R8X'&8%++N8i,8N%N8+l8%` .}8N:.R$RE%N88N%N$K$R 188,FE$8%~Y88I
  15. * .E888888I .i8888888' .:$8I;88+`E8R:/8N,.>881.`$8E/1/]N8X.Y8N`"KF&&FK!'88*."88K./$88%RN888+~
  16. * 8888888I .,N888888~ ~88i"8W,!N8*.I88.}888%F,i$88"F88" 888:E8X.>88!i88>`888*.}Fl1]*}1YKi'
  17. * i888888N' I888Y ]88;/EX*IFKFK88X K8R .l8W 88Y ~88}'88E&%8W.X8N``]88!.$8K .:W8I
  18. * .i888888N; I8Y .&8$ .X88! i881.:%888>I88 ;88] +88+.';;;;:.Y88X 18N.,88l .+88/
  19. * .:R888888I
  20. * .&888888I Copyright (c) 2009-2020. 博锐尚格科技股份有限公司
  21. * ~8888'
  22. * .!88~ All rights reserved.
  23. *
  24. * *********************************************************************************************************************
  25. */
  26. import { SGradient, SPoint } from "./";
  27. /**
  28. * 放射性渐变
  29. *
  30. * @author 庞利祥 <sybotan@126.com>
  31. */
  32. export class SRadialGradient extends SGradient {
  33. /** 开始圆形半径 */
  34. r1: number;
  35. /** 结束圆形半径 */
  36. r2: number;
  37. /**
  38. * 构造函数
  39. *
  40. * @param start 开始圆形坐标
  41. * @param r1 开始圆形半径
  42. * @param end 结束圆形坐标
  43. * @param r2 结束圆形半径
  44. */
  45. constructor(start: SPoint, r1: number, end: SPoint, r2: number);
  46. /**
  47. * 构造函数
  48. *
  49. * @param x1 开始圆形 X 坐标
  50. * @param y1 开始圆形 Y 坐标
  51. * @param r1 开始圆形半径
  52. * @param x2 结束圆形 X 坐标
  53. * @param y2 结束圆形 Y 坐标
  54. * @param r2 结束圆形半径
  55. */
  56. constructor(
  57. x1: number,
  58. y1: number,
  59. r1: number,
  60. x2: number,
  61. y2: number,
  62. r2: number
  63. );
  64. /**
  65. * 构造函数(重载实现)
  66. *
  67. * @param x1 开始圆形 X 坐标 | 开始圆形坐标
  68. * @param y1 开始圆形 Y 坐标 | 开始圆形半径
  69. * @param r1 开始圆形半径 | 结束圆形坐标
  70. * @param x2 结束圆形 X 坐标 | 结束圆形半径
  71. * @param y2 结束圆形 Y 坐标
  72. * @param r2 结束圆形半径
  73. */
  74. constructor(
  75. x1: number | SPoint,
  76. y1: number,
  77. r1: number | SPoint,
  78. x2: number,
  79. y2?: number,
  80. r2?: number
  81. ) {
  82. super();
  83. if (x1 instanceof SPoint && r1 instanceof SPoint) {
  84. this.start = new SPoint(x1);
  85. this.end = new SPoint(r1);
  86. this.r1 = y1;
  87. this.r2 = x2;
  88. } else {
  89. this.start = new SPoint(x1 as number, y1 as number);
  90. this.end = new SPoint(x2 as number, y2 as number);
  91. this.r1 = r1 as number;
  92. this.r2 = r2 as number;
  93. }
  94. }
  95. /**
  96. * 转为字符串保存
  97. *
  98. */
  99. value(): string {
  100. let str = `SRadialGradient{`;
  101. str += `${this.x1},${this.y1},${this.r1};`;
  102. str += `${this.x2},${this.y2},${this.r2};`;
  103. this.stopList.forEach((t): void => {
  104. str += `${t.pos},${t.color.value};`;
  105. });
  106. return `${str}}`;
  107. }
  108. }