Skip to main content

Timeline for Collatz's ice cream cone factory

Current License: CC BY-SA 4.0

7 events
when toggle format what by license comment
Jun 13, 2021 at 10:20 comment added Kaiido Alright, then if taking their input inside an Array is also legal, I guess it's 140: (x,C)=>{c=C.getContext`2d`;while((z=x[0])-1)x.unshift(z%2?3*z+1:z/2),r=Math.max(...x)/99,x.map((a,i)=>c.lineTo(a/r,99-x[i-1]/r));c.stroke()} with x being the integer input wrapped in an Array, and C an HTML canvas.
Jun 13, 2021 at 9:23 comment added Neil @Kaiido There are two rules at play here: 1) functions that produce output may do so by writing to an (optionally additional) input rather than producing a return value 2) an image object is an acceptable i/o format (see the list of acceptable graphical i/o formats linked in the question).
Jun 12, 2021 at 23:49 comment added Neil (A typed array of RGB values would be OK though; that counts as an image.)
Jun 12, 2021 at 23:48 comment added Neil @Kaiido I/O needs to be an image. A 2d context isn't itself an image.
Jun 12, 2021 at 16:40 comment added Neil A snippet may not be valid in which case your best bet may be a function which takes a and a canvas element as input and outputs by drawing on the passed-in canvas.
Jun 12, 2021 at 9:08 comment added Kaiido -14: c.beginPath(); is useless here, a path is started automatically at context's init. Now, it's unclear how your script is embedded in the HTML here, so take a +8 for <script> after the canvas opening tag and you end with 160. (Note that in the snippet you'd also need a </script> end tag, but I think it's not necessary if there is a true EOF, I'm on a phone rn and can't test myself.)
Jun 12, 2021 at 3:21 history answered Hannesh CC BY-SA 4.0