Navigation

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

    Posts made by justvanrossum

    • RE: A little arcTo() and geometry help?

      Partial explainer of what that code does: https://twitter.com/justvanrossum/status/1192324084656476160

      posted in General Discussion
      justvanrossum
      justvanrossum
    • RE: A little arcTo() and geometry help?

      @MauriceMeilleur Have a look at https://github.com/typemytype/outlinerRoboFontExtension/blob/master/Outliner.roboFontExt/lib/outlinePen.py#L518 which solves more or less the same problem. Esp. the handleLength part should be of interest to you.

      posted in General Discussion
      justvanrossum
      justvanrossum
    • Python For Designers online book

      http://pythonfordesigners.com/

      posted in Tutorials
      justvanrossum
      justvanrossum
    • Here's a good tutorial for people just starting out with DrawBot

      https://learn.adafruit.com/getting-started-with-drawbot?view=all

      posted in Tutorials
      justvanrossum
      justvanrossum
    • RE: Using a virtualenv in Drawbot

      Oh, I've been trapped by a bot it seems 😞 Still, my answer may be useful 🙂

      posted in General Discussion
      justvanrossum
      justvanrossum
    • RE: Using a virtualenv in Drawbot

      Oh, that's a clever idea, thanks for sharing.

      ... said in Using a virtualenv in Drawbot:

      import sys
      sys.path.insert(0, "/Users/maartenidema/t_venv/lib/python3.6/site-packages")

      You should be able to make that happen automatically. Please try the following:

      • Create a folder called /Library/Python/3.6/site-packages if it doesn't already exists
      • place a file in there with a .pth extension, say my_venv.pth
      • write the line /Users/maartenidema/t_venv/lib/python3.6/site-packages into that file
      • Restart DrawBot and see if you can now import from your venv.

      Sorry, I didn't test this. Please let us know if it works.

      posted in General Discussion
      justvanrossum
      justvanrossum
    • Rotating arrows exercise

      This is by no means an original idea, but it's a fun thing to program.

      Triggered by Mike Duggan: https://twitter.com/mickduggan/status/1090577885067386880

      Arrows.gif

      # triggered by Mike Duggan:
      # https://twitter.com/mickduggan/status/1090577885067386880
      
      def arrow(center, size, rotation, barThickness, arrowhead):
          with savedState():
              translate(*center)
              scale(size)
              rotate(rotation)
              points = [
                  (-0.5, barThickness/2),
                  (0.5 - arrowhead, barThickness/2),
                  (0.5 - arrowhead, 0.5),
                  (0.5, 0),
                  (0.5 - arrowhead, -0.5),
                  (0.5 - arrowhead, -barThickness/2),
                  (-0.5, -barThickness/2),
              ]
              polygon(*points)
      
      def arrowGrid(numArrows, arrowSize, barThickness, arrowhead, rotation):
          for i in range(numArrows):
              x = i * arrowSize
              for j in range(numArrows):
                  y = j * arrowSize
                  arrow((x, y), arrowSize, rotation, barThickness, arrowhead)
      
      def easeInOut(t):
          assert 0 <= t <= 1
          return (1 - cos(t * pi)) / 2
      
      canvasSize = 400
      numArrows = 4
      arrowSize = canvasSize / numArrows
      barThickness = 0.5
      arrowhead = 0.5
      rotation = 180
      
      duration = 4
      framesPerSecond = 15
      numFrames = duration * framesPerSecond
      
      for frame in range(numFrames):
          t = 4 * frame / numFrames
          quadrant = floor(t)
          t = easeInOut(t % 1)
          angle = ((quadrant + t) * 90) % 380
          flip = quadrant % 2
          angle = -angle
      
          newPage(canvasSize, canvasSize)
          frameDuration(1/framesPerSecond)
      
          if flip:
              fill(1)
              rect(0, 0, canvasSize, canvasSize)
              fill(0)
              arrowGrid(numArrows + 1, arrowSize, barThickness, arrowhead, angle)
          else:
              fill(0)
              rect(0, 0, canvasSize, canvasSize)
              fill(1)
              translate(-arrowSize/2, -arrowSize/2)
              arrowGrid(numArrows + 2, arrowSize, 1 - barThickness, arrowhead, angle + 180)
      
      saveImage("Arrows.gif")
      
      posted in Tutorials
      justvanrossum
      justvanrossum
    • RE: qCurve

      @mauricemeilleur You're seeing the representation of your shape as cubic beziers. The quads get converted to cubic because the underlying NSBezierPath doesn't support quadratic curves.

      posted in General Discussion
      justvanrossum
      justvanrossum
    • RE: qCurve

      @mauricemeilleur It's part of the "pen protocol" which lives in with FontTools, so any documentation should go there. It's documented in the code, have a look at the basePen.py module:

      https://github.com/fonttools/fonttools/blob/ca92b172f59356c38ac8d201129fb3a22512fac8/Lib/fontTools/pens/basePen.py#L80

      The main trick for the blobs is indeed the fact that the contour will have no on-curve points, and that is achieved by passing None as the last argument to pen.qCurveTo().

      posted in General Discussion
      justvanrossum
      justvanrossum
    • RE: Drawing glyphs from ufo file.

      @rafalbuchner This should work:

      def drawGlyph(g):
          bez = BezierPath()
          g.draw(bez)
          drawPath(bez)
      
      posted in General Discussion
      justvanrossum
      justvanrossum
    • RE: Cellular automaton

      @jo Beautiful!!!

      posted in Code snippets
      justvanrossum
      justvanrossum
    • RE: How to run Drawbot on a server: Does it is possible?

      @agyei Sounds like that should work.

      posted in General Discussion
      justvanrossum
      justvanrossum
    • RE: listFontGlyphNames() returning Alphabetical order?

      @guidoferreyra It looks like DrawBot could be changed to do that, yes. Please file an issue on github. In the meantime, you could do it yourself via fontTools:

      from fontTools.ttLib import TTFont
      font("AGaramondPro-Regular")
      f = TTFont(fontFilePath())
      print(f.getGlyphOrder())
      
      posted in General Discussion
      justvanrossum
      justvanrossum
    • RE: Making new libraries

      Alternatively you can park your module in /Library/Python/3.6/site-packages/ (If using Py 3.6.) If that folder doesn't exist, you can create it manually. DrawBot will find it.

      posted in General Discussion
      justvanrossum
      justvanrossum
    • RE: Making new libraries

      The from . import mymodule notation is only for relative imports within packages.

      The easiest way is indeed to put your module in the same folder as the main script. But just write import mymodule or from mymodule import nameinmymodule.

      Note that imports ae cached: if you change your module, the main script won't see those changes until you reload your module (or restart DrawBot).

      posted in General Discussion
      justvanrossum
      justvanrossum
    • A grid of animated spirals

      0_1520364143306_SpiralGrid2-clean.gif

      def spiral(cx, cy, diameter, angle):
          with savedState():
              translate(cx, cy)
              scale(diameter / 1000)
              for i in range(100):
                  rect(406, 0, 95, 95)
                  rotate(angle)
                  scale(0.99)
      
      gridSize = 100
      margin = 50
      canvasSize = 500
      numFrames = 40
      
      for frame in range(numFrames):
          t = frame / numFrames
          newPage(canvasSize, canvasSize)
          frameDuration(1/20)
          fill(0)
          rect(0, 0, canvasSize, canvasSize)
          fill(1)
          translate(margin, margin)
          for i in range(5):
              for j in range(5):
                  a = 2 * pi * (t + (i + j) / 8)
                  angle = 31 + 2 * sin(a)
                  spiral(i*gridSize, j*gridSize, 95, angle)
      
      saveImage("~/Desktop/SpiralGrid.gif")
      
      posted in Code snippets
      justvanrossum
      justvanrossum
    • RE: SSL Error (known SSL OSX issue?)

      The link you reference indeed explains the problem. I tried the first solution but it doesn't help. I don't have that command file in my machine to try that.

      posted in Bugs
      justvanrossum
      justvanrossum
    • RE: Windows minimizing and re-expanding after completing script

      @mauricemeilleur Hm, I've never seen this happen.

      posted in Bugs
      justvanrossum
      justvanrossum
    • RE: image Object should have imagePixelColor method

      You can pass an ImageObject to imagePixelColor():

      im = ImageObject()
      
      with im:
          fill(1, 0, 0)
          rect(100, 100, 200, 200)
      
      print(imagePixelColor(im, (150, 140)))
      
      posted in Feature Requests
      justvanrossum
      justvanrossum
    • RE: SSL Error (known SSL OSX issue?)

      @chuckloyola It fails for me in the same way, but also in Terminal. I have no idea why. It's more a general Python issue rather than one with DrawBot it seems.

      posted in Bugs
      justvanrossum
      justvanrossum