Does this count as a build?

New Home Forum Things You Have Made Does this count as a build?

This topic contains 565 replies, has 23 voices, and was last updated by  Mark Roland 6 months, 1 week ago.

Viewing 30 posts - 31 through 60 (of 566 total)
  • Author
    Posts
  • #36814

    Ryan
    Keymaster

    The interface would be for people to be able to make there own code. I am imagining it like the MPCNC where every single build is a different size. Having to download and run a program would be intimidating for some.

    I am thinking the non cnc crowd. My close friends, the ones who are kind of oblivious to what I do, saw this and immediately took interest and got excited. These are the one I help with tech support for so I was thinking how could I make them one and let them use it without calling me everyday for help. They see this as amazing…to me it is half of a cnc machine and it is the simple half…to them it is magic.

    #36816

    Ryan
    Keymaster

    Going back to your crazy weekend build project, I don’t understand at this stage how you get from nice gcode to the tilt instructions? Did I miss something reading the thread?

    tilt?

    #36817

    James Donnelly
    Participant

    Sorry for skim reading about the Web GUI reasoning, I was at work.

    A web GUI has one advantage in that you will find more able people to help should you share the project.

    A desktop application might be easier to distribute as a simple installer, and won’t depend on a web server to run.

    Also you’ll be able to easily talk to the machine via the USB/COM port of the controller board if you write a proper application.

    Just speaking from my experience. Both will work fine. I’d be more than happy to lend a hand with the development, but it sounds like you’re keen yourself, and Jeff’s ahead of me in the queue 🙂

    #36818

    Ryan
    Keymaster

    No way, group effort!

    I feel pretty excited about this so maybe I should focus on the hardware first. I have a bunch of stuff coming next day from amazon. Monday’s for me are catching on on shipping from the weekend, then after I get that done I will start sketching some new parts. You guys both seem way more qualified than me, but I will check out the links you put up in more detail after I get the orders out. If it clicks for me and seems easy I will give it a try.

    #36819

    James Donnelly
    Participant

    The interface would be for people to be able to make there own code. I am imagining it like the MPCNC where every single build is a different size. Having to download and run a program would be intimidating for some.

    I am thinking the non cnc crowd. My close friends, the ones who are kind of oblivious to what I do, saw this and immediately took interest and got excited. These are the one I help with tech support for so I was thinking how could I make them one and let them use it without calling me everyday for help. They see this as amazing…to me it is half of a cnc machine and it is the simple half…to them it is magic.

    Ah, makes more sense now, OK.

    So if you’re talking about an integrated system you install for people, you would build in a raspberry PI or similar and get that to run the web interface, right?

    #36824

    Ryan
    Keymaster

    No, that could be optional. Just output gcode onto a sd for now and run it on the lcd screen. Baby steps.

    There are a few way to do fully automated.

    I am thinking just an easy way to set a table size X and Y dimensions, then have some drop downs or something to play with (squares, circles, triangles, flowers, hearts whatever). If we could get to the point to add letters…..would be amazing.

    The hardware options are already coming to me, I think I can get this pretty simplified. I think sticking with conduit is still best for now..

    #36843

    James Donnelly
    Participant

    Right, so now I think I finally get it.

    You’re thinking of a central web page, that you would need to arrange hosting for?

    This is very easy to do with a Python program, but if it is the case, then I would 100% say do it all in JavaScript as per your first suggestion.

    HTML5 has SVG support, and it’s definitely not an issue to convert to Gcode in the browser. This way there is no server side component, so you can put a flat JavaScript driven page on your website. As you said, like the calculator.

    I found a couple of things that would probably help you along:

    https://github.com/forresto/turtle-svg

    This one is Node, meaning it’s written for server side, but the code will run for sure in the browser with a little migration:

    https://github.com/em/svg2gcode

    #36844

    James Donnelly
    Participant

    Perhaps more useful:

    Open source Turtle browser implementation (half way there):

    https://github.com/bjpop/js-turtle

    See the live demo; type demo() in the command box:

    https://rawgit.com/wrschneider99/js-turtle/master/turtle.html

    Here is a JavaScript lib similar to the Python one Jeff posted to help with generating gcode from primitives:

    https://github.com/zackaholic/Plotter/blob/master/example.js

    But as we saw with the Python / Turtle script, you can very simply concatenate the Gcode on the fly directly from the vector values available.

    To get the file download option when you have no server disk, you can create the file in the browser memory and use a data URI to trigger the download:

    https://stackoverflow.com/questions/3665115/create-a-file-in-memory-for-user-to-download-not-through-server

    #36846

    Jeffeb3
    Participant

    I was very confused until I looked up what turtle is:

    https://docs.python.org/2/library/turtle.html

    Now that I see that, I can see how that would be useful.

    There’s no reason there can’t be more than one way to drive this thing. There are several ways to do anything with the MPCNC. Having a webpage just load up some client side javascript would be the best in the long term, because you don’t have to deal with installing anything, and you don’t have to sacrifice anything on the server besides the space and BW for loading the program. The python would be server side or installed on the user’s machine. AFAIK, there are no other options. I personally don’t like writing javascript, but to each their own, it’s a simple enough program that you could do it.

    Here’s some brain dumping:

    So if I were to narrow the scope, and come up with something that just took a pattern, scaled and rotated it until it became line art instead of just a polygon, the requirements for something like that would be:
    – The input would have to be a connected set of paths, that were completely inclosed. They could be overlapping, concave or anything like that, but they would have to be continuous, and start and end at the same place.
    – For example, a rectangle, circle (interpolated into many line segments), a triangle, or even something like the open hardware logo would work.
    – Something with two polygons wouldn’t work as expected. Like a donut, because it needs to get from one circle to the other, and it can’t lift up.
    – The output would need to be the path to take. I don’t think there is any CAM that would take the line art and correctly engrave it in the right order.
    – A “transform” would be the generic thing you can apply to the shape to make it slide around in the workspace.
    – Easy transforms are scale, rotate, and translate.
    – More complicated ones would be to follow a parametric function, like translate around a circle, while rotating, and while scaling according to a sine function.

    That seems pretty doable, and simple, actually. You take the input, convert it to something that understands x, y and then perform a transform on each point, and output x, y, do it in a for loop. Then convert the output to gcode.

    Gcode as input:
    Making the input gcode would intimidate some people, but not others. For things like a triangle, it might be overkill, but for things like the open source hardware logo, it would be tough to do by hand. The nice thing about gcode is that it forces things to be connected, sort of. Every line segment is and x, y and the previous x, y. That doesn’t work if the gcode includes Z. Another benefit, at least for testing is that the gctools library can read it, and perform quite a few transforms.

    Web as input:
    If you can make a list of X,Y points from a web form, then it would work just as well as gcode. If you’re talking about having a set of radio buttons for circle, square, triangle, then it’s pretty limited. Maybe there’s also a custom button where people can paste in a TSV list of points.

    Svg as input:
    IMO too complicated. There are just too many things svg can do. For example which layer do you read?

    Turtle as input:
    Seems to be very simple. There seem to be a lot of ways to test your algorithm. Just to be clear, what I’m suggesting is something like the turtle2svg web page, but with the output being gcode. People would tell the ball to “go forward(50)” and then “turn left(45)” and they can add for loops, etc. It would be easy to make star shapes, it’s relatively simple. It would completely define what we need to do. One downside is that people might be intimidated if it feels too much like a program language.

    Ggode as output:
    Obviously a good choice. As I said earlier, I don’t think anything can take an SVG and do a good job writing the gcode for that, because you want it traced in a particular order.

    Arduino as output:
    If you wanted, you could have some other format that the arduino uses to move, and read that in. I don’t think that’s really useful. GCode is really already well hammered on for this purpose.

    Python for transforms:
    I like it! No one else will though. Being able to write an arbitrary python function to transform the shape is pretty advanced.

    Turtle for transforms:
    This is an interesting concept. I could imagine checkmarks or radio buttons for scaling, rotating, and translating and then a checkmark for turtle, where you could write turtle commands to define the parametrics of the advanced transform.

    Web for transforms:
    You’d be limited to the most basic options, like: Rotate CW 1 “Unit” per shape, while scaling between full size and 10%. Some simple options, like min/max scale, speed to scale, and speed to rotate would all be easy to parse. Anything more complicated would require some skills, but maybe some basic things like having a translation based on a circle, or something.

    Command line for transforms:
    This seems like a good way to do it to me. People who have used a raspberry pi, but not necessarily done any programming could use it. It might also be an easy way to write a GUI, because it can just interface to the CLI.

    I think I can write something pretty quick to read in a gcode file and some options via command line, and then output a gcode file in python. I don’t know anything about p2exe, and I don’t have a windows machine I can test anything on, but I can make a few gcode files and share the code to make them.

    #36851

    Jeffeb3
    Participant

    I have to go, and I won’t be able to look at this for a few days, but here is a draft. It does scale, clip and rotate. Usage:

    ./sandify.py -h
    Usage: sandify.py [options] 
    
    Options:
      -h, –help            show this help message and exit
      -l LOOPS, –loops=LOOPS
                            Select how many copies of the shape you’d like
      -x SIZE_X, –size_x=SIZE_X
                            Select the max size for the X axis.
      -y SIZE_Y, –size_y=SIZE_Y
                            Select the max size for the Y axis.
      -r ROTATE, –rotate=ROTATE
                            Select how many degrees to rotate for each copy of the
                            shape. Positive is CW, negative is CCW. Rotates the
                            shape around the size_x/2, size_y/2
      -s SCALE, –scale=SCALE
                            Select how many percent to scale the shape for each
                            copy of the shape. Positive will grow, negative will
                            shrink. For example, -10 will scale from 100 to 0 in
                            10 steps
    

    The main body of code:

    #!/usr/bin/env python
    
    from util import *
    import optparse
    import sys
    import os.path
    
    # First, define some filters used in this process
    class Scale(Filter):
      """ Scale the input from 0,0
      """
    
      def __init__(self, scale):
        self.scale = scale
    
      def apply(self, command):
        result = command.clone()
    
        if command.X is not None:
          result.X = command.X * self.scale
        if command.Y is not None:
          result.Y = command.Y * self.scale
    
        return result
    
    class Clip(Filter):
      """ Clip any commands so they do not escape the desired size
      """
    
      def __init__(self, size_x, size_y):
        self.size_x = size_x
        self.size_y = size_y
    
      def apply(self, command):
        result = command.clone()
    
        if command.X is not None:
          result.X = min(max(command.X, 0.0), self.size_x)
        if command.Y is not None:
          result.Y = min(max(command.Y, 0.0), self.size_y)
    
        return result
    
    # consume the command line arguments first. Details: https://docs.python.org/2/library/optparse.html
    parser = optparse.OptionParser(usage="usage: sandify.py [options] <input.gcode>")
    parser.add_option('-l', '–loops', dest='loops', default=10,
            help="Select how many copies of the shape you'd like")
    parser.add_option('-x', '–size_x', dest='size_x', default=100,
            help="Select the max size for the X axis.")
    parser.add_option('-y', '–size_y', dest='size_y', default=100,
            help="Select the max size for the Y axis.")
    parser.add_option('-r', '–rotate', dest='rotate',
            help="Select how many degrees to rotate for each copy of the shape. Positive is CW, negative is CCW. Rotates the shape around the size_x/2, size_y/2")
    parser.add_option('-s', '–scale', dest='scale',
            help="Select how many percent to scale the shape for each copy of the shape. Positive will grow, negative will shrink. For example, -10 will scale from 100 to 0 in 10 steps")
    (options, input_gcode) = parser.parse_args()
    
    # clean up some of these options
    options.loops = int(options.loops)
    print 'Configured to run for {} loops'.format(options.loops)
    options.size_x = float(options.size_x)
    options.size_y = float(options.size_y)
    print 'Configured to limit the size between (0,0) and ({},{})'.format(options.size_x, options.size_y)
    if options.rotate:
        options.rotate = float(options.rotate)
    if options.scale:
        options.scale = float(options.scale)
    
    # check for an input file
    if not input_gcode or len(input_gcode) != 1 or not os.path.isfile(input_gcode[0]):
        print('ERROR, you need to specify a gcode file as input')
        sys.exit(1)
    
    print 'Reading in {}'.format(input_gcode[0])
    
    input = loadGCode(input_gcode[0])
    
    # Start with a clean slate of gcode
    output = GCode()
    
    print 'Performing transformations'
    
    # for each of these angles
    for loop in range(options.loops):
        # rotate the input to that angle
        loop_shape = input.clone()
    
        if options.rotate:
            loop_shape = loop_shape.clone(Translate(-options.size_x/2, -options.size_y/2),
                                          Rotate(options.rotate * loop),
                                          Translate(options.size_x/2.0, options.size_y/2.0))
    
        if options.scale:
            loop_shape = loop_shape.clone(Translate(-options.size_x/2, -options.size_y/2),
                                          Scale((1.0 + (0.01 * options.scale * loop))),
                                          Translate(options.size_x/2.0, options.size_y/2.0))
    
        # Clip
        loop_shape = loop_shape.clone(Clip(options.size_x, options.size_y))
    
        # copy that rotationm to the output
        output.lines += loop_shape.lines
    
    output_name = 'output.gcode'
    print 'Saving output gcode to {}'.format(output_name)
    saveGCode(output_name, output)
    
    

    Example output:

    ./sandify.py input.gcode -l6 -s -4 -r 5 && cat output.gcode
    Configured to run for 6 loops
    Configured to limit the size between (0,0) and (100.0,100.0)
    Reading in input.gcode
    Performing transformations
    Saving output gcode to output.gcode
    
    G01 X20.0000 Y20.0000
    G01 X80.0000 Y20.0000
    G01 X80.0000 Y80.0000
    G01 X20.0000 Y80.0000
    
    G01 X23.8197 Y18.7995
    G01 X81.2005 Y23.8197
    G01 X76.1803 Y81.2005
    G01 X18.7995 Y76.1803
    
    G01 X27.6120 Y18.0266
    G01 X81.9734 Y27.6120
    G01 X72.3880 Y81.9734
    G01 X18.0266 Y72.3880
    
    G01 X31.3324 Y17.6667
    G01 X82.3333 Y31.3324
    G01 X68.6676 Y82.3333
    G01 X17.6667 Y68.6676
    
    G01 X34.9387 Y17.7008
    G01 X82.2992 Y34.9387
    G01 X65.0613 Y82.2992
    G01 X17.7008 Y65.0613
    
    G01 X38.3915 Y18.1058
    G01 X81.8942 Y38.3915
    G01 X61.6085 Y81.8942
    G01 X18.1058 Y61.6085
    
    

    That should get you started with some prettier pictures, Ryan.

    Attachments:
    1. sandify.zip
    #36857

    James Donnelly
    Participant

    Like you, I am thinking about many modes of access to this device and other solutions. Many of which would be programmatic in input.

    But if I was to focus in on the concept that I understand Ryan is trying to achieve, I think it would be useful to take your terms of input, transform and output, and put them into context in relation to that.

    A few points before I get into that:

    By SVG, I wasn’t referencing the file format, but instead the term for how HTML 5 browsers let you render DOM elements as SVG:

    https://www.w3schools.com/html/html5_svg.asp

    What this will let you do in the context of this project is have a live preview panel in the web GUI to show the user what the gcode they are generating is going to do in realtime..

    The Turtle approach I think is a good shortcut for implementing the drawings in the web application, because you could quickly draw on some very advanced code written for Python Turtle and JavaScript Turtle, and probably many others that script the code to enable looping etc. This code could be adapted to implement the components in the user’s palette of available primitives/shapes, so I was not thinking that the user would write Turtle instructions. The good thing about Turtle, is if you ban the pen up command for this purpose, it can only generate valid paths, taking care of many of your rules.

    Finally, the problem with needing a Python backend is not really server resources, but that typically ecommerce, forum and blog hosting providers are very unlikely to support you installing a Python script, so therefore you need to go arrange some Python hosting. No big deal, but harder than packaging your app in a simple HTML file that sits anywhere and runs in the browser.

    So, in the style of “user stories” using your terms of input, output and transforms:

    As a user I want to achieve input and transforms through a simple intuitive and fun interface. The interface should start by being unambitious, but could develop into something more than just HTML forms based. With SVG and Canvas HTML 5 offers 2 ways to do any interface you can imagine. I would envisage a drag and drop approach where you have a pool of initial components to drag into a canvas and then some options to do the repetition which are very graphical and intuitive.

    As a user I need to be able to either be prompted to download a gcode file to an SD card, so I can manually put this in the device, or I need to activate an interface control on the device hosted web interface that transfers the gcode to the device for me via code running on an RPI or similar.

    And finally –

    As a user need be able to produce visually stunning patterns without any prior knowledge of gcode, vector graphics, Python, Javascript or Turtle.

    Perhaps the best middle ground is to focus the GUI and gcode generation work in a single pure JavaScript client, and have that talk to a thin python backend whose sole role is to put the generated gcode straight onto the sd card in the device.

    Back to all the permutations in the things you list, that’s more my cup of tea. I am super interested in doing some plotting and other stuff purely from writing Python code. This kind of thing for one, but also potentially things like tranformations for 4th axis work.

    1 user thanked author for this post.
    #36858

    James Donnelly
    Participant

    Wow, good quality work and fast!

    I think the benefit of turtle for this stuff shows up in the brevity of this code.

    Go to: https://rawgit.com/wrschneider99/js-turtle/master/turtle.html

    Paste in this JavaScript:

    function square(side) {
       repeat(4, function () {
          forward(side);
          right(90);
       });
    }
    
    function triangle(side) {
       repeat(3, function () {
          forward(side);
          right(120);
       });
    }
    
    function sandify(shape_func,loops,side,rotate) {
       hideTurtle();
       colour(0,0,255,1);
       for(s = loops; s > 0; s–) {
          shape_func(side);
          right(rotate);
       }
    }

    Then invoke (type this in the command box):

    sandify(square,36,50,10)

    Or:

    sandify(triangle,36,60,10)

    You can see instead of your approach of asking for a gcode as input, I can’t do that in the demo so I’ve added a triangle function to the pre-existing square.

    To be added in here is the gcode generation, which wouldn’t take much code at all

    Attachments:
    #36861

    James Donnelly
    Participant

    I added one line to the turtle.js library:

     console.log("G01 X" + Math.floor(newX+150) + " Y" + Math.floor(newY+150));

    It’s floored for readability, and offset by 150 because the canvas is 300×300 and the origin is centered not homed.

    Command: sandify(triangle,3,60,120)

    Gcode:

    G01 X150 Y210
    G01 X201 Y179
    G01 X149 Y150
    G01 X201 Y119
    G01 X149 Y90
    G01 X150 Y150
    G01 X98 Y120
    G01 X98 Y180
    G01 X150 Y150

    #36862

    Jeffeb3
    Participant

    Oh, ok I’m pickin’ up what you’re puttin’ down. That does seem useful. The fact that it works in JavaScript is really nice. I have done very little JavaScript, so having something that simple is great.

    Is there a good way to scale or skew the shapes? I guess you could change the size of the side. What about importing something like a logo? I was thinking of using EstlCAM to trace a logo, then import it in as gcode.

    As for how fast that Python was, I use vim 😉

    #36865

    James Donnelly
    Participant

    The thing is, the turtle.js is open source, so we’re not restricted to writing functions using the available API (listed on the left of the demo)

    It does text already. Skews or any other kind of transformation are easy.

    You could easily implement a gcode import function as an expert feature. You’d just be going backwards from gcode to vector paths.

    #36873

    Ryan
    Keymaster

    Holy cow you guys are fast, go cut some parts on the lowRider, come back and you guys coded up all kinds of stuff. I’m gonna stuff my face then see if I can comprehend a little bit of what was said above. Tried the turtle thing it didn’t work right off the bat so food first my brain ain’t workn’.

    #36883

    James Donnelly
    Participant

    A basic wireframe prototype to get the thoughts flowing?

    sandify

    Attachments:
    #36886

    James Donnelly
    Participant

    I was thinking after basic shapes there should be a tool to design spirograph drawings.

    Of course, after looking hard for 10 seconds, I was able to find something:

    http://seedcode.com/SpirographN/sgn.html?_ga=2.127723085.1500006977.1498559657-465537690.1498559657

    Again, source code is on Github, so good to go.

    #36887

    James Donnelly
    Participant

    It’s addictive.

    Tip: set the speed to fastest to see the pattern quickly

    #36892

    James Donnelly
    Participant

    Of course, spirographs are not enough, you also need parabolic art:

    https://medium.com/@rubenalexander/parabola-time-sponsored-by-html-svg-and-javascript-1ccfdde9911f
    http://jsfiddle.net/aer1fr3a/3/

    These ones are clearly not for the sand machine, but fun links for folks into plotting maybe:

    https://github.com/margaretpearce/js-art
    http://azarask.in/projects/algorithm-ink/#e0274a5c

    #36895

    Jeffeb3
    Participant

    I’m fairly certain we need Ryan to release the hardware before we give him access to this stuff. Once he gets this going, he’s just going to stare at it all day.

    Great ideas for patterns, James. The last one, with an infinite tunnel is really good, even without the texture.

    Some of these will go on forever. Which makes me wonder:
    1) I’d like to run a raspberry pi to just send out gcode as it’s being generated. That would let you run programs for weeks.
    2) I would feel better if the motors and drivers weren’t warm at all when doing that. Can we turn down the current?

    W.r.t. your user wire diagram. That looks awesome. You can’t really have two shapes at once, right?

    #36896

    James Donnelly
    Participant

    Actually I was thinking you could put as many shapes as you like in the box.

    I’ll leave 2) to the hardware team. YOu’d think so with the lower mass and forces, right?

    I should have included a form section for position I guess.

    The only thing that would be nice would be if the effects of the ball on sand could be emulated in the preview – so you could see that one pattern blocked out the one behind it for over lapping patterns.

    Here are a couple more little functions:

    (works at https://rawgit.com/wrschneider99/js-turtle/master/turtle.html)

    function spiral(sides,loops,gap) {
       hideTurtle();
       colour(0,0,255,1);
       
       angle = 360/sides;
       side_length = 1;
       for(i = 0; i < loops*sides; i++) {
         forward(side_length);
         left(angle);
         side_length+= gap;
       }
    }
    
    // version 1: odd number of points only!
    function star(points, length) {
       hideTurtle();
       colour(0,0,255,1);
       
       angle = 180 – (180/points);
       side_length = 1;
       for(i = 0; i < points; i++) {
         forward(length);
         left(angle);
         forward(length)
         
       }
    }
    #36901

    Ryan
    Keymaster

    OMG, I am thinking of new parts, trying not to overthink it or reinvent the wheel, over engineer or whatever you want to call it. I have a serious moral dilemma of adapt MPCNC parts or redesign everything……ahhhhh probably best for now to adapt MPCNC parts. Then make a new system for Version 2 if needed.

    I was thinking for multiple figures or whatever it would start at the center point of all of them and do a reverse offset until it hit them and just keep outlining. Typing that it makes it sound difficult. I guess a single design would be better at least to start with, text being more important than multiple shapes. Even if it was make a pattern, then write in cursive across the pattern from one edge to the next. I did one by hand but the spline function was limiting me.

    New magnets will be here today.

    I am going to play with some of those links you guys found now…if I don;t check back by the end of the evening….I’m stuck playing with them and need rescuing.

    #36902

    Ryan
    Keymaster

    That spirograph is damn near perfect. If it allowed you to constrain it in a box (so it uses the whole area) and figure out some values to open up the overlap a little bit, maybe a turns limit or something. If that output code with the arcs commands it would be a tiny file even, Or maybe not because the output isn’t a circle….hmmm. Maybe there is a way to just tweak the arc gcode to make some cool patterns.

    That is kind of what I was thinking, it has some drop downs and some editable numbers. Everyone could have a completely different pattern.

    #36903

    Ryan
    Keymaster

    I still can’t get turtle going, it keeps says “exception”

    Could you drop a screenshot so maybe I can see what I am doing wrong.

    The programming for turtle looks like something I did in 6th grade I think, in DOS?!

    #36908

    Jeffeb3
    Participant

    Wrt hardware. I like the idea of the corexy machine. I’m thinking of trying to reduce the motors to 2 motors, fewer drivers, simpler cables. Plus it would always be square.

    #36909

    Ryan
    Keymaster

    Yup…long ass belts but seems to be the better way to do it since accuracy (do to belt sag) shouldn’t be an issue.

    #36910

    Ryan
    Keymaster

    But…That’s what I was talking about above. Trying to just get it working quickly or making a new setup.. The problem with CoreXY is the center bar can’t be a single round, square (or angle) would be best or two rounds would work to prevent twisting. For something this big (I am thinking full sized dinner table), The regular setup is probably best.

    #36911

    Ryan
    Keymaster

    Knowing if I make it suitable for all three sized conduit, it will work worldwide. If I move to angle, square, or channel, who knows how many sizes there are.

    I’m not sure how fast you would really want it to move, at some point it will start to splash or throw the sand.

    #36914

    James Donnelly
    Participant

    I know why Ryan. Took a while to figure it out. Somehow when pasting from the site to this forum, the minus sign was getting replaced with another hyphen like character

    As you can see from all the edits, I’ve tried every possible way to format the code, but the minus sign always gets replace with hyphen.

    function spiral(sides,loops,gap) {
       hideTurtle();
       colour(0,0,255,1);
        
       angle = 360/sides;
       side_length = 1;
       for(i = 0; i < loops*sides; i++) {
         forward(side_length);
         left(angle);
         side_length+= gap;
       }
    }
    
    // version 1: odd number of points only!
    function star(points, length) {
       hideTurtle();
       colour(0,0,255,1);
        
       angle = 180 – (180/points);
       
       for(i = 0; i < points; i++) {
         forward(length);
         left(angle);
         forward(length)
       }
    }

    https://rawgit.com/wrschneider99/js-turtle/master/turtle.html

    Attachments:
Viewing 30 posts - 31 through 60 (of 566 total)

You must be logged in to reply to this topic.