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

      Script to Standalone app
      Code snippets • open document py2app variable • 19 Apr 2022, 04:50 • eduairet   20 May 2022, 08:36

      14
      0
      Votes
      14
      Posts
      36
      Views

      imik 20 May 2022, 08:36

      The hint with __file__ was just what I needed and got me on the right track. Using os.path.join(os.path.dirname(__file__), 'resource', 'font.otf') within the main.py now gives me the ability to pull content from the resource directory. Perfect! Thank you so much @frederik, as always
    • eduairet

      Chess board in one loop
      General Discussion • chessboard coding challenge no conditionals one loop • 30 Jul 2021, 04:06 • eduairet   21 Feb 2022, 10:16

      10
      0
      Votes
      10
      Posts
      45
      Views

      AndiCrew 21 Feb 2022, 10:16

      @eduairet It was fun. It looks like there will be more challenges ahead.
    • eduairet

      Gradient rings from Python for Designers tutorial
      Tutorials • gradient circles python for designers • 11 Jan 2021, 20:06 • eduairet   18 Jan 2021, 19:42

      3
      0
      Votes
      3
      Posts
      32
      Views

      eduairet 18 Jan 2021, 19:42

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

      Vertical Align
      Feature Requests • 22 Dec 2020, 17:43 • eduairet   1 Jun 2022, 20:23

      4
      3
      Votes
      4
      Posts
      29
      Views

      frederik 1 Jun 2022, 20:23

      and the resulting image
    • eduairet

      Loop image generation breaks at index 16
      General Discussion • batch csv custom postcards txt • 16 Dec 2020, 02:09 • eduairet   18 Dec 2020, 06:29

      4
      0
      Votes
      4
      Posts
      27
      Views

      eduairet 18 Dec 2020, 06:29

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

      SOLVED QRCodeGenerator(size, message)
      General Discussion • image object • 29 Nov 2020, 03:07 • eduairet   17 Apr 2023, 19:03

      10
      0
      Votes
      10
      Posts
      49
      Views

      frederik 17 Apr 2023, 19:03

      hehe, totally forgot about that one... but I prefer the solution with pyqrcode as it provides a list 0/1
    • eduairet

      UNSOLVED access a specific frame from a gif
      General Discussion • 4 Aug 2020, 01:33 • eduairet   3 Nov 2020, 03:15

      7
      0
      Votes
      7
      Posts
      52
      Views

      eduairet 3 Nov 2020, 03:15

      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 • 17 Jul 2020, 17:26 • eduairet   20 Jul 2020, 19:59

      6
      0
      Votes
      6
      Posts
      43
      Views

      eduairet 20 Jul 2020, 19:59

      @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 • 19 Mar 2020, 23:17 • eduairet   17 Jul 2020, 17:28

      5
      1
      Votes
      5
      Posts
      71
      Views

      eduairet 17 Jul 2020, 17:28

      @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 • 24 Feb 2020, 17:03 • eduairet   28 Feb 2020, 16:24

      5
      0
      Votes
      5
      Posts
      30
      Views

      eduairet 28 Feb 2020, 16:24

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

      SOLVED Identify when a word breaks
      General Discussion • text formatting • 7 Feb 2020, 19:19 • eduairet   17 Feb 2020, 23:16

      3
      0
      Votes
      3
      Posts
      82
      Views

      eduairet 17 Feb 2020, 23:16

      @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 • 21 Jan 2020, 19:32 • eduairet   29 Mar 2020, 18:45

      9
      0
      Votes
      9
      Posts
      148
      Views

      charlielemaignan 29 Mar 2020, 18:45

      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 • 31 Oct 2019, 07:33 • eduairet   1 Nov 2019, 18:12

      4
      0
      Votes
      4
      Posts
      254
      Views

      eduairet 1 Nov 2019, 18:12

      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 • 4 Oct 2019, 03:50 • eduairet   16 Oct 2019, 02:18

      5
      0
      Votes
      5
      Posts
      461
      Views

      eduairet 16 Oct 2019, 02:18

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

      SOLVED Output text
      Tutorials • text formatting • 30 Aug 2019, 03:19 • eduairet   24 Sept 2019, 23:13

      9
      0
      Votes
      9
      Posts
      500
      Views

      eduairet 24 Sept 2019, 23:13

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

      SOLVED Grid
      Tutorials • grid layout • 22 Aug 2019, 04:15 • eduairet   22 Aug 2019, 23:46

      3
      0
      Votes
      3
      Posts
      327
      Views

      eduairet 22 Aug 2019, 23:46

      @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)
    Drawing With Python