Navigation

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Users
    • Groups
    • Solved
    • Unsolved
    • Search
    1. Home
    2. FutureDays
    3. Posts
    • Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Best
    • Groups

    Posts made by FutureDays

    • RE: Entering Font Properties into Existing Python Code

      Hello,

      Once again, thank you for being so helpful.

      Enjoy the day.

      Best.

      Robert

      posted in General Discussion
      FutureDays
      FutureDays
    • Entering Font Properties into Existing Python Code

      Hello All,

      A quick question, if I want to change my existing star properties to font properties, what might be the approach?

      I have attached my code for comment.

      def star(x, y, n, r1, r2):
          pts = []
          for i in range(n * 2):
              a = i * pi / n
              r = r2 if i % 2 else r1
              pts.append((x + r * sin(a), y + r * cos(a)))
          polygon(*pts)
      
      CANVAS = 500
      SQUARESIZE = 158
      NSQUARES = 50
      SQUAREDIST = 6
      
      width = NSQUARES * SQUAREDIST
      
      NFRAMES = 50
      
      for frame in range(NFRAMES):
          newPage(CANVAS, CANVAS)
          frameDuration(1/20)
          
          fill(0)
          rect(0, 0, CANVAS, CANVAS)
      
          phase = 2 * pi * frame / NFRAMES  
          startAngle = 90 * sin(phase)
          endAngle = 90 * sin(phase + 0.5 * pi)
      
          translate(CANVAS/2 - width / 2, CANVAS/2)
      
          fill(1)
          stroke(0)
      
          for i in range(NSQUARES + 1):
              f = i / NSQUARES
              save()
              translate(i * SQUAREDIST, 0)
              scale(0.7, 1)
              rotate(startAngle + f * (endAngle - startAngle))
      
              star(0, 0, 5, SQUARESIZE, SQUARESIZE * 0.5)
      
              restore()
      
      saveImage("StackOfStars.gif")
      

      Thank you.

      Robert

      posted in General Discussion
      FutureDays
      FutureDays
    • RE: Changing Squares to Five Point Stars with JVR Code

      @gferreira

      Hello gferreira,

      Thank you so much the reply has been very helpful. I can see that I was thinking too much about modifying all areas of the code instead of changing a small component.

      Enjoy the day.

      Best.

      Robert

      posted in General Discussion
      FutureDays
      FutureDays
    • RE: Changing Squares to Five Point Stars with JVR Code

      @FutureDays

      Hi All,

      I am now totally stuck:

      CANVAS = 1440
      
      NFRAMES = 1
      
      for frame in range(NFRAMES):
          newPage(CANVAS, CANVAS)
          frameDuration(1/20)
          
      fill(0)
      rect(0, 0, CANVAS, CANVAS)
      
      phase = 2 * pi * frame / NFRAMES 
      startAngle = 90 * sin(phase)
      endAngle = 90 * sin(phase + 0.5 * pi)
      
      
      translate(CANVAS/2, CANVAS/2)
      
      fill(1)
      stroke(0)
      
      for i in range(20):
          save()
          translate(i * 10)
          scale(1.1)
          rotate(380)
          def star(x, y, n, r1, r2):
              pts = []
              for i in range(n * 2):
                  a = i * pi / n
                  r = r2 if i % 2 else r1
                  pts.append((x + r * sin(a), y + r * cos(a)))
              polygon(*pts)
          star(1, -95, 5, 450, 260)
          restore()
      
      saveImage("StarTest.gif")
      

      Any help would be very much appreciated

      Best,

      Robert

      posted in General Discussion
      FutureDays
      FutureDays
    • RE: Changing Squares to Five Point Stars with JVR Code

      @gferreira
      Hi. That is exactly what I was hoping to achieve. Hopefully I can make this work.

      Best.

      Robert

      posted in General Discussion
      FutureDays
      FutureDays
    • Changing Squares to Five Point Stars with JVR Code

      Hi All,

      Having a ball learning drawbot so thanks to everyone who has been involved in the development process to date. Recently I been playing around with the source code for one of Just Van Rossum's StackoSquares animations. That said, I have a question, in order to change the object from multiple squares to multiple five point stars, is the solution simply changing the square object to a star object. If so how would I write the star object code. Very new to coding so any help would be gratefully appreciated.

      Best.

      Robert

      PS: The code is below this line of type.

      CANVAS = 500
      SQUARESIZE = 158
      NSQUARES = 50
      SQUAREDIST = 6
      
      width = NSQUARES * SQUAREDIST
      
      NFRAMES = 50
      
      for frame in range(NFRAMES):
          newPage(CANVAS, CANVAS)
          frameDuration(1/20)
          
          fill(0)
          rect(0, 0, CANVAS, CANVAS)
      
          phase = 2 * pi * frame / NFRAMES  # angle in radians
          startAngle = 90 * sin(phase)
          endAngle = 90 * sin(phase + 0.5 * pi)
      
          translate(CANVAS/2 - width / 2, CANVAS/2)
      
          fill(1)
          stroke(0)
      
          for i in range(NSQUARES + 1):
              f = i / NSQUARES
              save()
              translate(i * SQUAREDIST, 0)
              scale(0.7, 1)
              rotate(startAngle + f * (endAngle - startAngle))
              rect(-SQUARESIZE/2, -SQUARESIZE/2, SQUARESIZE, SQUARESIZE)
              restore()
      
      saveImage("StackOfSquares.gif")
      
      posted in General Discussion
      FutureDays
      FutureDays