Navigation

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

    Best posts made by frederik

    • DrawBot 3.112 Release

      A new version is available:

      • The launch time is now at lightning speed!

      • Added a new keyword argument center for the rotate(), scale(), and skew() functions.

      The optional center argument will make the transformation be centered around the given point:

      rotate(20, center=(500, 500)) # rotate around (500, 500)
      rect(250, 250, 500, 500)
      

      Just for reference: the extra argument does the same as this example but is a lot more convenient:

      # define a center point
      centerX, centerY = 500, 500
      # translate to that center point
      translate(centerX, centerY)
      # do the transformation
      rotate(20)
      # translate back 
      translate(-centerX, -centerY)
      # draw something
      rect(250, 250, 500, 500)
      

      Download and Play!!!

      posted in Announcements
      frederik
      frederik
    • RE: Generate animated .gifs, .pdfs similar to generateMP4()?

      that is possible you can use:

      from drawBot.context.tools.gifTools import generateGif
      
      generateGif(gifPaths, destinationPath, frameRates)
      # gifPaths: a list of paths to gif files
      # destinationPath: a path where to save the animated gif
      # frameRates: a list with the same length as the gifPaths of ints in 1/100sec
      

      see https://github.com/typemytype/drawbot/blob/master/drawBot/context/tools/gifTools.py#L11

      hope this works!

      posted in General Discussion
      frederik
      frederik
    • DrawBot 3.122 is released
      • Adding bezierPath.expandStroke(width, lineCap="round", lineJoin="round", miterLimit=10) (thanks to Bahman Eslami)

      • Improved internal OpenType feature tags setting

      • Improved complex formattedString type setting

      • Improved alignment with text() and FormattedString

      • Added a DrawBot frontend for pip/PyPI to make it super easy to install third-party packages: see menu Python -> Install Python Packages...

        DrawBotPipDemo.gif

      • Fixed text stroke behavior (but is a breaking change): strokeWidth on text no longer scales with the fontSize

      • Removed support for .mov export on 10.15 and up (QTKit is no longer supported there)

      • Fixed extracting single frames from .gif files

      • Improved setup.py, so drawbot-as-a-module can be easily installed with pip using a github URL

      • All test now run on Travis CI (and soon also on GitHub Actions)

      • Removed Python 2 code

      • Many small issues were fixed

      posted in Announcements
      frederik
      frederik
    • DrawBot3.121 is released
      • Jumping to python 3.7

        If you use external packages you will need to install them for python 3.7. If you don't have python 3.7 installed you will need to do that first.

      • Improved syntax highlighting for python 3

      • Fallback fonts are also used in a svg context.

      • listNamedInstances() lists all named instances for a variable font.

      • BezierPath objects have bezierPath.line(pt1, pt2) and bezierPath.polygon(pt1, pt2, ...) methods.

      • Update internal packages!

      posted in Announcements
      frederik
      frederik
    • RE: Are there any tutorials on how to build Drawbot python files via Sublime?

      you could save the result to disk and open the result in an specified app with:

      from drawBot import *
      
      fill(random(), random(), random())
      rect(10, 10, 100, 100)
      
      path = "~/Desktop/test.pdf"
      saveImage("~/Desktop/test.pdf")
      
      import os
      os.system(f"open --background -a Preview {path}")
      
      posted in General Discussion
      frederik
      frederik
    • RE: arcTo documentation?

      I understand the confusion 🙂

      a much better explanation:

      The created arc is defined by a circle inscribed inside the angle specified by three points: the current point, the fromPoint parameter, and the toPoint parameter (in that order). The arc itself lies on the perimeter of the circle, whose radius is specified by the radius parameter. The arc is drawn between the two points of the circle that are tangent to the two legs of the angle.
      The arc usually does not contain the points in the fromPoint and toPoint parameters. If the starting point of the arc does not coincide with the current point, a line is drawn between the two points. The starting point of the arc lies on the line defined by the current point and the fromPoint parameter.

      https://developer.apple.com/documentation/appkit/nsbezierpath/1520737-appendbezierpathwitharcfrompoint

      I will adjust the drawBot documentation

      posted in General Discussion
      frederik
      frederik
    • RE: while()

      This is savedState() http://www.drawbot.com/content/canvas/state.html#drawBot.savedState

      with savedState():
          # do something
      

      This is more readable and clearer then wrapping code inside a save / restore statement.

      posted in General Discussion
      frederik
      frederik
    • RE: What's the main difference between py2 vs py3?

      For beginners there is not such a big difference:

      Strings

      All strings are unicode string, so no converting back and forth, but this is actually the best thing!!

      print

      print('hello world') requires brackets ( and )

      divisions

      Divisions are always floats so no more rounding, this is also a good thing: 1/3-> 0.333333 instead of 0

      You keep the old behaviour with 1//3

      If you dive deeper:

      dictionaries

      dict.keys(), dict.values(), dict.items() are not a lists anymore

      Looping (a for loop or a while loop) over a dictionary and changing content of that dictionary is tricky:

      for key in list(myDict.keys()):
          myDict[key] = "changed" + myDict[key]
      

      There is of course more

      • Python2 or Python3
      • What's New
      • google it 🙂
      posted in General Discussion
      frederik
      frederik
    • RE: Stephen Nixon's blogified class notes: a useful beginners' DrawBot tutorial

      @thundernixon ssssht py3.6 🙂

      posted in Tutorials
      frederik
      frederik
    • RE: Impossible typefaces?

      there are plainly of references in generative art, going from artist like Sol Lewit to graphic designers Juriaan Schrofer and many more.

      good luck!!

      posted in Code snippets
      frederik
      frederik
    • DrawBot 3.116 is released
      • support for a new file .drawbot which is a package containing drawBot scripts. Made for sharing and exchanging scripts.
        0_1537862153487_Screen Shot 2018-09-25 at 09.55.42.png

      • a new Icon!!!!! thanks Andy
        0_1537862098837_41625240-68034a06-7418-11e8-9829-c04348676bb0.gif

      • newPage() without arguments is possible, drawBot will use the previous set width and height or fallback to the default.

      posted in Announcements
      frederik
      frederik
    • RE: how to code a gif making a picture transform from small to large and rotate

      hope this example is clear enough!

      testImage.gif

      # path to an image
      path = 'https://github.com/typemytype/drawbot/raw/master/docs/content/assets/drawBot.jpg'
      # get the width and height of the image
      canvasWidth, canvasHeight = imageSize(path)
      # amount of frames
      frameCount = 24
      # start the loop
      for frame in range(frameCount):
          # calculate a factor, number between 0 - 1
          # going from 0 - 1 - 0
          frameFactor = frame / (frameCount) * 2        
          if frameFactor > 1:
             frameFactor = 2 - frameFactor 
          # create a new page, based on the image size
          newPage(canvasWidth, canvasHeight)
          # set frame duration in second only when the full image is shown
          if frameFactor == 1:
              frameDuration(1)
          else:
              frameDuration(.05)
          
          # easin
          frameFactor = frameFactor * frameFactor
          # translate to the middle
          translate(canvasWidth/2, canvasHeight/2)
          # scale from the middle
          scale(frameFactor)
          # rotate from the middle
          rotate(360 * frameFactor * 10)
          # translate back away from the middle
          translate(-canvasWidth/2, -canvasHeight/2)
          # draw the image
          image(path, (0, 0))
      # save as gif
      saveImage("testImage.gif")
      
      posted in General Discussion
      frederik
      frederik
    • RE: Why would I declare a newPath() as opposed to defining a BezierPath() with a variable name?

      In some cases it's a lot easier to have an object of path to work with, instead of the combo: newPath(), moveTo(..), lineTo(..), curveTo(..), closePath()

      stroke(0)
      fill(None)
      # create a new path object
      path = BezierPath()
      # add a move to to the path object
      path.moveTo((200, 200))
      # add a line to to the path object
      path.lineTo((200, 100))
      
      # this creates a new path and set it as current path in the stack
      newPath()
      # add a move to to the current path
      moveTo((100, 100))
      # add a line to to the current path 
      lineTo((100, 200))
      # draw the current path
      drawPath()
      
      # draw the path, instead of the current one
      drawPath(path)
      
      posted in General Discussion
      frederik
      frederik
    • RE: Oval() point placement

      I don't know why but my wild guess is it has todo with drawing ovals at more extreme w, h ratios, when the points are on the extremes you will need a pushing point in the middle to nice curve back.

      @gferreira you method only works for circles...

      the drawBot RoboFont extension has points on the extremes, cause the context is type... see https://github.com/typemytype/drawBotRoboFontExtension/blob/master/DrawBot.roboFontExt/lib/glyphContext.py#L23

      see the big difference when the oval is getting thinner...

      def straightOval(x, y, w, h):
              c = 0.55
              hx = w * c * .5
              hy = h * c * .5
              path = BezierPath()
              path.moveTo((x + w * .5, y))
              path.curveTo((x + w * .5 + hx, y), (x + w, y + h * .5 - hy), (x + w, y + h * .5))
              path.curveTo((x + w, y + h * .5 + hy), (x + w * .5 + hx, y + h), (x + w * .5, y + h))
              path.curveTo((x + w * .5 - hx, y + h), (x, y + h * .5 + hy), (x, y + h * .5))
              path.curveTo((x, y + h * .5 - hy), (x + w * .5 - hx, y), (x + w * .5, y))
              path.closePath()
              drawPath(path)
              
      
      x, y, w, h = 10, 10, 8.0, 146.0
      
      
      oval(x, y, w, h)
      straightOval(x + w + 10, y, w, h)
      
      posted in General Discussion
      frederik
      frederik
    • RE: Manipulating points

      you can get point labels in RoboFont with:

      glyph = CurrentGlyph()
      
      for contour in glyph:
          for point in contour.points:
              print(point.labels)
      
      posted in General Discussion
      frederik
      frederik
    • RE: Manipulating points

      I dont know Glyhps 🙂 but you can always do this in RoboFont with point labels!!!

      posted in General Discussion
      frederik
      frederik
    • RE: RFont subclass not generating "otf"

      two things:

      why generate a binary and read the the binary back in? see f1.generate("otfcff", "f1.otf")

      Give you new font a unique name based on the interp_factor. The font familyName and styleName makes up the postScriptName which has to be unique to set a font in drawBot (and everywhere else). In your case the font familyName and styleName will be "None" "None". This is not good...

      posted in General Discussion
      frederik
      frederik
    • RE: RFont subclass not generating "otf"

      there are several options:

      • font.interpolate will returns a ufo
      • a designspace document with a given location will also returns a ufo, use mutatorMath
      • generate a variable font

      Generating variable fonts from design spaces is not difficult: in RoboFont you can use the Batch extension. In DrawBot you can pip install ufo2ft to generate a var font and use it inside your type setting.

      good luck!

      posted in General Discussion
      frederik
      frederik
    • RE: RFont subclass not generating "otf"

      Inside the app DrawBot an RFont has no implementation for the method generate.

      Inside RoboFont you can use the DrawBot extension, where you can have all the powers DrawBot has to draw and all the powers RoboFont has to edit font data, and also call font.generate(...).

      posted in General Discussion
      frederik
      frederik
    • RE: Cryptic error language in the pip/PyPi frontend

      and I think nodebox is the the itself app and has no setup.py.

      posted in General Discussion
      frederik
      frederik