Navigation

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

    Topics created by bic

    • bic

      Voronoi Fun
      Code snippets • voronoi • • bic  

      5
      0
      Votes
      5
      Posts
      561
      Views

      gferreira

      Voronoi is a lot of fun indeed. I gave scipy.spatial.Voronoi a try, and got it to work (sort of; some polygons are missing): # based on http://stackoverflow.com/questions/27548363/from-voronoi-tessellation-to-shapely-polygons from random import randrange from scipy.spatial import Voronoi size(600, 300) pointsAmount = 160 points = [(randrange(width()), randrange(height())) for i in range(pointsAmount)] V = Voronoi(points) regions = [V.vertices[line] for line in V.regions if -1 not in line] stroke(1) strokeWidth(2) for R in regions: pts = [(float(x), float(y)) for x, y in R] if len(pts): fill(random(), random(), 0.7, 0.7) polygon(*pts) r = 1 stroke(None) fill(0) for x, y in points: oval(x-r, y-r, r*2, r*2) saveImage('voronoi-drawbot-2.png') and here is the bitmap version ported from PIL happy voronoiing!
    • bic

      Zip not supported?
      Bugs • py3 • • bic  

      4
      0
      Votes
      4
      Posts
      1056
      Views

      gferreira

      @bic to make sure which version of Python you are running: import sys print(sys.version) in SublimeText3 you can set the Python version in Tools > Build System. handling of unicode changed radically from py2 to py3. see: Strings, Bytes, and Unicode in Python 2 and 3 Unicode strings in Python: A basic tutorial hope this helps!
    • bic

      Kadenze online course
      Tutorials • getting started • • bic  

      2
      1
      Votes
      2
      Posts
      1459
      Views

      MauriceMeilleur

      @bic Ooh. Looks intriguing. I wonder if there's a Rhino Python library that could be imported and used in DB …