Log In  


Cart #simpleheart-0 | 2020-02-13 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
1

1



It should be possible to do this without math:

-- simple heart by dw817
-- (02-13-20)

cls()
circ(54,64,10,8)
circ(74,64,10,8)
rectfill(49,63,79,74,0)
line(49,73,64,88,8)
line(64,88,79,73,8)

Ha ... I saw the math on wolfram :(
Yours is much more concise.


Yes but consider this, @tonetheman. It should be possible to make one that uses only acceleration values to generate curves and be very small code indeed.

Want to try and tackle it ? :)


Ha prob not... I was just happy I got the one I posted working. :) :) :)


It's a good heart shape - parametric equations are fun. :D

Pretty easy to modify the code for other equations, too, looks like.


1

Here it is. Using a table:

heart={0,-1,-1,0,2,0,1,2,1,0,1,1,1,2}

And optional crystal effect that can be turned off. Ah maybe the code is not so small now:
UPDATED (color palette was skewed)

-- crystal heart by dw817
-- (02-13-20)

crystal=4
-- =0 off >=1 step

x=64
y=48
c=1 n=0
cls()

pal={1,13,14,15,14,13,1,2,8,9,10,9,8,2,3,11,10,11,3,1,13,12,7,12,13}

heart={0,-1,-1,0,2,0,1,2,1,0,1,1,1,2}

ax1=heart[1]
ay1=heart[2]

for i=3,#heart,3 do
  ax2=heart[i]
  ay2=heart[i+1]
  d=heart[i+2]
  for j=1,26*d do
    if crystal>0 then
      n+=1
      if n%crystal==1 then
        line(64,48,x,y,pal[c])
        line(63,48,127-x,y,pal[c])
        c+=1
        if (c==26) c=1
      end
    end
    pset(x,y,7)
    pset(127-x,y)
    x+=ax1 y+=ay1
    if (ax1<ax2) ax1+=.02
    if (ax1>ax2) ax1-=.02
    if (ay1<ay2) ay1+=.02
    if (ay1>ay2) ay1-=.02
    ax1=mid(-1,ax1,1)
    ay1=mid(-1,ay1,1)
    repeat
      flip()
    until btn(4)
  end
end

Hold down (O) to see it drawn.


Oh man that is sweeeeet!


Thanks !

But what you're doing is equally interesting, and your heart has a magnificent curve at the bottom. The only time I've ever used SQRT is calculating hit points and stuff based off experience points. Never for drawing. Something for me to learn.

Gold star for your sterling and beautiful work here, @tonetheman.



[Please log in to post a comment]