#Turning image into a spiral (canvas)

70 messages · Page 1 of 1 (latest)

meager finch
#

Instead of filling the cells draw a centered line in each cell with variable thickness

blissful anchor
blissful anchor
meager finch
#

Ok... you might need to copy your canvas but with a cell-size of 1x1 then each line-center would be at px 3 + n * 5

blissful anchor
#

cell size is not 1x1

#

its 5x5

meager finch
#

To get the center you need to split the 5x5 cells, I'd say

blissful anchor
#

🤔

#

@ ChooKing

meager finch
#

As I have no idea how you calc in your canvas, assuming you use a variable "cellSize" and row/colls... just go to the cell and then - 3 to draw at the center of that cell. Can't explain petter

obtuse condor
#

Disregard my question. I just realized that you want to center it.

meager finch
#

I assume I didn't get task.
I had thought it would be about drawing a line and give this line a thickness relative to the pixel's darkness. So I thought of drawing a lune in each cell centered around the middle px, so 3

obtuse condor
#

There is a critical question not answered by the instructions. What color goes in the empty areas that have a thickness less than 5?

#

I examined the spiral image and I think that I understand the problem now. What you need to do is a spiral iteration of 5x5 blocks. Replace each block with a black rectangle on top of a 5x5 white rectangle. The black rectangle's dimensions depend on the direction of iteration in addition to the darkness of the cell. If you are iterating horizontally, then the black rectangle always has a width of 5 but the height depends on the darkness. If you are iterating vertically, then the black rectangle always has a height of 5 but the width depends on the darkness.

meager finch
#

Aaah... so it's not about drawing a centered line with adjusted thickness and the provided images group shows how it ~should~ look finally!

blissful anchor
blissful anchor
obtuse condor
blissful anchor
blissful anchor
#

(sorry for late replies)

obtuse condor
# blissful anchor

That actually makes things easier. You don't have to calculate the center.

blissful anchor
#

i dont understand. when i do line.width = double, wont it increase in both ways?

obtuse condor
blissful anchor
#

or both up AND down

obtuse condor
blissful anchor
#

you cant do this with a single black rectangle

blissful anchor
#

whenever it goes from up to right

#

changes from increasing upwards to right

obtuse condor
obtuse condor
blissful anchor
#

😩

obtuse condor
blissful anchor
#

i wish i knew

obtuse condor
blissful anchor
#

one of the extra requirements (for bonus points) is to make it so it is circular

#

and not rectangular

#

with this method it would be impossible to do it

#

i was thinking about drawing a spiral line and 5 pixels at a time checking to which cell it corresponds to

#

and based on that increasing the width

#

but i dont know how to actually align it with the cells

obtuse condor
blissful anchor
obtuse condor
#

A segment of a spiral is not the same as a segment of a circle. It's mathematically a much more complex shape.

blissful anchor
obtuse condor
blissful anchor
#

okay

meager finch
#

Hmmm... the images you shared, the group with the 4, was that how it is expected to look?
Then I think you might just draw a rect per cell - like ChooKing suggested - and vary the heigth/width corresponding to the darkness you calculated in the task before.
You'd need to calculate with the real pixels inside the cell

blissful anchor
meager finch
#

I now made a spiral with random thickness per cell but all centered, I think It would need to shift the lines depending on thickness so the alway have the edge on the same level (top, right, bottom or left)
That's really an interesting challenge 😅
I'll have another look to morrow to fox this

blissful anchor
#

looks like pipes

blissful anchor
#

Okay did it fully now

#

what a pain in the a$$

meager finch
#

great!!!! Congratulations!!!
Yes, it really is. TBH I HATE canvas 🙈 😅
The only thing I see with your spiral is that the corners don't match accurately. You might need to adjust the coords by 3 px in two direction-turns

meager finch
#

oh and the lines right from center seem to be all "black"

blissful anchor
#

here is a random image

#

and here is my version

meager finch
#

Nice!!! You really made it. Congrats again!!! 🥳