#patterngenerator
Explore tagged Tumblr posts
Text
#AI#LLM#GPT#MIT News - Artificial intelligence#Rachel Gordon | MIT CSAIL#From physics to generative AI: An AI model for advanced pattern generation
0 notes
Text
We now have patterngenerator here too
https://tumblr.com/randompatterngenerator
0 notes
Photo

From my friend, the Random Pattern Generator. #Random #Pattern #Generator #RandomPatternGenerator #RandomPattern #PatternGenerator #RandomGenerator #MyFriend #Friendship https://www.instagram.com/p/CRYL4UynY1n/?utm_medium=tumblr
#random#pattern#generator#randompatterngenerator#randompattern#patterngenerator#randomgenerator#myfriend#friendship
0 notes
Photo
The background pattern for this page was made using Patternify. The design is based on the Rosepath weaving structure. You can copy the CSS code or download the PNG file for the pattern here.
0 notes
Photo

It's been awhile since I tinkered with Mirror Lab, but I took some chunk of a piece I was working on and started to run it through a few iterations and here's where it is so far. #art #patterngeneration #mandala (at SoFA District) https://www.instagram.com/p/CUCUqBRLcY4/?utm_medium=tumblr
0 notes
Photo

Risographie, Patterngenerator – Krebs, 2016 Risographie Kunstdruck, 297 * 420 mm Analogisierung von generierten Rapportvariationen, die Variationstechniken von Fugen adaptieren. Astrid Hesse [email protected]
0 notes
Text
Refactoring the knitting pattern generator
Something was bothering me about my knitting pattern generator this morning. I was brainstorming about how to write the crown decreases and was struggling with my conditional statements.
Mostly, I was troubled by this part:
def cast_on @gauge_inch.to_i * @circumference.to_i end def ribbing_type # Can this be cleaner? if cast_on % 4 == 0 return "your choice of: (a) k2, p2, (b) k3, p1, or (c) k1, p1" elsif cast_on % 2 == 0 return "k1, p1" elsif cast_on % 3 == 0 return "k2, p1" elsif cast_on % 5 == 0 return "k3, p2" else # Change this to return custom information about custom ribbing return "OH NEWTS! I couldn't come up with a multiple of 2, 3, 4, or 5; you must come up with your own custom" end end
The problem I was running into here was that I have conditional statements set up when I'm calculating the ribbing type, but I need to access them again later when I do the crown decreases.
The conditional statement shouldn't be buried in a method that tells you which type of ribbing to knit the brim in. Instead of hiding it away at the middle of the code, I separated the methods based on the multiples and put them into the cast_on methods. This makes it easier to add in more multiples or additional conditions later.
You'll see in the code below that I've removed the ribbing_type method and objects entirely. There are two reasons for this:
I want to focus on the functionality of using multiple methods to define the cast_on variable.
I'm working on making the cast_on methods work with the currently empty crown_math method.
In total and complete honesty, I couldn't figure out how to incorporate ribbing_type (or crown_math) into these methods. More study here is clearly needed.
What I'm most proud of so far is the cast_on_round method (highlighted), which takes any number that is not a multiple of 10, 9, or 8, makes it so, and selects the smallest of those as cast_on.
ribbing_needle is desperately in need some refactoring after I become more comfortable with array docs and enumerables. I may even change this to a hash.
Here's the code so far:
class Hat attr_accessor :gauge_inch, :gauge_row, :circumference, :needle attr_reader :cast_on # Add list of private/public methods def initialize @gauge_inch = gauge_inch @gauge_row = gauge_row @circumference = circumference @needle = needle end def ribbing_needle # This won't work for extreme needle sizes or very small needles. # Consider changing this to a hash with key value pairs assigned by me? @needle_array = ["1.75mm", "2mm", "2.25mm", "2.5mm", "2.75mm", "3mm", "3.25mm", "3.5mm", "3.75mm", "4mm", "4.25mm", "4.5mm", "5mm", "5.5mm", "6mm", "6.5mm", "7mm", "7.5mm", "8mm", "9mm", "10mm", "12.75mm", "15mm", "19mm", "25mm"] @ribbing_needle_index = @needle_array.index("#{@needle.to_s}mm") - 2 @ribbing_needle = @needle_array.values_at(@ribbing_needle_index) end def cast_on @cast_on = @gauge_inch.to_i * @circumference.to_i end def cast_on_10 return @cast_on if @cast_on % 10 == 0 end def cast_on_9 return @cast_on if @cast_on % 9 == 0 end def cast_on_8 return @cast_on if @cast_on % 8 == 0 end def cast_on_round if @cast_on % 10 != 0 && @cast_on % 9 != 0 && @cast_on % 8 != 0 round_10 = @cast_on + 10 - (@cast_on % 10) round_9 = @cast_on + 9 - (@cast_on % 9) round_8 = @cast_on + 8 - (@cast_on % 8) round_ary = [round_10, round_9, round_8] @cast_on = round_ary.min # Pulling the smallest rounded multiple end end # Private def ribbing_rows @gauge_row.to_i * 2 # 2 inches for all sizes end # Private def height # Size tables baby = [15, 15.5, 16, 16.5, 17, 17.5] child = [18, 18.5, 19, 19.5, 20, 20.5] adult = [21, 21.5, 22, 22.5, 23, 23.5, 24, 24.5, 25, 25.5, 26, 26.5] # Work until hat measures from crown return "1 inch" if baby.include?(circumference.to_i) return "1.5 inches" if child.include?(circumference.to_i) return "2 inches" if adult.include?(circumference.to_i) end # Private def crown_math # math for crown decreases end # Public def pattern # Grab user input puts "What size mm needle are you using? Don't use decimals unless needed." @needle = gets.chomp puts "How many stitches do you have per inch?" @gauge_inch = gets.chomp puts "How many rows do you have per inch?" @gauge_row = gets.chomp puts "What is the circumference of the head you want to wear this hat?" puts "Please use inches, rounded to the nearest half inch (ex: 20, 16.5)." puts "This only works for 15 inches up to 26.5 inches." @circumference = gets.chomp # Legend table abbrevs = [ "k: knit", "p: purl", "m: marker", "sl: slip", "pm: place marker", "slm: slip marker", "k2tog: knit two together", "co: cast on", "bo: bind off", "st/s: stitch/es", "rpt/s: repeat/s" ] # Pattern print out puts "\n- - - - - - - - - - - - - - - - - - - - - - -" puts "\nA custom knitting pattern. Hooray!" puts "This pattern requires either a 16 inch circular needle, or a set of DPNs. Your choice." puts "\nDid you get an error? Consult the error legend at the bottom." puts "\n- - - - - - - - - - - - - - - - - - - - - - -" puts "\nLegend:" puts abbrevs.sort puts "\n- - - - - - - - - - - - - - - - - - - - - - -" puts "\nDirections:" puts "Using #{ribbing_needle}, co #{cast_on} sts, pm and join for knitting in the round." puts "Work in ribbing or edging of your choice for approximately 2 inches (#{ribbing_rows} rows)." puts "Change to #{@needle} mm needle. Work in stockinette st (k all sts, all rows) until hat measures #{height} from crown." puts "\n- - - - - - - - - - - - - - - - - - - - - - -" end end test_hat = Hat.new test_hat.pattern
Still not perfect, but getting closer to being able to add in the crown decreases! It's likely that I'll write the crown_math on its own instead of forcing it into the class immediately. Kind of testing while writing... right?
3 notes
·
View notes
Text
class Hat
I'm still tinkering with the knitting pattern generator, and I'm getting a lot closer to making it more functional.
I forced myself to write it up as a class, something that was a little intimidating given all of the working parts.
I have not incorporated the crown decreases into the program yet. I'm trying to find a clever way to have the program generate all of the rows for me, instead of me writing out the rows and inserting the variables for stitch count and decreases. The goal is to remove everything repetitive.
Here's the updated draft:
class Hat attr_accessor :gauge_inch, :gauge_row, :circumference, :needle # Add list of private/public methods def initialize @gauge_inch = gauge_inch @gauge_row = gauge_row @circumference = circumference @needle = needle end # Private def cast_on @gauge_inch.to_i * @circumference.to_i end # Private def ribbing_type # Can this be cleaner? if cast_on % 4 == 0 return "your choice of: (a) k2, p2, (b) k3, p1, or (c) k1, p1" elsif cast_on % 2 == 0 return "k1, p1" elsif cast_on % 3 == 0 return "k2, p1" elsif cast_on % 5 == 0 return "k3, p2" else # Change this to return custom information about custom ribbing return "OH NEWTS! I couldn't come up with a multiple of 2, 3, 4, or 5; you must come up with your own custom" end end # Private def ribbing_rows @gauge_row.to_i * 2 # 2 inches for all sizes end # Private def height # Size tables baby = [15, 15.5, 16, 16.5, 17, 17.5] child = [18, 18.5, 19, 19.5, 20, 20.5] adult = [21, 21.5, 22, 22.5, 23, 23.5, 24, 24.5, 25, 25.5, 26, 26.5] # Work until hat measures from crown return "1 inch" if baby.include?(circumference.to_i) return "1.5 inches" if child.include?(circumference.to_i) @height = "2 inches" if adult.include?(circumference.to_i) end # Private def crown_math # math for crown decreases end # Public? def pattern # Grab user input puts "What size mm needle are you using? Don't use decimals unless needed." @needle = gets.chomp puts "How many stitches do you have per inch?" @gauge_inch = gets.chomp puts "How many rows do you have per inch?" @gauge_row = gets.chomp puts "What is the circumference of the head you want to wear this hat?" puts "Please use inches, rounded to the nearest half inch (ex: 20, 16.5)." puts "This only works for 15 inches up to 26.5 inches." @circumference = gets.chomp # Legend table abbrevs = [ "k: knit", "p: purl", "m: marker", "sl: slip", "pm: place marker", "slm: slip marker", "k2tog: knit two together", "ssk: slip, slip, knit two slipped stitches together", "co: cast on", "bo: bind off", "st/s: stitch/es", "rpt/s: repeat/s" ] # Error table errors = ["size: circumference not a valid number, height cannot be calculated"] # Pattern print out puts "\n- - - - - - - - - - - - - - - - - - - - - - -" puts "\nA custom knitting pattern. Hooray!" puts "This pattern requires either a 16 inch circular needle, or a set of DPNs. Your choice." puts "\nDid you get an error? Consult the error legend at the bottom." puts "\n- - - - - - - - - - - - - - - - - - - - - - -" puts "\nLegend:" puts abbrevs.sort puts "\n- - - - - - - - - - - - - - - - - - - - - - -" puts "\nDirections:" puts "Using one needle size smaller than required for gauge, co #{cast_on} sts, pm and join for knitting in the round." puts "Work in #{ribbing_type} ribbing for approximately 2 inches (#{ribbing_rows} rows)." puts "Change to #{needle} mm needle. Work in stockinette st (k all sts, all rows) until hat measures #{height} from crown." puts "\n- - - - - - - - - - - - - - - - - - - - - - -" puts "\nError legend:" puts errors.sort end end test_hat = Hat.new test_hat.pattern
3 notes
·
View notes
Text
Knitting pattern generator: crown decreases
I've been deliberating over this for awhile. I've written a few drafts of my knitting pattern generator, and every time I get to the crown decreases I stop working because I'm not sure how to handle it. I think part of the problem there is I approach the crown decreases after I've been coding for a few hours, so my brain is stuck in code mode, rather than knitting mode.
Well, I haven't been coding for very long today, so my brain is relatively fresh. I even knit a few rows on a shawl that I'm working on before sitting down to think about this.
When I write a hat pattern and it's time to approach the crown decreases, I map out a few things:
What are the multiples of the number of stitches on the needle? For the sake of the knitting pattern generator, this is the same as the cast on.
Across how many inches/rows do I need to decrease? Baby hats decrease across 1 inch, child hats across 1.5 inches, and adult hats across 2 inches.
How do I want to decrease? Spiral? Box? Staggered spiral? I will likely stick with a simple spiral since it's easier.
How many stitches would I decrease down to before cinching? Probably 6-10, depending on the multiple.
Once I have all of that information, I write up a sort of template:
Row 1: *k x, k2tog, rpt from * to end of round (xx sts).
Row 2: k all sts.
Write out directions to repeat Rows 1-2 until knitter works *k2, k2tog. Work one more plain row, then work last two rows as:
Next row: (k1, k2tog) yy tmes (xx sts).
Next row: k2tog yy times (xx sts).
Break yarn and cinch remaining stitches together.
So the cardinal rule of Ruby (and programming in general) is Don't Repeat Yourself.
There is a lot of repetition in knitting patterns. Seriously, there's a ton. The rows that follow 1-2 are all the same setup, the only thing that changes is x and xx. x decreases by one with each row, whereas xx decreases based on the multiple, which determines the number of stitches decreased on each row.
My program will then need to:
Get the cast on information. It already has this. Woohoo!
Determine the best multiple to work decreases based on: (a) the number of rows per inch and how many rows you have to work decreases, (b) how many stitches it should get down to, and (c) which decrease method I want to use (probably set this to spiral by default).
Generate row-by-row instructions up until the user has 1 stitch remaining between each decrease. Omit the plain knit row and provide the last 2 rows of instructions.
Provide a stitch count for each decrease row.
Some things are easy. I already know how to:
Do the basic math. This will give me stitch counts for each row and it will get the multiple.
But I don't know how to:
Pick the best stitch multiple based on the number of rows available to work.
I think I don't know how to do that in a pattern generator because it has a lot to do with the overall aesthetic of the hat, and how I want it to look. Stepping back and thinking more abstractly, this is not a pattern that is lovingly hand designed and perfected by me, but rather, it's a quick on-the-go pattern generator that provides users with a general template from which to build.
Thinking about it in theses terms, I can set up the program to only allow for optimal multiples that make decreasing easy.
For example, instead of determining if the user's cast on is divisible by 4, I would instead check for a multiple of 8. Instead of 3, check for a multiple of 9. This step built into the program earlier on makes it easier to generate the crown decreases later because the math has already been done.
I think I will have to use a loop of sorts to generate the row by row instructions. I'll likely use an until loop to repeat the code since I will want it to stop when x is 1.
I think I got this.
0 notes