Navigation

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

    Jérémie

    @JeremieHornus

    4
    Reputation
    5
    Posts
    585
    Profile views
    1
    Followers
    0
    Following
    Joined Last Online
    Website black-foundry.com/

    JeremieHornus Follow

    Best posts made by JeremieHornus

    • Dave's Creature

      0_1532504178269_davesCreature.gif
      after this tweet:
      https://twitter.com/beesandbombs/status/1021746882362728448
      and this processing code:
      https://gist.github.com/beesandbombs/6f3e6fb723f50b080916816ae8e561e3

      I made a DrawBot/Python translation:

      import math
      n = 720
      l = 350
      twm = math.pi/20
      
      def mapValue(value, start1, stop1, start2, stop2):
          p = 1.0*(value-start1) / (stop1 - start1)
          return start2 + p*(stop2 - start2)
      
      def spiral(q, R, nt):
          path = BezierPath()
          origin = width()*.5, height()*.5
          path.moveTo(origin)
          for i in range(n):
              qq = 1.0*i/(n-1)
              r = mapValue(math.cos(2*math.pi*qq), 1, -1, 0, R)*math.sqrt(qq)
              th = nt*2*math.pi*qq - 4*2*math.pi*t - q
              x = r*math.cos(th)
              y = -l*qq + r*math.sin(th)
      
              tw = twm*math.sin(2*math.pi*t - math.pi*qq)
      
              xx = x*math.cos(tw) + y*math.sin(tw)
              yy = y*math.cos(tw) - x*math.sin(tw)
      
              path.lineTo((origin[0]+xx, origin[1]+yy))
      
          path.endPath()
          drawPath(path)
      
      N = 9
      frames = 60
      
      for f in range(frames):
          newPage(1000, 1000)
          frameDuration(1/30)
          fill(1)
          rect(0, 0, width(), height())
          t = 1.0*f/frames
          for i in range(N):
              R = 42
              m = mapValue(math.sin(2*math.pi*t), -1, 1, 0, 1)
              nt = 6+6*m
              save()
              stroke(.5)
              fill(None)
              strokeWidth(1)
              rotate(360.0*i/N, (width()*.5, height()*.5))
              spiral(2*math.pi*i/N, R, nt);
              restore()
      saveImage('davesCreature.gif')
      

      One might find mapValue an interesting function featured natively in processing:
      https://processing.org/reference/map_.html

      posted in Code snippets
      JeremieHornus
      JeremieHornus
    • RE: Possible solution to Just's puzzle?

      @justvanrossum building on @erik solution:
      0_1515856408012_Just2.gif

      import random, math, noise
      
      w = 500
      h = 500
      
      dia = 100
      rows = 5
      cols = 5
      ovals = []
      
      frames = 30
      
      for x in range(1, rows):
          for y in range(1, cols):
              ovals.append((x*(w/rows), y*h/cols, 1+.5*random.random()))
      
      for f in range(frames):
          newPage(w, h)
          frameDuration(1/20)
          fill(0)
          rect(0,0,width(),height())
          n = f/frames
          for d in range(1, dia):
              d = dia-d
              fill(.9*math.sqrt((dia-d)/dia))
              
              for i, (x, y, g) in enumerate(ovals):
                  m = noise.pnoise3(.1*x/w, .1*y/h, i+ .5*math.sin(2*math.pi*(f/frames)))
                  oval(20*m + x-.5*d*g*(1+m), 20*m +  y-.5*d*g*(1+m), d*g*(1+m), d*g*(1+m))
      
      saveImage("Just2.mp4")
      
      posted in Code snippets
      JeremieHornus
      JeremieHornus
    • WildyLoopyThing

      A simple little Perlin Noise animation thing 🙂
      0_1515422425702_wildyloopything.gif

      # Requires caseman perlin noise: clone and install > https://github.com/caseman/noise
      import noise
      import random
      import math
      
      points = []
      
      size = 500
      nthing = 60
      baseSizeRatio = .2
      ncircle = 5
      for e in range(ncircle):  
          n = (e+1)/ncircle
          for i in range(nthing):
              phase = i / nthing
              x = size*.5 - n*baseSizeRatio*size * math.sin(2*math.pi*phase)
              y = size*.9 - .5*(1-n)*size - (1-n)*baseSizeRatio*size - .1*n*baseSizeRatio*size * math.cos(2*math.pi*phase)
              c = (0, 1, .5, .8*(y/size) )
              l = 10+ 10*random.random()
              t = 1
              points.append((x, y, c, l, t))
      
      length = 10
      frames = 100
      
      for f in range(frames):
          
          newPage(size, size)
          frameDuration(1/15)
          fill(0) 
          rect(0, 0, size, size) 
          fill(None) 
          
          for p in points:
              strokeWidth(p[4])
              stroke(p[2][0], p[2][1], p[2][2], p[2][3])
              path = BezierPath()
              
              prev_x = p[0]
              prev_y = p[1]  + (p[1]/size)*50*math.sin(noise.pnoise2(.1*p[0]*.1*p[1], .1*abs(frames*.5-f)))
              path.moveTo((prev_x, prev_y))
              for l in range(length):
                  dx = int(p[3]*math.sin(noise.pnoise2(.1*p[0], (abs(frames*.5-f)+l)*.1 )))
                  dy = -int(p[3]*math.cos(noise.pnoise2(.1*p[1], (abs(frames*.5-f)+l)*.1 )))
                  path.lineTo((prev_x, prev_y))
                  prev_x += dx
                  prev_y += dy
              drawPath(path)
              
      saveImage("~/Desktop/wildyloopything.gif")
      
      posted in Code snippets
      JeremieHornus
      JeremieHornus

    Latest posts made by JeremieHornus

    • Dave's Creature

      0_1532504178269_davesCreature.gif
      after this tweet:
      https://twitter.com/beesandbombs/status/1021746882362728448
      and this processing code:
      https://gist.github.com/beesandbombs/6f3e6fb723f50b080916816ae8e561e3

      I made a DrawBot/Python translation:

      import math
      n = 720
      l = 350
      twm = math.pi/20
      
      def mapValue(value, start1, stop1, start2, stop2):
          p = 1.0*(value-start1) / (stop1 - start1)
          return start2 + p*(stop2 - start2)
      
      def spiral(q, R, nt):
          path = BezierPath()
          origin = width()*.5, height()*.5
          path.moveTo(origin)
          for i in range(n):
              qq = 1.0*i/(n-1)
              r = mapValue(math.cos(2*math.pi*qq), 1, -1, 0, R)*math.sqrt(qq)
              th = nt*2*math.pi*qq - 4*2*math.pi*t - q
              x = r*math.cos(th)
              y = -l*qq + r*math.sin(th)
      
              tw = twm*math.sin(2*math.pi*t - math.pi*qq)
      
              xx = x*math.cos(tw) + y*math.sin(tw)
              yy = y*math.cos(tw) - x*math.sin(tw)
      
              path.lineTo((origin[0]+xx, origin[1]+yy))
      
          path.endPath()
          drawPath(path)
      
      N = 9
      frames = 60
      
      for f in range(frames):
          newPage(1000, 1000)
          frameDuration(1/30)
          fill(1)
          rect(0, 0, width(), height())
          t = 1.0*f/frames
          for i in range(N):
              R = 42
              m = mapValue(math.sin(2*math.pi*t), -1, 1, 0, 1)
              nt = 6+6*m
              save()
              stroke(.5)
              fill(None)
              strokeWidth(1)
              rotate(360.0*i/N, (width()*.5, height()*.5))
              spiral(2*math.pi*i/N, R, nt);
              restore()
      saveImage('davesCreature.gif')
      

      One might find mapValue an interesting function featured natively in processing:
      https://processing.org/reference/map_.html

      posted in Code snippets
      JeremieHornus
      JeremieHornus
    • RE: Possible solution to Just's puzzle?

      @justvanrossum building on @erik solution:
      0_1515856408012_Just2.gif

      import random, math, noise
      
      w = 500
      h = 500
      
      dia = 100
      rows = 5
      cols = 5
      ovals = []
      
      frames = 30
      
      for x in range(1, rows):
          for y in range(1, cols):
              ovals.append((x*(w/rows), y*h/cols, 1+.5*random.random()))
      
      for f in range(frames):
          newPage(w, h)
          frameDuration(1/20)
          fill(0)
          rect(0,0,width(),height())
          n = f/frames
          for d in range(1, dia):
              d = dia-d
              fill(.9*math.sqrt((dia-d)/dia))
              
              for i, (x, y, g) in enumerate(ovals):
                  m = noise.pnoise3(.1*x/w, .1*y/h, i+ .5*math.sin(2*math.pi*(f/frames)))
                  oval(20*m + x-.5*d*g*(1+m), 20*m +  y-.5*d*g*(1+m), d*g*(1+m), d*g*(1+m))
      
      saveImage("Just2.mp4")
      
      posted in Code snippets
      JeremieHornus
      JeremieHornus
    • RE: Possible solution to Just's puzzle?

      Something like that ?

      fill(math.sqrt((dia-d)/dia))
      

      0_1515849423774_Just.jpg

      posted in Code snippets
      JeremieHornus
      JeremieHornus
    • WildyLoopyThing

      A simple little Perlin Noise animation thing 🙂
      0_1515422425702_wildyloopything.gif

      # Requires caseman perlin noise: clone and install > https://github.com/caseman/noise
      import noise
      import random
      import math
      
      points = []
      
      size = 500
      nthing = 60
      baseSizeRatio = .2
      ncircle = 5
      for e in range(ncircle):  
          n = (e+1)/ncircle
          for i in range(nthing):
              phase = i / nthing
              x = size*.5 - n*baseSizeRatio*size * math.sin(2*math.pi*phase)
              y = size*.9 - .5*(1-n)*size - (1-n)*baseSizeRatio*size - .1*n*baseSizeRatio*size * math.cos(2*math.pi*phase)
              c = (0, 1, .5, .8*(y/size) )
              l = 10+ 10*random.random()
              t = 1
              points.append((x, y, c, l, t))
      
      length = 10
      frames = 100
      
      for f in range(frames):
          
          newPage(size, size)
          frameDuration(1/15)
          fill(0) 
          rect(0, 0, size, size) 
          fill(None) 
          
          for p in points:
              strokeWidth(p[4])
              stroke(p[2][0], p[2][1], p[2][2], p[2][3])
              path = BezierPath()
              
              prev_x = p[0]
              prev_y = p[1]  + (p[1]/size)*50*math.sin(noise.pnoise2(.1*p[0]*.1*p[1], .1*abs(frames*.5-f)))
              path.moveTo((prev_x, prev_y))
              for l in range(length):
                  dx = int(p[3]*math.sin(noise.pnoise2(.1*p[0], (abs(frames*.5-f)+l)*.1 )))
                  dy = -int(p[3]*math.cos(noise.pnoise2(.1*p[1], (abs(frames*.5-f)+l)*.1 )))
                  path.lineTo((prev_x, prev_y))
                  prev_x += dx
                  prev_y += dy
              drawPath(path)
              
      saveImage("~/Desktop/wildyloopything.gif")
      
      posted in Code snippets
      JeremieHornus
      JeremieHornus
    • Is there a way to share Python code on the forum?

      At some point I thought the idea of the forum was also to share bits of DrawBot code… would that be possible and how?

      posted in General Discussion
      JeremieHornus
      JeremieHornus