how can this work

@Ray_Spahn What do you mean by “curve in a different direction” .

@dave1707 I think they mean, can you make it change direction (smoothly?) partway into the line?

@ dave 1707 I meant that having the lines curve Ike a snake but also grow from a certain point and have a tail
Like this picture

I’m sure it can be done, but it will take more time than I want to put into it.

@ dave1707 thank you so much for all you have done especially today
Have a great day and again thank you

@Ray_Spahn - Ah now I have a better idea of what you want.
To be honest I think it’s a fairly complex example, especially if your a new comer to Codea and or programming.

Here’s what I would advise

  1. Get comfortable with the existing line function
  2. Get comfortable with using variables to represent the endpoint of a line
  3. Update those variables so that you can see the line grow and shrink (just keep it to either horizontal or vertical for now)
  4. Brush up on your maths so you can make a straight line grow and shrink at any given angle (see the sin / cos examples above)
  5. Brush up on tables so you can have lots of lines all growing and shrinking separately
  6. Go back to the maths to arrange these lines in a circle

and your pretty much done.

THIS is EXACTLY what I was talking about when I said start with a sketch (or an example video) or an idea of what you want to do and then moving forward step by step

I agree, one step at a time

Right now you are biting off too much

@Ray_Spahn Still not sure if this is what you’re after.


function setup()

function draw()
    background(255, 184, 0, 255)
    if count>30 then
        for z=1,360 do
    stroke(92, 0, 255, 255)    
    for z=1,360 do
    fill(0, 255, 246, 255)
    stroke(255, 0, 166, 255)

@dave1707 thanks so much for trying again and sticking with working this idea but i was talking about the the link i pasted the lines in the video where the lines grow like you sent me but where they curve and turn into different directions

@dave1707 i was watching the video and thought of how to code that and that is why i am so interestedd in this idea

How about this? (Long press on “new project” and select “paste into project”)

--# Main
-- Circular Spectrum

function setup()
    spec = Spectrum(WIDTH / 2, HEIGHT / 2, WIDTH / 4, WIDTH / 16, true, true)
    spec2 = Spectrum(WIDTH / 2, HEIGHT / 2, WIDTH / 4, WIDTH / 8, false, false)

function draw()
    for i = 1, 250 do
        spec.length[i] = math.max(0, noise(i / 30, i / 30 * math.pi, ElapsedTime * 2) * spec.outer)
        spec2.length[i] = math.max(0, noise(i / 15, i / 15 * math.pi, ElapsedTime * 4) * spec2.outer + spec2.outer / 2)
    fill(0, 0)
    ellipse(WIDTH / 2, HEIGHT / 2, WIDTH / 2 + 7.5, HEIGHT / 2 + 7.5)
    sprite("Cargo Bot:Codea Icon", WIDTH / 2, HEIGHT / 2, WIDTH / 4 * math.cos(ElapsedTime / math.pi), HEIGHT / 4)

--# Spectrum
Spectrum = class()

function Spectrum:init(x, y, inner, outer, continuous, invert)
    self.x, self.y = x, y
    self.inner, self.outer = inner, outer
    self.continuous, self.invert = continuous, invert
    self.length = {}
    for i = 1, 2 do
        self.length[i] = 0

function Spectrum:generateCache()
    self.angleCache = {}
    for i = 1, #self.length - 1 do
        local prog1 = (i - 1) / (#self.length)
        local prog2 = (i) / (#self.length)
        local rad1 = math.pi * 2 * prog1
        local rad2 = math.pi * 2 * prog2
        local sin1 = math.sin(rad1)
        local cos1 = math.cos(rad1)
        local sin2 = math.sin(rad2)
        local cos2 = math.cos(rad2)
        self.angleCache[i] = {s1 = sin1, c1 = cos1, s2 = sin2, c2 = cos2}

function Spectrum:draw()
    if #self.length ~= #self.angleCache then
    local mult = 1
    if self.invert then
        mult = -1
    for i = 1, #self.length - 1 do
        local sin1 = self.angleCache[i].s1
        local cos1 = self.angleCache[i].c1
        local sin2 = self.angleCache[i].s2
        local cos2 = self.angleCache[i].c2
        if self.continuous then
            line(sin1 * self.inner + sin1 * self.length[i] * mult + self.x, cos1 * self.inner + cos1 * self.length[i] * mult + self.y, sin2 * self.inner + sin2 * self.length[i + 1] * mult + self.x, cos2 * self.inner + cos2 * self.length[i + 1] * mult + self.y)
            line(sin1 * self.inner + self.x, cos1 * self.inner + self.y, sin1 * self.inner + sin1 * self.length[i] * mult + self.x, cos1 * self.inner + cos1 * self.length[i] * mult + self.y)
    local rad1 = math.pi * 2 * ((#self.length - 1) / #self.length)
    local rad2 = 0
    local sin1 = self.angleCache[#self.length - 1].s2
    local cos1 = self.angleCache[#self.length - 1].c2
    local sin2 = self.angleCache[1].s1
    local cos2 = self.angleCache[1].c1
    if self.continuous then
        line(sin1 * self.inner + sin1 * self.length[#self.length] * mult + self.x, cos1 * self.inner + cos1 * self.length[#self.length] * mult + self.y, sin2 * self.inner + sin2 * self.length[1] * mult + self.x, cos2 * self.inner + cos2 * self.length[1] * mult + self.y)
        line(sin1 * self.inner + self.x, cos1 * self.inner + self.y, sin1 * self.inner + sin1 * self.length[#self.length] * mult + self.x, cos1 * self.inner + cos1 * self.length[#self.length] * mult + self.y)

The class is called Spectrum(). The first two parameters are the X and Y coordinates, the third is the inner length (the distance each line starts from the center), the fourth is the outer length (the distance each line ends at most from the center), the fifth is whether it’s continuous (whether it should be one curved line, or a bunch of straight lines), and the sixth is whether it’s inverted (false = higher line length is further from the center, true = high line length is closer to the center).

@SkyTheCoder i pasted a wrong pictures url this should work and i couldnt figure out why people were coding the wrong ting any way this should work ill check it after i post it

  • thank you again and the code you sent me was really good thank you for your effort

@Ray_Spahn That sure is different from what I thought you were asking in your first post.

@dave1707 i know i did not check the url because i thought it was the right one sorry about that

@Ray_Spahn No problem about the url. It just gave me something else to try. I don’t like the way my latest code works because it always starts over at 1 so there’s sometimes a big difference between the current “1” and the previous “360” value. It’s not a smooth transition.

@Ray_Spahn I like the effect that is being shown in the second link. I think that can be done using Bézier curves in 3D with rotation. I’m not sure if it would look the same and how fast it would run. It’s also something that I’m not going to try anytime soon.

@Ray_Spahn I very highly doubt that effect would be possible in realtime at 60 FPS.

You might be interested in the “Liquid line flow” programs that were posted a while back.

@LoopSpace Thanks for the links. There are some interesting examples in the older discussions. Too bad there isn’t an easy way to find them.

@LoopSpace But in 3D… Where do you even start, with 3D volumetric particle systems?