Navigation

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

    djrrb

    @djrrb

    2
    Reputation
    8
    Posts
    234
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    djrrb Follow

    Best posts made by djrrb

    • RE: image patterns as shape fill

      This is an old post I realize, but since I just happened to stumble upon it and it didn’t get any responses, I’ll just mention that you can use clipPath() and then looping through a grid and drawing an image.

      # make an image that we’ll tile
      im = ImageObject()
      im.sunbeamsGenerator(
          (100, 100),  # size
          (0, 0),  # center
          )
      
      # draw a single tile in the lower left, for reference
      image(im, (0, 0))
      
      # get the size 
      imWidth, imHeight = im.size()
      rows = int(ceil(height()/imHeight))
      cols = int(ceil(width()/imWidth))
      
      # make a shape
      shape = BezierPath()
      shape.oval(100, 100, 800, 800)
      shape.rect(500, 500, 400, 400)
      
      # i always like to save state before clip path
      with savedState():
          # clip the path using the shape
          clipPath(shape)
          # loop through y and x to make a grid
          for y in range(rows):
              for x in range(cols):
                  # draw the image a bunch of times
                  image(im, (x*imWidth, y*imHeight))
      
      posted in General Discussion
      djrrb
      djrrb
    • RE: Markdown syntax for FormattedString?

      I hope you don’t mind me reviving this...I’ve been trying to work with @frederik’s gist from march, and cannot seem to get beyond this error after installing markdown using the package manager. Usually I would just ascribe this to my weird python setup, but since Drawbot is its own self-contained universe, I wonder if there is something obvious I am missing?

      Drawbot Version 3.126, MacOS 10.15.7 (19H2)

      Many thanks!

      Traceback (most recent call last):
        File "<untitled>", line 72, in <module>
        File "<untitled>", line 14, in appendMarkdown
        File "/Users/david/Library/Application Support/DrawBot/Python3.7/markdown/__init__.py", line 29, in <module>
        File "/Users/david/Library/Application Support/DrawBot/Python3.7/markdown/core.py", line 27, in <module>
        File "/Users/david/Library/Application Support/DrawBot/Python3.7/markdown/preprocessors.py", line 29, in <module>
        File "/Users/david/Library/Application Support/DrawBot/Python3.7/markdown/htmlparser.py", line 31, in <module>
      AttributeError: 'zipimport.zipimporter' object has no attribute 'exec_module'
      
      posted in Feature Requests
      djrrb
      djrrb

    Latest posts made by djrrb

    • RE: image patterns as shape fill

      This is an old post I realize, but since I just happened to stumble upon it and it didn’t get any responses, I’ll just mention that you can use clipPath() and then looping through a grid and drawing an image.

      # make an image that we’ll tile
      im = ImageObject()
      im.sunbeamsGenerator(
          (100, 100),  # size
          (0, 0),  # center
          )
      
      # draw a single tile in the lower left, for reference
      image(im, (0, 0))
      
      # get the size 
      imWidth, imHeight = im.size()
      rows = int(ceil(height()/imHeight))
      cols = int(ceil(width()/imWidth))
      
      # make a shape
      shape = BezierPath()
      shape.oval(100, 100, 800, 800)
      shape.rect(500, 500, 400, 400)
      
      # i always like to save state before clip path
      with savedState():
          # clip the path using the shape
          clipPath(shape)
          # loop through y and x to make a grid
          for y in range(rows):
              for x in range(cols):
                  # draw the image a bunch of times
                  image(im, (x*imWidth, y*imHeight))
      
      posted in General Discussion
      djrrb
      djrrb
    • Show Tabs in Editor

      In teaching classes/workshops, I have found that indentation tends to be a challenge for folks who are new to Python. Since the Drawbot editor is intended to help beginners, I think an editor preference to show tabs might be very helpful...if it’s not too difficult to add!

      There are a few ways to visualize this: greyed-out middots for each space, vertical lines, etc.

      Talking to @robstenson about this topic, he suggested the Indent Rainbow VSCode extension, which clearly but subtly color codes tabs to help students easily identify the indentation level of a code block. (He also showed me Rainbow Brackets as well, which is pretty cool.)

      If this should be a github issue, let me know, but I figured I would start here because I prefer typing my feature requests in DBRegular! 😎

      Thank you!

      posted in Feature Requests
      djrrb
      djrrb
    • RE: Built-in interpolation functions

      @frederik done! https://github.com/typemytype/drawbot/issues/414

      posted in Feature Requests
      djrrb
      djrrb
    • Built-in interpolation functions

      I’m curious if you think there is value in adding interpolation functions to DrawBot, similar to lerp(), norm(), and map() in Processing/p5.js.

      I understand it’s not good to bloat the initial state, and perhaps this is better handled by an external package. (Or maybe there is already a built-in way to deal with this that I don’t know about?)

      Interpolation plays such a big part in so many of my scripts and those I create with my students, and I have cut and pasted the code below into so many of my DrawBot scripts that I felt moved to write this post and ask.

      In case you are interested, I am happy to contribute the code I use. It uses the same syntax as Processing, except that remap() is used to avoid conflict with the Python map() function.

      Thank you, as always

      # Released by DJR under the BSD license 
      def lerp(start, stop, amt):
      	"""
      	Return the interpolation factor (between 0 and 1) of a VALUE between START and STOP.
      	https://processing.org/reference/lerp_.html
      	"""
      	return float(amt-start) / float(stop-start)
      	
      def norm(value, start, stop):
      	"""
      	Interpolate using a value between 0 and 1
      	See also: https://processing.org/reference/norm_.html
      	"""
      	return start + (stop-start) * value
      
      def remap(value, start1, stop1, start2, stop2, withinBounds=False):
          """
          Re-maps a number from one range to another.
          """
          factor = lerp(start1, stop1, value)
          if withinBounds:
              if factor < 0: factor = 0
              if factor > 1: factor = 1
          return norm(factor, start2, stop2)
      
      posted in Feature Requests
      djrrb
      djrrb
    • RE: Markdown syntax for FormattedString?

      @gferreira said in Markdown syntax for FormattedString?:

      markdown==3.2.2

      Thanks so much Gustavo!

      posted in Feature Requests
      djrrb
      djrrb
    • RE: Markdown syntax for FormattedString?

      I hope you don’t mind me reviving this...I’ve been trying to work with @frederik’s gist from march, and cannot seem to get beyond this error after installing markdown using the package manager. Usually I would just ascribe this to my weird python setup, but since Drawbot is its own self-contained universe, I wonder if there is something obvious I am missing?

      Drawbot Version 3.126, MacOS 10.15.7 (19H2)

      Many thanks!

      Traceback (most recent call last):
        File "<untitled>", line 72, in <module>
        File "<untitled>", line 14, in appendMarkdown
        File "/Users/david/Library/Application Support/DrawBot/Python3.7/markdown/__init__.py", line 29, in <module>
        File "/Users/david/Library/Application Support/DrawBot/Python3.7/markdown/core.py", line 27, in <module>
        File "/Users/david/Library/Application Support/DrawBot/Python3.7/markdown/preprocessors.py", line 29, in <module>
        File "/Users/david/Library/Application Support/DrawBot/Python3.7/markdown/htmlparser.py", line 31, in <module>
      AttributeError: 'zipimport.zipimporter' object has no attribute 'exec_module'
      
      posted in Feature Requests
      djrrb
      djrrb
    • RE: Color fonts: “Create Outlines”, changing palettes

      @robstenson Wow!! This works perfectly for me. 👏👏👏

      Of course it would be cool to see something like these solutions worked into the drawbot API, but this solves my problem. Thanks so much!

      posted in Feature Requests
      djrrb
      djrrb
    • Color fonts: “Create Outlines”, changing palettes

      I realize this is a pretty niche request, but I found it interesting so I figured I’d share it. Perhaps there is even a way of doing this already?

      1. Normally, to convert text into outlines I would use a BezierPath object with a text method, but this doesn’t help me with a COLR/CPAL color font because the color information is lost to the monochromatic BezierPath object. Is there another way of converting text to a series of differently-colored paths?

      2. I would also love to access alternative color palettes stored in the CPAL table, as well as to designate my own (as was requested here: https://twitter.com/bicvudesign/status/1058063097485803520). Maybe this requires us to wait for OS support, but I figured I’d mention it in case you were interested in pursuing.

      As always, thanks again for all your work on this amazing tool!

      posted in Feature Requests
      djrrb
      djrrb