Advertisement
Philip_Lammes

Arc Angle Oscillation Problem

Jul 13th, 2017
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.11 KB | None | 0 0
  1. float colUpdate = 0.0;
  2. float len = PI;
  3.  
  4. float freq = .1;
  5.  
  6. //Color Variables
  7. double colR = 0.0;
  8. double colG = 0.0;
  9. double colB = 0.0;
  10.  
  11. //Color Oscillation Variables
  12. int colorStart = 128;
  13. int colorSpan = 127;
  14.  
  15. //Arc Position Variables
  16. double xPos = 0.0;
  17. double yPos = 0.0;
  18.  
  19. //Arc Position Oscillation Variables
  20. int widthStart = 0;
  21. int widthSpan = 0;
  22. int heightStart = 0;
  23. int heightSpan = 0;
  24.  
  25. //Arc Rotation Variables
  26. double arcAngle1 = 0.0;
  27. double arcAngle2 = 0.0;
  28.  
  29. //Arc Rotation Oscillation variables
  30. float arcAngle1Start = 0.0;
  31. float arcAngle1Span = 0.0;
  32. float arcAngle2Start = 0.0;
  33. float arcAngle2Span = 0.0;
  34.  
  35. void setup(){
  36. size(1000, 500);
  37. frameRate(10);
  38. background(255,255,255);
  39. }
  40.  
  41. void draw(){
  42. //Misc
  43. len += 1;
  44. noFill();
  45.  
  46. //Setting Values for Arc Position Oscillation
  47. widthStart = width/2;
  48. widthSpan = width/3;
  49. heightStart = height/2;
  50. heightSpan = height/3;
  51.  
  52. //Setting Values for Arc Rotation Oscillation
  53. arcAngle1Start = -HALF_PI;
  54. arcAngle1Span = HALF_PI;
  55. arcAngle2Start = HALF_PI;
  56. arcAngle2Span= HALF_PI;
  57.  
  58. //Sine Oscillation for Color and Arc Position
  59. for (int i = 0; i < len; ++i)
  60. {
  61. colR = Math.sin(freq*i + 0) * colorSpan + colorStart;
  62. colG = Math.sin(freq*i + 2) * colorSpan + colorStart;
  63. colB = Math.sin(freq*i + 4) * colorSpan + colorStart;
  64.  
  65. xPos = Math.sin(freq*i) * widthSpan + widthStart;
  66. yPos = Math.sin((2*freq)*i) * heightSpan + heightStart;
  67.  
  68. arcAngle1 = Math.sin(freq*i) * arcAngle1Span + arcAngle1Start;
  69. arcAngle2 = Math.sin(freq*i) * arcAngle2Span + arcAngle2Start;
  70. }
  71.  
  72.  
  73. //Choosing Color of Arc Using the Color Doubles Converted to Floats
  74. stroke(Float.parseFloat(new Double(colR).toString()),Float.parseFloat(new Double(colG).toString()),Float.parseFloat(new Double(colB).toString()));
  75.  
  76. //Drawing the Arc Using the Same Float Conversion Method
  77. arc(Float.parseFloat(new Double(xPos).toString()), Float.parseFloat(new Double(yPos).toString()), 50, 100, Float.parseFloat(new Double(arcAngle1).toString()), Float.parseFloat(new Double(arcAngle2).toString()));
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement