Navigation

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

    jo

    @jo

    41
    Reputation
    41
    Posts
    994
    Profile views
    1
    Followers
    0
    Following
    Joined Last Online
    Website langustefonts.com Location vienna most of the time

    jo Follow

    Posts made by jo

    • RE: Variable portrait

      hi @eduairet
      you can submit a string of characters to the random choice function:

      chars = 'aeiou'
      print (random.choice(chars))
      

      any call of a ‘drawing function’ will make a new Page. Remove the translate(0, 2) to not have the blank page.

      Finally getting the image pixel color takes some time. Try to move stuff outside of the loops if they do not change. Eg try a loop outside the ranLetters() function to get and store the pixel colors, so you do not have to do that for every page.

      pix_cols = {}
      
      for x in range(0, w, s):
          for y in range(0, h, s):
              pix_cols[(x, y)] = imagePixelColor(path, (x, y))
      

      then inside the loop just ask for the stored value:

      color = pix_cols[(x, y)]
      

      also these three lines do not change so they could be outside of the loop:

      font("League Spartan Variable")
      fontSize(s)
      lineHeight(s * 0.75)
      

      good luck!

      posted in Tutorials
      jo
    • bezierPath.polygon()?

      I just tried to use bezierPath.polygon() since bezierPath.rect() and bezierPath.oval() work.
      this does not work (and can be solved in other ways), but maybe it would be nice and somewhat logic since rect and oval do work?

      posted in Feature Requests
      jo
    • RE: How can I split a path into multiple segments?

      @jansindl3r keep in mind that in a Bezier curve time and distance do not correlate. if you construct a point at time .1 it will not be at one tenth of the curve length.
      Bezier_const.png

      afaik the most common technique to get similar distances is to calculate lots of points on the curve(s), calculate some distances and select the closest points.

      this link has some very helpful information.

      good luck.

      posted in General Discussion
      jo
    • RE: Output text

      @gferreira
      probably not pythonic
      but i was surprised this works
      (if you keep things black and white)

      coin = randint(0, 1)
      color1 = coin,
      color2 = not coin,
      
      posted in Tutorials
      jo
    • Lissajous table

      Here is some code to draw a Lissajous table.
      Change the func_x and/or func_y (sin or cos) and/or add some value to the delta to get other curves.
      Well, actually the curves are just polygons.

      # ----------------------
      #  lissajous table 
      # ----------------------
      #  settings 
      
      cols = 12 
      rows = 8
      cell_s = 80
      r_factor = .8 # fraction of the cell size to have a gap between them
      
      func_x = cos  # should be `sin` or `cos` 
      func_y = sin  # should be `sin` or `cos` 
      delta = 0 #pi/3  # some angle in radians 
      
      density = 360 # amount of points per cell – higher values make nicer curve approximations 
      
      # ----------------------
      #  calculated settings 
      
      radius = (cell_s * r_factor) / 2
      step = (2 * pi) / density
      
      pw = cell_s * (cols + 1)
      ph = cell_s * (rows + 1)
      
      x_coords = { (col, d) : func_x(step * (col + 1) * d  + pi/2 + delta) * radius for col in range(cols) for d in range(density) }
      y_coords = { (row, d) : func_y(step * (row + 1) * d  + pi/2) * radius for row in range(rows) for d in range(density) }
      
      
      # ----------------------
      #  function(s)
      
      def draw_cell(pos, col, row):
          cx, cy = pos
          points = [(cx + x_coords[(col, f)], cy + y_coords[(row, f)]) for f in range(density)]
          polygon(*points)
      
      
      # ----------------------
      #  drawings 
      
      newPage(pw, ph)
      rect(0, 0, pw, ph)
      fontSize(12)
      translate(0, ph)
      fill(1)
      text('δ\n{0:.2f}°'.format(degrees(delta)), (cell_s * (1 - r_factor)/2, -20))
      
      for col in range(1, cols+1):
          cx = col * cell_s + cell_s * (1 - r_factor)/2
          text('{0}\n{1}'.format(func_x.__name__, col), (cx, -20))
      
      for row in range(1, rows + 1):
          cy = row * cell_s + cell_s * (1 - r_factor)
          text('{0}\n{1}'.format(func_y.__name__, row), (cell_s * (1 - r_factor)/2, -cy))
          
      fill(None)
      stroke(.5)
      strokeWidth(1)
      
      for col in range(cols):
          for row in range(rows):
              draw_cell((cell_s * col + cell_s * 1.5, - cell_s * row -cell_s * 1.5), col, row)
      

      liss_table.png

      posted in Code snippets
      jo
    • RE: How to mirror/flip a object?

      @habakuk nice to read that you can use some of the code!

      about the lissajous: I am not sure what exactly you want to achieve. the german wiki entry has vizualisations for a few values. you might want to change the value for a and b and also delta, eg:

      a = 1 
      b = 3
      delta = pi/4
      

      I do not have your variable font so I cannot test this but I was wondering why you added the plus and minus 20 here:

      curr_axis1 = ip(axis1_min + 20, axis1_max - 20, x)
      curr_axis2 = ip(axis2_min + 20, axis2_max - 20, y)
      

      lastly if you want to draw the shadow in the back, just put the lines of code before you call the pink drawing. you might then use the savedState() so draw it without the mirroring.

      good luck, jo!

      posted in General Discussion
      jo
    • RE: How to mirror/flip a object?

      the mirrored drawing is probably happening outside your canvas. keep in mind that every transformation (scale, skew, rotation, etc) is always starting from the origin. so a mirroring from the default origin (left, bottom corner) will be to the left or below your canvas. see the example below with a shifted origin.

      pw = 1000
      ph = 400
      txt = "SHADE"
      newPage(pw, ph)
      translate(0, 160) # shift the origin up a bit
      fontSize(300)
      text(txt, (pw/2, 0), align = 'center')
      scale(x=1, y=-.5) # the mirroring
      text(txt, (pw/2, 0), align = 'center')
      
      posted in General Discussion
      jo
    • RE: More variable fonts nonsense

      @Christine hello!
      I just downloaded the zip from github and did test a few of the scripts in drawbot without any issue. did you change the folder structure and / or do you get an error message? what OS are you using?

      posted in Code snippets
      jo
    • RE: Random Lines with no intersection

      @mrrouge

      ok if i got you right you want the function to return a value — in your case the height of the legs. this value could then be used in a while loop. while loops are quite helpful but might run forever if done incorrect. I adapted the code a bit so the legs function returns the length of the legs which is then added to the y value in the while loop. There is a check inside the while loop so it will run for a maximum of 3000 times.

      # -------------
      #  settings 
      
      pw = ph = 500
      amount_x = 10
      
      cell_w = pw / amount_x
      
      max_h  = 50
      gap = max_h * .2
      
      # -------------
      #  fucntion(s)
      
      def legs(pos, max_w, max_h):
      
          x, y = pos
          length = random() * max_h
          step_s = random() * max_w
          polygon((x - step_s, y) , (x, y + length), (x + step_s, y), close = False)
          
          return length
      
      # -------------
      #  drawings
      
      newPage(pw, ph) 
      fill(None)
      stroke(0)
      strokeWidth(2)
      
      for x in range(amount_x):
          
          count = 0
          y = -random() * max_h
          while y < ph:
              y += legs((x * cell_w + cell_w/2, y), cell_w/2, max_h)
              y += gap
              count += 1
              
              if count > 3000: break 
      
      

      and the while loop without the check:

      for x in range(amount_x):
          y = -random() * max_h
          while y < ph:
              y += legs((x * cell_w + cell_w/2, y), cell_w/2, max_h)
              y += gap
      
      

      legs.jpg

      posted in General Discussion
      jo
    • Vera Molnar re-coded

      Vera Molnar is a great computer generated arts pioneer and is still working. I could not resist to emulate and try to recode some of her artworks. Using drawbot to do so is great fun and pretty easy — one can only wonder about the struggles she had to overcome. With all due respect here is a link to github with my humble attempts.

      posted in Code snippets
      jo