Navigation

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

    Topics created by eduairet

    • eduairet

      Gradient rings from Python for Designers tutorial
      Tutorials • gradient circles python for designers • • eduairet  

      3
      0
      Votes
      3
      Posts
      22
      Views

      eduairet

      @frederik thank you very much! I'll implement this way
    • eduairet

      Vertical Align
      Feature Requests • • eduairet  

      1
      0
      Votes
      1
      Posts
      9
      Views

      No one has replied

    • eduairet

      Loop image generation breaks at index 16
      General Discussion • batch csv custom postcards txt • • eduairet  

      4
      0
      Votes
      4
      Posts
      23
      Views

      eduairet

      @frederik OMG it works now!!! thank you very much!!!! Happy holidays!!!
    • eduairet

      SOLVED QRCodeGenerator(size, message)
      General Discussion • image object • • eduairet  

      4
      0
      Votes
      4
      Posts
      22
      Views

      frederik

      maybe the callback should convert incoming str to bytes, or the docs must change. Im make an issue --> https://github.com/typemytype/drawbot/issues/411
    • eduairet

      UNSOLVED access a specific frame from a gif
      General Discussion • • eduairet  

      7
      0
      Votes
      7
      Posts
      45
      Views

      eduairet

      This is an old post but this might help someone looking for iteration on gifs, and maybe anyone can tell an interesting fact about it. I've been working with gifs generated via Photoshop and Media Encoder and they crash after the second frame. What has worked for me to fix this problem is to open the gif file with the Mac OS Preview app and rewrite the file, even though this solved my problem it could be great to know if you had a similar experience and how you solved it.
    • eduairet

      SOLVED Pixelating a Bezier Path
      General Discussion • • eduairet  

      6
      0
      Votes
      6
      Posts
      37
      Views

      eduairet

      @frederik thank you It worked great now: x, y = 500, 500 resolutions = [72, 18] mfont = '/Library/Application Support/Adobe/Fonts/SansNom-Regular.otf' installFont(mfont) font(mfont) print(listFontGlyphNames()) letters = ['n', 'E'] def pixelar(tx, t, al=True): newPage(x, y) path = BezierPath() path.text(tx, fontSize=500, font=mfont) coords = path.bounds() translate((x - (coords[0] + coords[2])) * 0.5, (y - (coords[1] + coords[3])) * 0.5) drawPath(path) saveImage('~/Desktop/hint_{0}_{1}_aal_{2}.png'.format(tx, t, str(al).lower()), imageResolution=int(t), antiAliasing = al) newDrawing() for letter in letters: for resolution in resolutions: pixelar(letter, resolution, False) pixelar(letter, resolution)
    • eduairet

      Unknown Pleasures Tutorial
      Tutorials • • eduairet  

      5
      1
      Votes
      5
      Posts
      63
      Views

      eduairet

      @jo Thank you, I was disconnected from Drawbot so I haven't seen this, I'll try your suggestions on the code
    • eduairet

      SOLVED Problem with path closing
      General Discussion • bezierpath arc • • eduairet  

      5
      0
      Votes
      5
      Posts
      28
      Views

      eduairet

      @gferreira great!!!! thank you very much.
    • eduairet

      SOLVED Identify when a word breaks
      General Discussion • text formatting • • eduairet  

      3
      0
      Votes
      3
      Posts
      68
      Views

      eduairet

      @gferreira Thank you! I've used this in the following application but I noticed that even though I used hyphenation=False the words break in the middle so, I don't need it to break for this exercise but it's something I can't figure out: myVarFont = '/Library/Application Support/Adobe/Fonts/AstripeVariableGX.ttf' variations = listFontVariations(myVarFont) print(variations) axis1 = list(variations.keys())[0] minH = variations[axis1]['minValue'] maxH = variations[axis1]['maxValue'] axis2 = list(variations.keys())[1] minV = variations[axis2]['minValue'] maxV = variations[axis2]['maxValue'] #Words def textPage(*words, o=0, size='Tabloid', positive=True, h=True, txt=FormattedString(), myFont=myVarFont, fSize=30, lHeight=23.5): def canvas(): newPage(size) if positive is True: fill(1) if positive is False: fill(0) rect(o, o, width(), height()) canvas() txt.font( installFont(myFont) ) txt.fontSize(fSize) txt.openTypeFeatures(calt=True) txt.lineHeight(lHeight) hyphenation(False) lineLength = 0 textLength = (width()*height())/(lHeight) #print(textLength) while txt.size()[0] < textLength: for word in words: if lineLength % 350 == 0: txt.append('\n' + word, fontVariations={axis1:minH, axis2:minV}) else: txt.append(word, fontVariations={axis1:minH, axis2:minV}) lineLength += textSize(word)[0] #print(lineLength) textBox(txt, ( o, o, width(), height() )) #print(txt.size()[0]) textPage('PIBA', '2020', 'LIDERA') saveImage('~/Desktop/PIBA_2020_CORBATA.pdf') This is what I need from the image: And this is what I don't understand: By the way: The previous exercise worked this way: import os import unicodedata def strip_accents(text): try: text = unicode(text, 'utf-8') except NameError: # unicode is a default on python 3 pass text = unicodedata.normalize('NFD', text)\ .encode('ascii', 'ignore')\ .decode("utf-8") return str(text) class Canvas: def __init__(self, w, h, o = 0, bleed = 0): self.w = w self.h = h self.o = o self.bleed = bleed if self.bleed <= 0: newPage(self.w, self.h) else: newPage(self.w + self.bleed * 2, self.h + self.bleed * 2) translate(self.bleed, self.bleed) def color(self, r = 255, g = 255, b = 255, a = 100): self.r = r / 255 self.g = g / 255 self.b = b / 255 self.a = a / 100 return fill(self.r, self.g, self.b, self.a) def bg_stroke(self, r, g, b, a, sw): self.r, self.g, self.b, self.a = color_c(r, g, b, a) self.sw = sw stroke(self.r, self.g, self.b, self.a) strokeWidth(self.sw) fill(None) def grid(self, cols, rows, gutter, mTop, mBottom, mLeft, mRight, view=True): if view == True: self.cols = cols self.rows = rows self.gutter = gutter self.mTop = mTop - self.gutter self.mBottom = mBottom - self.gutter self.mLeft = mLeft - self.gutter self.mRight = mRight - self.gutter wd = (self.w - self.gutter * (self.cols + 1)) / self.cols - ((self.mRight + self.mLeft) / self.cols) hg = (self.h - self.gutter * (self.rows + 1)) / self.rows - ((self.mTop + self.mBottom) / self.rows) fill(None) strokeWidth(0.25) stroke(0, 1, 1) for self.col in range(self.cols): for self.row in range(self.rows): x = self.gutter + self.col * (wd + self.gutter) y = self.gutter + self.row * (hg + self.gutter) rect(x + self.mLeft, y + self.mBottom, wd, hg) def bg_square(self): if self.bleed <= 0: rect(self.o, self.o, self.w, self.h) else: rect(self.o - self.bleed, self.o - self.bleed, self.w + self.bleed * 2, self.h + self.bleed * 2) def bg_image(self, imgPath, px, py, angle, s): self.imgPath = imgPath self.px = px self.py = py self.angle = angle self.s = s srcWidth, srcHeight = imageSize(self.imgPath) dstWidth, dstHeight = self.w + s, self.h + s factorWidth = dstWidth / srcWidth factorHeight = dstHeight / srcHeight with savedState(): scale(factorWidth, factorHeight) rotate(self.angle) translate(self.px, self.py) image(imgPath, (0, 0)) def crop_marks(self): stroke(1) strokeWidth(1) line((self.o, -8), (self.o, -4)) line((-8, self.o), (-4, self.o)) line((self.o + self.w, -8), (self.o + self.w, -4)) line((8 + self.w, self.o), (4 + self.w, self.o)) line((self.o, 8 + self.h), (self.o, 4 + self.h)) line((-8, self.o + self.h), (-4, self.o + self.h)) line((self.o + self.w, 8 + self.h), (self.o + self.w, 4 + self.h)) line((8 + self.w, self.o + self.h), (4 + self.w, self.o + self.h)) stroke(0) strokeWidth(0.5) line((self.o, -8), (self.o, -4)) line((-8, self.o), (-4, self.o)) line((self.o + self.w, -8), (self.o + self.w, -4)) line((8 + self.w, self.o), (4 + self.w, self.o)) line((self.o, 8 + self.h), (self.o, 4 + self.h)) line((-8, self.o + self.h), (-4, self.o + self.h)) line((self.o + self.w, 8 + self.h), (self.o + self.w, 4 + self.h)) line((8 + self.w, self.o + self.h), (4 + self.w, self.o + self.h)) #Design #Margin gutter = 0 mTop = 8 mBottom = 8 mLeft = 8 mRight = 8 #Variable Font myVarFont = '/Library/Application Support/Adobe/Fonts/AstripeVariableGX.ttf' variations = listFontVariations(myVarFont) print(variations) #print(listFontGlyphNames()) axis1 = list(variations.keys())[0] minH = variations[axis1]['minValue'] maxH = variations[axis1]['maxValue'] axis2 = list(variations.keys())[1] minV = variations[axis2]['minValue'] maxV = variations[axis2]['maxValue'] num = 0 logo = 'PIBA_2020_GAFETES_LOGO.pdf' #Info gafetes_dir = {'Staff': 3, 'All Access': 1, 'Participante': 3, 'Prensa': 1, 'Académico': 3, 'Maestro de Ceremonia': 3, 'Jueces': 1, 'Edecán': 1, 'Sistemas': 1, 'Acompañante': 1, 'Director': 1} gafetes = [i for i in gafetes_dir.keys()] copias = [i for i in gafetes_dir.values()] def gafete(gf=0): #Frente page = Canvas(240, 150, 0, 8) page.color(255, 255, 255, 100) page.bg_square() #Text var = 400 minus = 0 lineHeight = 45 al = 'right' fs = 41 t = FormattedString() t.font(installFont(myVarFont)) t.fontSize(fs) t.fill(0) t.openTypeFeatures(calt=True) t.align(al) t.lineHeight(lineHeight) t.baselineShift(-15) for letter in gafetes[gf].upper(): t.append(letter, fontVariations={axis1:var, axis2:randint(minV, maxV)}) print(t.size()[0]) while t.size()[0] < page.w - 40 and var < 500: var += 10 print(var) if t.size()[0] > 300.0: lineHeight = 40 minus = 440.0 print('minus') if t.size()[0] < 140.0: lineHeight = 69 fs = 60 print('minus') t = FormattedString() t.font(installFont(myVarFont)) t.fontSize(fs) t.fill(0) t.openTypeFeatures(calt=True) t.align(al) t.lineHeight(lineHeight) t.baselineShift(-15) for letter in gafetes[gf].upper(): t.append(letter, fontVariations={axis1:var, axis2:randint(minV, maxV - minus)}) textBox(t, (mLeft, mBottom, page.w - mRight - mLeft, page.h - mTop - mBottom)) #Art page.bg_image('/Users/eduardo.aire/Documents/Documentos - EATs iMac/A/01_A_PROYECTOS/01_VIGENTES/2020_PIBA/PIBA_2020_FOTOS/29_PIBA_2020_ESTELASTRIPE.psd', -1140, -10, 270, 100) #Marks, guides and comments #fill(0, 0, 0, 0.1) #rect(mLeft, mBottom, page.w - mRight - mLeft, page.h - mTop - mBottom) page.crop_marks() page.grid(6, 3, 0, mTop, mBottom, mLeft, mRight, False) #Reverso page = Canvas(240, 150, 0, 8) page.color(255, 255, 255, 100) page.bg_square() #Logo imgPath = logo srcWidth, srcHeight = imageSize(imgPath) dstWidth, dstHeight = page.w, page.h factorWidth = dstWidth / srcWidth factorHeight = dstHeight / srcHeight with savedState(): scale(1) rotate(-90) translate(-150, 0) image(imgPath, (0,0)) #Marks, guides and comments #fill(0, 0, 0, 0.1) #rect(mLeft, mBottom, page.w - mRight - mLeft, page.h - mTop - mBottom) page.crop_marks() page.grid(6, 3, 0, mTop, mBottom, mLeft, mRight, False) saveImage('~/Desktop/PIBA_2020_GAFETES_{name}_{number:0>2}.pdf'.format(name = strip_accents(gafetes[gf].upper().replace(" ", "_")), number = str(num))) newDrawing() #gafete(6) for i in range(len(gafetes)+1): num=1 for j in range(copias[i - 1]): gafete(i - 1) num += 1
    • eduairet

      SOLVED Making a loop to save multiple GIFs
      Tutorials • • eduairet  

      9
      0
      Votes
      9
      Posts
      135
      Views

      charlielemaignan

      Hello @frederik ! Thank you! it works for me May I add those few lines found on this other tutorial about "EaseInOut" function. def easeInOut(factor): assert 0 <= factor <= 1 return (1 - cos(factor * pi)) / 2 It will add a new graph with easeInOut. It is working well with your previous lines. Thank you for your help ! Be safe.
    • eduairet

      SOLVED Variable portrait
      Tutorials • variable fonts image • • eduairet  

      4
      0
      Votes
      4
      Posts
      251
      Views

      eduairet

      import string import random # path to the image path = u"https://yourimage.jpg" # get the size of the image print(imageSize("https://yourimage.jpg")) # w, h = imageSize(path) s = letter size w = 400 h = 400 s = 10 # Set the characters you need chars = 'HOLAhola' print (random.choice(chars)) # Get colors pix_cols = {} for x in range(0, w, s): for y in range(0, h, s): pix_cols[(x, y)] = imagePixelColor(path, (x, y)) # Variable font to use """ FontName wdth {'name': 'Width', 'minValue': 100.0, 'maxValue': 800.0, 'defaultValue': 100.0} wght {'name': 'Weight', 'minValue': 150.0, 'maxValue': 800.0, 'defaultValue': 150.0} slnt {'name': 'Slant', 'minValue': 0.0, 'maxValue': 14.0, 'defaultValue': 0.0} """ min_val_wdth = listFontVariations('FontName')['wdth']['minValue'] max_val_wdth = listFontVariations('FontName')['wdth']['maxValue'] min_val_wght = listFontVariations('FontName')['wght']['minValue'] max_val_wght = listFontVariations('FontName')['wght']['maxValue'] min_val_slnt = listFontVariations('FontName')['slnt']['minValue'] max_val_slnt = listFontVariations('FontName')['slnt']['maxValue'] def ranLetters(): # loop over the width of the image newPage(w, h) fill(1) rect(0, 0, w, h) for x in range(0, w, s): # loop of the height of the image for y in range(0, h, s): color = pix_cols[(x, y)] if color: txt = random.choice(chars) font("FontName") fontSize(s) fontVariations(wdth = randint(min_val_wdth, max_val_wdth), wght = randint(min_val_wght, max_val_wght)) r, g, b, a = color # set the color fill(r, g, b, a) # draw some text text(txt, (x, y), align='center') for i in range(5): ranLetters() saveImage("~/Desktop/name.gif", imageResolution=144)
    • eduairet

      SOLVED Radial animation
      Tutorials • animation • • eduairet  

      5
      0
      Votes
      5
      Posts
      454
      Views

      eduairet

      @gferreira wow, this is huge!!! thank you again
    • eduairet

      SOLVED Output text
      Tutorials • text formatting • • eduairet  

      9
      0
      Votes
      9
      Posts
      486
      Views

      eduairet

      @gferreira thanks, it worked, I'm coming with some new exercises. Cheers.
    • eduairet

      SOLVED Grid
      Tutorials • grid layout • • eduairet  

      3
      0
      Votes
      3
      Posts
      319
      Views

      eduairet

      @gferreira said in Grid: w = (width() - gutter * (cols + 1)) / cols h = (height() - gutter * (rows + 1)) / rows Thank you very much, it worked way much better, I also tried to add a margin feature that worked well so now I can design over the grid size(1000, 1000) cols = 3 rows = 3 gutter = 12 #Margin mTop = 10 - gutter mBottom = 20 - gutter mLeft = 10 - gutter mRight = 10 - gutter w = (width() - gutter * (cols + 1)) / cols - ((mRight + mLeft) / cols) h = (height() - gutter * (rows + 1)) / rows - ((mTop + mBottom) / rows) fill(None) strokeWidth(1) stroke(0, 1, 1) for col in range(cols): for row in range(rows): x = gutter + col * (w + gutter) y = gutter + row * (h + gutter) rect(x + mLeft, y + mBottom, w, h)