[Tutor] Seeking Help for CMU CS Academy - Spinning Arcs

Kevin Andreyo kevand at Berksiu.org
Fri Jan 15 09:00:58 EST 2021


Greetings:

I’m working through the exercises for CMU CS Academy-- a project in Carnegie Mellon University’s School of Computer Science (SCS) that has the goal of developing a novel, world-class, online, interactive high school computer science curriculum that is entirely free.
I am working on the exercise 7.4 Spinning Arcs. I understand what the startAngle and sweepAngle of an arc are. I’m just not understanding what the code means by “updating” the start and sweep angles. I can’t seem to get my angles to change at all.

This is my code…

app.background = rgb(0, 0, 60)

arcs = Group()

for i in range(10):
    # Each green strip is an arc with the center covered by another arc.
    # The strips are drawn from big to small so the covering arcs only cover
    # the arcs that are bigger than them.
    arc1 = Arc(200, 200, 401 - (40 * i), 401 - (40 * i), 0, 10,
               fill=rgb(0, 25 * (i + 1), 20 * (i + 1)))
    arc2 = Arc(200, 200, 370 - (40 * i), 370 - (40 * i), 0, 10,
               fill=rgb(0, 0, 60))

    # dA is the change in the start angle, dS is the change in the sweep angle.
    arc1.dA = i + 1
    arc1.dS = 2 * (i + 1)
    arc2.dA = i + 1
    arc2.dS = 2 * (i + 1)

    arcs.add(arc1, arc2)

def moveArcs(arc):
    # If the sweepAngle will become too small or is bigger than or equal to 340,
    # change the direction that the sweep angle changes.
    ### Place Your Code Here ###
    for arc in arcs.children:
        if(0>arc.sweepAngle>=340):
            arc1.dS=-arc1.dS
            arc2.dS=-arc2.dS
    # Update the start and sweep angles of the arc.
    ### Place Your Code Here ###
        arc.startAngle=arc1.dA
        arc.sweepAngle=arc1.dS
    # When the start angle gets to 360, reset it to 0.
    ### Place Your Code Here ###
        if(arc.startAngle>=360):
            arc.startAngle=0

def onStep():
    for arc in arcs.children:
        moveArcs(arc)

Thank you for your help.
Sincerely,
Kevin
________________________________
IMPORTANT/CONFIDENTIAL: This communication is intended solely for the use of the individual or entity to which it is addressed. This e-mail contains information from the Berks County Intermediate Unit that may be privileged, confidential, and exempt from disclosure under applicable law. If the reader of this communication is not the intended recipient, you are hereby notified that any dissemination, distribution, or copying of this communication is strictly prohibited. If you have received this communication in error, please notify us immediately and permanently delete this message including all attachments.
________________________________


More information about the Tutor mailing list