Tumgik
#Dragon curve
lesbianslovebts · 2 months
Text
Tumblr media
For this project, I took a stage 9 dragon curve and implemented the following rule: for each of the stage 8 fractals contained within the stage 9 fractal, where 4 lines enclose a square, there is 1 bead. I made the background black and then assigned a color to each column. The rainbow is because I am gay, of course. :]
42 notes · View notes
blake447 · 10 months
Text
Strange way of drawing the Dragon Curve
Tumblr media
Alright, so real quick I just want to share potentially the most arcane method of drawing the Dragon Curve I've ever seen, derived and designed by yours truly! As far as I know, this is a novel solution. I know the sequence it generates is known, but I'm not sure if anyone else has used this method before. Its quite elegant if I may say so myself.
Tumblr media
So for those that aren't aware in programming the "<<" and ">>" operators are sometimes known as "bit shifts." Basically what this is doing is starting at some number, adding a power of two, then getting a specific 1 or 0 in the binary representation of that number iteratively, until its searched enough bits to know they aren't going to change anymore.
It has to do with this sequence right here. I've mentioned before, my personal favorite way of generating the dragon curve is to start with the sequence 0, reverse it, add one, roll over once you reach 4, and tack that on to the original sequence. So 0 0 1 0 1 2 1 0 1 2 1 2 3 2 1 0 1 2 1 2 3 2 1 2 3 0 3 2 3 2 1 Well what ends up happening is each time you add one, its like adding one to the reversed part of the newly added sequence. So we can track where all these 1's come from based on when they're added. For example, the 1 we added in the "01" step turns into 0 1 0 1 1 0 0 1 1 0 0 1 1 0 Note from here on out its palindromic, so reversing it no longer has any effect. What we end up with is a repeating pattern of two 1's, then two 0's, starting with half that many 0's. When going from 0 1 0 1 2 1 We're adding 1's to the entire second half, so in this step the 1's propagate to 0 0 1 1 0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0 And again, this is now palindromic. Four 1's, four 0's led by half that many. One of the things I've learned about the dragon curve is just how intrinsically linked it is to binary (and this makes sense when you think of the folding paper method of generating it. Here's an excel spreadsheet demonstrating this in action
Tumblr media
Now here's the fun part. My research was to parallelize this algorithm. One approach is to say "Okay, how can we calculate each term in this sequence without looking at the previous ones." And the answer is to exploit these very predictable patterns. And how do we predict these patterns? Simple, we simply count in binary
Tumblr media
The right most column is useless, but starting at the next one to the left, we see a familiar pattern, almost. Say we want to know what the 5th number in the dragon curve sequence is (0 indexed). To make the sequence only lead with one 0 instead of two, we need to offset by 1, then all we have to do is increase the number by (n + 1) = 5 and take its 2nd least significant bit (1 indexed because english). The 2nd bit of ( 1 + 5 = 6 ) is a 1. For the next iteration we're looking at the 3rd least significant bit. Here we need to offset by 2, and then we increase the number by 5 again and the 3rd significant bit is the one we take. The 3rd bit of (2 + 5 = 7) is another 1 After that we're looking at the 4th least significant bit. We need to offset by 4, then increase the number by 5, and the 4th significant bit will give us our number. The 4th bit of (4 + 5 = 9) is going to be another 1, bringing our total to 3. Here's a visual representation
Tumblr media
This is where the "1 << i" comes in, because that's the same as saying 2^i, which is how we get those offsets of 1, 2, 4, then 8, 16, 32... the "n" in "n + (1 << i)" comes from us offsetting to get the nth term in each sequence Finally the " >> (i + 1) " and "% 2" are to fetch the (i + 1)th bit from the number. After that the increasing size of the leading zero's outpaces our constant offset of the number 5, so we are only going to get 0's from here on out, and we can actually stop, hence the usage of bit length to terminate the loop early.
And if we look at the the 5th element of the sequence (0 indexed) 0 1 2 1 2 3 Funnily enough, in python this brings an actual speed increase (or at least, distributes the cost over the drawing) because of how slow reading and writing to memory is, compared to how math and bit-wise operations are implemented in low level C behind the scenes. Additionally, since there is no reliance on previous work this task can be multi-threaded, or even GPU accelerated if need be. Finally, if you've made it this far, here are a few images of some close ups of dragon curves from my GPU implemented (unrelated to this one entirely) just so that there's something pretty. Enjoy <3
Tumblr media Tumblr media
122 notes · View notes
technician-the · 8 months
Text
Tumblr media
42 notes · View notes
vacuously-true · 3 months
Note
your posts about dragon curves gave me vivid recollections of being a small child folding a strip of paper in half twice, seeing a level 2 curve without realizing it. "ha ha it looks like a truck" ah, memories
🥺 that's so cute
3 notes · View notes
exnihilo-comic · 2 years
Text
Tumblr media
no comic friday: in 2018, i noticed that stickers in the printer at work had perforations for tearing, and that you could make hills and valleys pretty easily. so here's a level 6 dragon curve.
3 notes · View notes
puppetmaster13u · 19 days
Text
Prompt 274
You know what is fun? Baby Ghost Jason. You know what could be even more fun? Ghosts are Dragons. 
Jason? Aware of none of this. 
He was on comms, y’know listening and rolling his eyes at Dickwing, who used his real name, really Dick, he mocks. It’s just a stakeout, nothing new there, honestly boring when he could be blowing something up instead. It should have just been a stakeout. 
Yet there’s something suddenly there, something behind him. Something that causes his hair to stand on end and his comms to spark into static like some sort of horror movie. Something, something with clawed hands with corpse-pale skin tipped in black, stained or dead or something else, tilting his head up and up and up as he’s frozen. 
“A child, out here? Alone?” a voice crackles, hisses, hums, and purrs, somehow all at once, unnatural in its tone. He can’t move, he needs to move, he has to move, but it’s like the space around him has gone cold and dead, like he’s stuck in the Pits once more as claws hold his head and his vision blurs. “Sleep, child. Rest- we’ll be home soon.” 
725 notes · View notes
knifeforsale · 2 years
Photo
Tumblr media
WICKED DRAGON DAGGER | LISTING
2K notes · View notes
Text
Tumblr media
hello genshin impact fandom. i would like you to please engage with the fic in question. also non genshin fandom tbh this is brain chemistry changing. doodle page of freminet to justify my posting
76 notes · View notes
123 notes · View notes
lesbianslovebts · 2 months
Text
I was able to convert a dragon curve into a beading project idea using the square stitch. Basically, if 4 lines of one color enclose a square, then the square will be shaded that same color. Each shaded square represents a bead of that color. If a square is not bound on all 4 sides by one color, then it is the background color. Lastly, any leftover line segments that do not make up a square will be stitched with thread of the appropriate color between the beads. I made up the rough sketch tonight, and tomorrow, I'll post a final drawing of the project plan.
2 notes · View notes
blake447 · 8 months
Text
Tumblr media
Getting my arch install looking nice and pretty. Background is a quaternion julia set, and down below we have my dragon curve code that I've been working on. Finally got polybar installed and working, and customized it lightly. Next I'm thinking a compositor so i can have transparent terminals and stuff if I want
70 notes · View notes
technician-the · 4 months
Text
Tumblr media
animation of my dragon curve fractal. this is fractals numbered 780 through 785.
it starts at iteration 3 (the first that was interesting to look at), and goes to iteration 9 (the last that fully fit in the frame).
4 notes · View notes
Text
131 notes · View notes