Beispiel #1
0
def teyleen_982():
    c = canvas(**canvas_args)
    pi = np.pi

    pal = [
        matplotlib_colors("lavender"),
    ] + palettes(96)

    c = canvas(**canvas_args)
    tc = 0.025

    dx = pi / 8
    t0 = dx
    t1 = 2 * pi - dx
    r = 1.8

    for n in range(6):
        c.ellipse(0, 0, r, r, pi / 2, t0, t1, color=pal[n], thickness=tc)

        dx *= 1.4
        t0 = dx
        t1 = 2 * pi - dx
        r -= 0.2

    return c
Beispiel #2
0
    def __init__(self,
                 path,
                 strokepath=None,
                 fillpath=None,
                 styles=None,
                 strokestyles=None,
                 fillstyles=None,
                 ornaments=None,
                 fillrule=style.fillrule.nonzero_winding):

        self.path = path

        # global style for stroking and filling and subdps
        self.styles = styles

        # styles which apply only for stroking and filling
        self.strokestyles = strokestyles
        self.fillstyles = fillstyles

        # the decoratedpath can contain additional elements of the
        # path (ornaments), e.g., arrowheads.
        if ornaments is None:
            self.ornaments = canvas.canvas()
        else:
            self.ornaments = ornaments

        # the fillrule is either fillrule.nonzero_winding or fillrule.even_odd
        self.fillrule = fillrule

        self.nostrokeranges = None
Beispiel #3
0
def checkCanvasIntegration():
    ci = CanvasInfo()

    try:
        print("")
        print("Verifying that Canvas integration works...")

        if canvasToken and canvasAPI and canvasCourseName:
            import canvas
            ci.c = canvas.canvas(token=canvasToken, api=canvasAPI)
            ci.courses = ci.c.getCourses()
            ci.courseId = ci.c.findCourseId(ci.courses, canvasCourseName)
            if ci.courseId:
                print("Found course on Canvas: %s" % canvasCourseName)
            else:
                print("Can't find course '%s' on Canvas." % canvasCourseName)

            ci.c.setDefaultCourseId(ci.courseId)
            ci.assignments = ci.c.getAssignments()
            ci.students = ci.c.getStudents()
            ci.assignmentId = ci.c.findAssignmentId(ci.assignments,
                                                    canvasAssignmentName)
            if ci.assignmentId:
                print("Found assignment on Canvas: %s" % canvasAssignmentName)
                return ci
            else:
                print("Can't find assignment '%s' in Canvas course." %
                      canvasAssignmentName)

    except:
        #import traceback
        #traceback.print_exc()
        pass

    return None
Beispiel #4
0
def render(camera, world):
    image = canvas(camera.hsize, camera.vsize)

    start = time.time()
    for y in range(camera.vsize):
        current = time.time()
        elapsed = round(current - start, 2)
        percent = round(y / camera.vsize * 100, 2)
        if y != 0:
            t = round((1 / (y / camera.vsize)) * elapsed - elapsed, 2)
            print(
                "\r"
                + str(percent).rjust(5)
                + "% : "
                + str(t)
                + "s left : "
                + str(elapsed)
                + "s elapsed",
                end=" ",
                flush=True,
            )
        for x in range(camera.hsize):
            ray = ray_for_pixel(camera, x, y)
            color = color_at(world, ray)
            write_pixel(image, x, y, color)
    print()

    return image
Beispiel #5
0
    def decorate(self, dp, texrunner):
        if self.texrunner:
            texrunner = self.texrunner
        import text as textmodule
        self.defaulttextattrs = [textmodule.halign.center]

        dp.ensurenormpath()
        if self.arclenfrombegin is not None:
            textpos = dp.path.begin() + self.arclenfrombegin
        elif self.arclenfromend is not None:
            textpos = dp.path.end() - self.arclenfromend
        else:
            # relarcpos is used if neither arcfrombegin nor arcfromend is given
            textpos = self.relarclenpos * dp.path.arclen()

        textattrs = self.defaulttextattrs + self.textattrs
        t = texrunner.text(0, 0, self.text, textattrs, singlecharmode=1)
        t.ensuredvicanvas()

        c = canvas.canvas()
        for item in t.dvicanvas.items:
            bbox = item.bbox()
            if bbox:
                x = item.bbox().center()[0]
                atrafo = dp.path.trafo(textpos+x)
                c.insert(item, [trafo.translate(-x, 0), atrafo])
                if self.exclude is not None:
                    dp.excluderange(textpos+bbox.left()-self.exclude, textpos+bbox.right()+self.exclude)
            else:
                c.insert(item)
        dp.ornaments.insert(c)
Beispiel #6
0
  def draw_frame(self):

    with canvas(self.device) as draw:

      for x in range(self.width):
        for y in range(self.height):
          if (x ^ y ^ self.flip) < self.count:
            color_index = (self.generation % len(self.colors)) - 1
            color_index = (((x ^ y) << 3) + self.generation) % len(self.colors)
            c = self.colors[color_index]
            c = int(c.red * 255), int(c.green * 255), int(c.blue * 255)
            draw.point((x, y), fill=c)
          else:
            draw.point((x, y), fill=(0, 0, 0))

      self.count += self.dir

      if self.count <= 0 or self.count >= self.width:
        self.dir = -self.dir

      if self.count <= 0:
        if self.flip == 0:
          self.flip = 31
        else:
          self.flip = 0

      self.generation += 1

    return 10
Beispiel #7
0
def simple_rectangles():
    c = canvas(**canvas_args)

    c.rectangle(-1, -1, 1, 1, 'lightcoral')
    c.rectangle(0, 0, 2, -2, 'lime')
    c.rectangle(-3, -3, 0.5, 0.5, 'royalblue')

    return c
Beispiel #8
0
    def _process(self, processMethod, contentfile, writer, context, registry, bbox):
        # usually, it is the bbox of the canvas enlarged by self.bboxenlarge, but
        # it might be a different bbox as specified in the page constructor
        assert not bbox
        if self.pagebbox:
            bbox.set(self.pagebbox)
        else:
            bbox.set(self.canvas.bbox()) # this bbox is not accurate
            bbox.enlarge(self.bboxenlarge)

        # check whether we expect a page trafo and use a temporary canvas to insert the
        # page canvas
        if self.paperformat and (self.rotated or self.centered or self.fittosize) and bbox:
            # calculate the pagetrafo
            paperwidth, paperheight = self.paperformat.width, self.paperformat.height

            # center (optionally rotated) output on page
            if self.rotated:
                pagetrafo = trafo.rotate(90).translated(paperwidth, 0)
                if self.centered or self.fittosize:
                    if not self.fittosize and (bbox.height() > paperwidth or bbox.width() > paperheight):
                        warnings.warn("content exceeds the papersize")
                    pagetrafo = pagetrafo.translated(-0.5*(paperwidth - bbox.height()) + bbox.bottom(),
                                                      0.5*(paperheight - bbox.width()) - bbox.left())
            else:
                if not self.fittosize and (bbox.width() > paperwidth or bbox.height() > paperheight):
                    warnings.warn("content exceeds the papersize")
                pagetrafo = trafo.translate(0.5*(paperwidth - bbox.width())  - bbox.left(),
                                            0.5*(paperheight - bbox.height()) - bbox.bottom())

            if self.fittosize:

                if 2*self.margin > paperwidth or 2*self.margin > paperheight:
                    raise ValueError("Margins too broad for selected paperformat. Aborting.")

                paperwidth -= 2 * self.margin
                paperheight -= 2 * self.margin

                # scale output to pagesize - margins
                if self.rotated:
                    sfactor = min(unit.topt(paperheight)/bbox.width_pt(), unit.topt(paperwidth)/bbox.height_pt())
                else:
                    sfactor = min(unit.topt(paperwidth)/bbox.width_pt(), unit.topt(paperheight)/bbox.height_pt())

                pagetrafo = pagetrafo.scaled(sfactor, sfactor, self.margin + 0.5*paperwidth, self.margin + 0.5*paperheight)

            bbox.transform(pagetrafo)
            cc = canvasmodule.canvas()
            cc.insert(self.canvas, [pagetrafo])
        else:
            cc = self.canvas

        getattr(style.linewidth.normal, processMethod)(contentfile, writer, context, registry, bbox)
        if self.pagebbox:
            bbox = bbox.copy() # don't alter the bbox provided to the constructor -> use a copy
        getattr(cc, processMethod)(contentfile, writer, context, registry, bbox)
Beispiel #9
0
    def _process(self, processMethod, contentfile, writer, context, registry, bbox):
        # usually, it is the bbox of the canvas enlarged by self.bboxenlarge, but
        # it might be a different bbox as specified in the page constructor
        assert not bbox
        if self.pagebbox:
            bbox.set(self.pagebbox)
        else:
            bbox.set(self.canvas.bbox()) # this bbox is not accurate
            bbox.enlarge(self.bboxenlarge)

        # check whether we expect a page trafo and use a temporary canvas to insert the
        # page canvas
        if self.paperformat and (self.rotated or self.centered or self.fittosize) and bbox:
            # calculate the pagetrafo
            paperwidth, paperheight = self.paperformat.width, self.paperformat.height

            # center (optionally rotated) output on page
            if self.rotated:
                pagetrafo = trafo.rotate(90).translated(paperwidth, 0)
                if self.centered or self.fittosize:
                    if not self.fittosize and (bbox.height() > paperwidth or bbox.width() > paperheight):
                        warnings.warn("content exceeds the papersize")
                    pagetrafo = pagetrafo.translated(-0.5*(paperwidth - bbox.height()) + bbox.bottom(),
                                                      0.5*(paperheight - bbox.width()) - bbox.left())
            else:
                if not self.fittosize and (bbox.width() > paperwidth or bbox.height() > paperheight):
                    warnings.warn("content exceeds the papersize")
                pagetrafo = trafo.translate(0.5*(paperwidth - bbox.width())  - bbox.left(),
                                            0.5*(paperheight - bbox.height()) - bbox.bottom())

            if self.fittosize:

                if 2*self.margin > paperwidth or 2*self.margin > paperheight:
                    raise ValueError("Margins too broad for selected paperformat. Aborting.")

                paperwidth -= 2 * self.margin
                paperheight -= 2 * self.margin

                # scale output to pagesize - margins
                if self.rotated:
                    sfactor = min(unit.topt(paperheight)/bbox.width_pt(), unit.topt(paperwidth)/bbox.height_pt())
                else:
                    sfactor = min(unit.topt(paperwidth)/bbox.width_pt(), unit.topt(paperheight)/bbox.height_pt())

                pagetrafo = pagetrafo.scaled(sfactor, sfactor, self.margin + 0.5*paperwidth, self.margin + 0.5*paperheight)

            bbox.transform(pagetrafo)
            cc = canvasmodule.canvas()
            cc.insert(self.canvas, [pagetrafo])
        else:
            cc = self.canvas

        getattr(style.linewidth.normal, processMethod)(contentfile, writer, context, registry, bbox)
        if self.pagebbox:
            bbox = bbox.copy() # don't alter the bbox provided to the constructor -> use a copy
        getattr(cc, processMethod)(contentfile, writer, context, registry, bbox)
Beispiel #10
0
def createCanvas():
    newWindow = Toplevel()
    newWindow.geometry("500x500")

    newCanvas = canvas(newWindow, values_json["canvas"][0],
                       values_json["canvas"][1])
    entry1 = entry(newWindow, values_json["entry1"][0], newCanvas)
    entry1.render(values_json["entry1"][1])
    buttonCanvas = button(newWindow, entry1.getTextVal,
                          values_json["buttonCanvas"][0],
                          values_json["buttonCanvas"][1])
Beispiel #11
0
 def __init__ (self, parent) :
     
     # Set the class as a Scrolled Window    
     wx.ScrolledWindow.__init__ (self, parent)
     
     self.SetScrollbars (20, 20, 60, 40)
     
     # Add the canvas
     self.canvas = canvas (self)
     
     self.Show ()
Beispiel #12
0
    def __init__(self, duration=5, fps=5, width=200, height=200, extent=4):

        self.duration = duration
        self.fps = fps
        self.artists = []

        n_frames = int(fps * duration)

        self.frames = [canvas(width, height, extent) for _ in range(n_frames)]
        self.has_rendered = [
            False,
        ] * len(self)
        self.timepoints = np.linspace(0, 1, len(self) + 1)[:-1]
Beispiel #13
0
    def _decocanvas(self, angle, dp, texrunner):
        dp.ensurenormpath()
        dist_pt = unit.topt(self.dist)

        c = canvas.canvas([canvas.clip(dp.path)])
        llx_pt, lly_pt, urx_pt, ury_pt = dp.path.bbox().highrestuple_pt()
        center_pt = 0.5*(llx_pt+urx_pt), 0.5*(lly_pt+ury_pt)
        radius_pt = 0.5*math.hypot(urx_pt-llx_pt, ury_pt-lly_pt) + dist_pt
        n = int(2*radius_pt / dist_pt) + 1
        for i in range(n):
            x_pt = center_pt[0] - radius_pt + i*dist_pt
            c.stroke(path.line_pt(x_pt, center_pt[1]-radius_pt, x_pt, center_pt[1]+radius_pt),
                     [trafo.rotate_pt(angle, center_pt[0], center_pt[1])] + self.strokestyles)
        return c
Beispiel #14
0
def teyleen_116():

    c = canvas(**canvas_args)
    pal = palettes(152)

    x = 0.25
    c.circle(x, x, r=x / 2, color=pal[0])
    c.circle(-x, x, r=x / 2, color=pal[1])
    c.circle(x, -x, r=x / 2, color=pal[2])
    c.circle(-x, -x, r=x / 2, color=pal[3])

    c.circle(0, x / 2, r=2 - x, color=pal[4], thickness=x / 20)
    c.circle(0, -x / 2, r=2 - x, color=pal[4], thickness=x / 20)

    return c
Beispiel #15
0
    def draw_frame(self):

        if not self.is_setup:
            self.setup()

        self.update()

        with canvas(self.device) as draw:

            draw.point(self.apple, self.apple_color)

            for point in list(self.segments):
                draw.point(point, self.snake_color)

        return self.movespeed
Beispiel #16
0
    def decorate(self, dp, texrunner):
        dp.ensurenormpath()
        l = dp.path.arclen()

        colors = [self.grad.select(n, self.steps) for n in range(self.steps)]
        colors.reverse()
        params = dp.path.arclentoparam([l*i/float(self.steps) for i in range(self.steps)])
        params.reverse()

        c = canvas.canvas()
        # treat the end pieces separately
        c.stroke(dp.path.split(params[1])[1], attr.mergeattrs([colors[0]] + self.attrs))
        for n in range(1,self.steps-1):
            c.stroke(dp.path.split([params[n-1],params[n+1]])[1], attr.mergeattrs([colors[n]] + self.attrs))
        c.stroke(dp.path.split(params[-2])[0], attr.mergeattrs([colors[-1]] + self.attrs))
        dp.ornaments.insert(c)
Beispiel #17
0
def simple_circles():
    c = canvas(**canvas_args)
    q = 155

    n = 3
    t = np.arange(0, 2 * np.pi, 2 * np.pi / n) + np.pi / 6
    x, y = np.cos(t), np.sin(t)

    c.circle(x[0], y[0], r=1, color=[0, 255, 0])
    c.circle(x[1], y[1], r=1, color=[255, 0, 0])
    c.circle(x[2], y[2], r=1, color=[0, 0, 255])

    # An example of not saturating the images together
    c.circle(0, 0, r=0.25, color=[q, q, q], blend=False)

    return c
Beispiel #18
0
    def _decocanvas(self, angle, dp, texrunner):
        dp.ensurenormpath()
        dist_pt = unit.topt(self.dist)

        c = canvas.canvas([canvas.clip(dp.path)])
        llx_pt, lly_pt, urx_pt, ury_pt = dp.path.bbox().highrestuple_pt()
        center_pt = 0.5 * (llx_pt + urx_pt), 0.5 * (lly_pt + ury_pt)
        radius_pt = 0.5 * math.hypot(urx_pt - llx_pt,
                                     ury_pt - lly_pt) + dist_pt
        n = int(2 * radius_pt / dist_pt) + 1
        for i in range(n):
            x_pt = center_pt[0] - radius_pt + i * dist_pt
            c.stroke(
                path.line_pt(x_pt, center_pt[1] - radius_pt, x_pt,
                             center_pt[1] + radius_pt),
                [trafo.rotate_pt(angle, center_pt[0], center_pt[1])] +
                self.strokestyles)
        return c
Beispiel #19
0
    def __init__(self, path, strokepath=None, fillpath=None,
                 styles=None, strokestyles=None, fillstyles=None,
                 ornaments=None):

        self.path = path

        # global style for stroking and filling and subdps
        self.styles = styles

        # styles which apply only for stroking and filling
        self.strokestyles = strokestyles
        self.fillstyles = fillstyles

        # the decoratedpath can contain additional elements of the
        # path (ornaments), e.g., arrowheads.
        if ornaments is None:
            self.ornaments = canvas.canvas()
        else:
            self.ornaments = ornaments

        self.nostrokeranges = None
Beispiel #20
0
def simple_lines():
    c = canvas(**canvas_args)

    c.line(-4, 0, 4, 0, thickness=0.05)
    c.line(0, 4, 0, -4, thickness=0.05)

    tc = 0.04

    for i in np.arange(-4, 5, 1):
        c.line(-4, i, 4, i, thickness=tc, color=[100, int(100 + i * 10), 100])
        c.line(i, 4, i, -4, thickness=tc, color=[100, 100, int(100 + i * 10)])

    for i in np.arange(-4, 5, .5):
        c.line(-4, i, 4, i, thickness=tc, color=[
            20,
        ] * 3)
        c.line(i, 4, i, -4, thickness=tc, color=[
            20,
        ] * 3)

    return c
Beispiel #21
0
    def decorate(self, dp, texrunner):
        dp.ensurenormpath()
        l = dp.path.arclen()

        colors = [self.grad.select(n, self.steps) for n in range(self.steps)]
        colors.reverse()
        params = dp.path.arclentoparam(
            [l * i / float(self.steps) for i in range(self.steps)])
        params.reverse()

        c = canvas.canvas()
        # treat the end pieces separately
        c.stroke(
            dp.path.split(params[1])[1],
            attr.mergeattrs([colors[0]] + self.attrs))
        for n in range(1, self.steps - 1):
            c.stroke(
                dp.path.split([params[n - 1], params[n + 1]])[1],
                attr.mergeattrs([colors[n]] + self.attrs))
        c.stroke(
            dp.path.split(params[-2])[0],
            attr.mergeattrs([colors[-1]] + self.attrs))
        dp.ornaments.insert(c)
Beispiel #22
0
import msvcrt, canvas
can = canvas.canvas(24, 24)

class player:
    def __init__(self, x, y):
        self.player_x = x
        self.player_y = y
    def draw(self):
        can.clear()
        can.pixel(self.player_x, self.player_y, 1)
        can.draw()
    
        
p1 = player(0, 0)
p1.draw()

while True:
    key = msvcrt.getch()
    if(key == b'r'):
        p1.player_x = 0
        p1.player_y = 0
        p1.draw()
    elif(key == b'H'):
        if not p1.player_y < 1:
            p1.player_y = p1.player_y - 1
    elif(key == b'P'):
        if not p1.player_y > 22:
            p1.player_y = p1.player_y + 1
    elif(key == b'K'):
        if not p1.player_x < 1:
            p1.player_x = p1.player_x - 1
Beispiel #23
0
from material import material
from ray import position, ray
from shape import hit, normal_at
from sphere import intersect, sphere
from tuple import color, normalize, point, point_light
from world import lighting

if __name__ == "__main__":
    ray_origin = point(0, 0, -5)
    wall_z = 10
    wall_size = 7
    canvas_pixels = 400
    pixel_size = wall_size / canvas_pixels
    half = wall_size / 2

    canvas = canvas(canvas_pixels, canvas_pixels)
    shape = sphere()
    shape.material = material()
    shape.material.color = color(0.2, 1, 1)

    light_position = point(-10, 10, -10)
    light_color = color(1, 1, 1)
    light = point_light(light_position, light_color)

    # transformations
    # shape.transform = scaling(1, 0.5, 1)
    # shape.transform = scaling(0.5, 1, 1)
    # shape.transform = rotation_z(pi / 4) * scaling(0.5, 1, 1)
    # shape.transform = shearing(1, 0, 0, 0, 0, 0) * scaling(0.5, 1, 1)

    start = time.time()
Beispiel #24
0
import msvcrt, canvas, random
score = 0
can = canvas.canvas(32, 24)

class ball:
    def __init__(self, x, y, d):
        self.ball_x = x
        self.ball_y = y
        self.ball_d = d
        
class paddle:
    def __init__(self, y_Min, y_Max):
        self.y_Min = y_Min
        self.y_Max = y_Max
        
bal = ball(random.randrange(4, 16), random.randrange(4, 16), random.randrange(2,4))
pad = paddle(8, 16)

def draw(canv, padd, ball):
        canv.clear()
        canv.pixel(ball.ball_x, ball.ball_y, 2)
        for i in range(padd.y_Min, padd.y_Max):
            canv.pixel(31, i, 1)
        for i in range(0, 24):
            canv.pixel(0, i, 1)
        canv.draw()

def bounce():
    global score
    if bal.ball_d == 0:
        if bal.ball_y < 1:
Beispiel #25
0
elif sys.argv[1] == 'emailClearCache':
    os.chdir(subdirName)        
    if len(sys.argv) > 2:
        emailClearCache(sys.argv[2:])
    else:
        emailClearCache(dirs)

elif sys.argv[1] == 'stats' or sys.argv[1] == 'stat':
    os.chdir(subdirName)
    if len(sys.argv) > 2:
        stats(sys.argv[2:])
    else:
        stats(dirs)

elif sys.argv[1] == 'download':
    c = canvas.canvas()
    if len(sys.argv) == 2:
        c.downloadAssignment(courseName=courseName, assignmentName=assignmentName, subdirName=subdirName)
    elif len(sys.argv) == 4:
        # Delete the any existing submission with the given name
        if os.path.exists(os.path.join(subdirName, sys.argv[2])):
            shutil.rmtree(os.path.join(subdirName, sys.argv[2]))
        c.downloadAssignment(courseName=courseName, assignmentName=assignmentName, subdirName=subdirName, userid=sys.argv[2], attempt=int(sys.argv[3]))
    else:
        print("Usage:")
        print(" ag.py download   --> downloads all non-late submissions")
        print(" ag.py download username attempt# --> downloads one specific submission (even if it is late)")
        exit(1)
    removeELFs()
    
elif sys.argv[1] == 'email':
Beispiel #26
0
    def __init__ (self) :

        wx.Frame.__init__ (self, None)

        ## Menu
        self.CreateStatusBar  ()

        # Creating the menu bar
        menuBar  = wx.MenuBar ()
        self.SetMenuBar (menuBar)
        
        # Creating the menu
        menuFile = wx.Menu ()
        menuHelp = wx.Menu ()
        
        # Adding some contents
        menuFileOpen  = wx.MenuItem (menuFile, wx.ID_OPEN )
        menuFileNew   = wx.MenuItem (menuFile, wx.ID_NEW  )
        menuFileSave  = wx.MenuItem (menuFile, wx.ID_SAVE )
        menuFileQuit  = wx.MenuItem (menuFile, wx.ID_EXIT )
        
        menuHelpAbout = wx.MenuItem (menuHelp, wx.ID_ABOUT)      
        
        # Binding
        self.Bind (wx.EVT_MENU, self.onOpen , menuFileOpen )
        self.Bind (wx.EVT_MENU, self.onNew  , menuFileNew  )
        self.Bind (wx.EVT_MENU, self.onSave , menuFileSave )
        self.Bind (wx.EVT_MENU, self.onQuit , menuFileQuit )
        
        self.Bind (wx.EVT_MENU, self.onAbout, menuHelpAbout)
        
        # Adding contents to the menus
        menuFile.AppendItem      (menuFileOpen )
        menuFile.AppendSeparator (             )
        menuFile.AppendItem      (menuFileNew  )
        menuFile.AppendItem      (menuFileSave )
        menuFile.AppendSeparator (             )
        menuFile.AppendItem      (menuFileQuit )
        
        menuHelp.AppendItem      (menuHelpAbout)
        
        # Adding the menus to the menu bar
        menuBar.Append (menuFile, "&Fichier")
        menuBar.Append (menuHelp, "&Aide"   )
        
        ## Frame
        
        # Creating some filling for the frame
        iterationText   = wx.StaticText (self, label = "Iteration"          )
        progressionText = wx.StaticText (self, label = "Progression"        )
        repetitionText  = wx.StaticText (self, label = "Chaques"            )
        secondesText    = wx.StaticText (self, label = "Secondes"           )
        
        self.iterationCtrl   = wx.SpinCtrl   (self, initial = 0, min = 0, max = 256, name = "iteration",   style = wx.TE_PROCESS_ENTER                       ) 
        progressionCtrl      = wx.SpinCtrl   (self, initial = 1, min = 1, max = 256, name = "progression", style = wx.TE_PROCESS_ENTER                       )
        repetitionCtrl       = agw.FloatSpin (self, min_val = 0.1, increment = 0.1, value = 0.5, digits = 1, name = "repetition", style = wx.TE_PROCESS_ENTER)
        
        # Adding the canvas
        self.canvas = canvas (self)
        
        # Binding
        self.Bind (wx.EVT_TEXT_ENTER, self.onTextEnter, self.iterationCtrl  )
        self.Bind (wx.EVT_TEXT_ENTER, self.onTextEnter, progressionCtrl     )
        self.Bind (wx.EVT_TEXT_ENTER, self.onTextEnter, repetitionCtrl      )
        
        # Layout the frame
        sizerIteration   = wx.BoxSizer (wx.HORIZONTAL)
        sizerProgression = wx.BoxSizer (wx.HORIZONTAL)
        sizeRepetition   = wx.BoxSizer (wx.HORIZONTAL)
        sizerBar         = wx.BoxSizer (wx.HORIZONTAL)
        self.sizerMain        = wx.BoxSizer (wx.VERTICAL  )
        
        sizerIteration.Add   (iterationText,     flag = wx.CENTER)
        sizerIteration.Add   (self.iterationCtrl                 )
        sizerProgression.Add (progressionText,   flag = wx.CENTER)
        sizerProgression.Add (progressionCtrl                    )
        sizeRepetition.Add   (repetitionText,    flag = wx.CENTER)
        sizeRepetition.Add   (repetitionCtrl                     )
        sizeRepetition.Add   (secondesText,      flag = wx.CENTER)
        
        sizerBar.Add         (sizerIteration                     )
        sizerBar.Add         ((20, -1)                           )
        sizerBar.Add         (sizerProgression                   )
        sizerBar.Add         ((20, -1)                           )
        sizerBar.Add         (sizeRepetition                     )
        
        self.sizerMain.Add        (sizerBar,    flag = wx.CENTER      )
        self.canvasSizer = self.sizerMain.Add        (self.canvas, 1, flag = wx.CENTER      )
        
        self.SetSizerAndFit (self.sizerMain)
        
        # Some setup
        self.defaultDirectory = os.getcwd ()
        self.Show ()
Beispiel #27
0
                                   0.) & (pha_data['KRON_RADIUS'] > 0.)
selection = number[mask]
print 'Number of postage stamps to create =', len(selection)

# Set the output directory
output_dir = args.outputdir
if output_dir[-1] != "/":
    output_dir = output_dir + "/"

# Cut the stamps
for n in selection:

    obj = n - 1
    ra = pha_data['ALPHAWIN_J2000'][obj]
    dec = pha_data['DELTAWIN_J2000'][obj]
    a_image = pha_data['A_IMAGE'][obj]
    kr = float(pha_data['KRON_RADIUS'][obj])

    input_size = round(kr * a_image, 0) * 6
    if input_size % 2 == 0:
        input_size = (input_size - 1)
    wd = input_size * 1. / 2

    nameout = coadd_tile + '_' + str(n) + '.fits'
    img = canvas(hdulist_tile, w_tile, ra, dec, wd, wd)
    newfile = fits.PrimaryHDU(data=img[0], header=img[1])
    newfile.writeto(output_dir + nameout, clobber=True, checksum=True)

t_end = time.time()
print("Time Elapsed for the search: %6.4f" % (t_end - t_begin))
Beispiel #28
0
def step_impl(context):
    context.c = canvas(5, 3)
Beispiel #29
0
def step_impl(context):
    context.c = canvas(10, 2)
Beispiel #30
0
    def setupUi(self, MainWindow):
        MainWindow.setObjectName(_fromUtf8("MainWindow"))
        MainWindow.resize(800, 601)
        self.centralwidget = QtGui.QWidget(MainWindow)
        self.centralwidget.setObjectName(_fromUtf8("centralwidget"))
        self.verticalLayout = QtGui.QVBoxLayout(self.centralwidget)
        self.verticalLayout.setObjectName(_fromUtf8("verticalLayout"))
        self.horizontalLayout = QtGui.QHBoxLayout()
        self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout"))
        self.canvas = canvas(self.centralwidget)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding,
                                       QtGui.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.canvas.sizePolicy().hasHeightForWidth())
        self.canvas.setSizePolicy(sizePolicy)
        self.canvas.setObjectName(_fromUtf8("canvas"))
        self.horizontalLayout.addWidget(self.canvas)
        self.verticalLayout.addLayout(self.horizontalLayout)
        self.horizontalLayout_2 = QtGui.QHBoxLayout()
        self.horizontalLayout_2.setObjectName(_fromUtf8("horizontalLayout_2"))
        self.playButton = QtGui.QToolButton(self.centralwidget)
        self.playButton.setToolButtonStyle(QtCore.Qt.ToolButtonIconOnly)
        self.playButton.setAutoRaise(True)
        self.playButton.setObjectName(_fromUtf8("playButton"))
        self.horizontalLayout_2.addWidget(self.playButton)
        self.stopButton = QtGui.QToolButton(self.centralwidget)
        self.stopButton.setAutoRaise(True)
        self.stopButton.setObjectName(_fromUtf8("stopButton"))
        self.horizontalLayout_2.addWidget(self.stopButton)
        self.dummytoolButton = QtGui.QToolButton(self.centralwidget)
        self.dummytoolButton.setEnabled(False)
        self.dummytoolButton.setAutoRaise(True)
        self.dummytoolButton.setObjectName(_fromUtf8("dummytoolButton"))
        self.horizontalLayout_2.addWidget(self.dummytoolButton)
        self.openToolButton = QtGui.QToolButton(self.centralwidget)
        self.openToolButton.setAutoRaise(True)
        self.openToolButton.setObjectName(_fromUtf8("openToolButton"))
        self.horizontalLayout_2.addWidget(self.openToolButton)
        self.saveSnapButton = QtGui.QToolButton(self.centralwidget)
        self.saveSnapButton.setAutoRaise(True)
        self.saveSnapButton.setObjectName(_fromUtf8("saveSnapButton"))
        self.horizontalLayout_2.addWidget(self.saveSnapButton)
        self.saveMovieButton = QtGui.QToolButton(self.centralwidget)
        self.saveMovieButton.setAutoRaise(True)
        self.saveMovieButton.setObjectName(_fromUtf8("saveMovieButton"))
        self.horizontalLayout_2.addWidget(self.saveMovieButton)
        self.dummy2ToolButton = QtGui.QToolButton(self.centralwidget)
        self.dummy2ToolButton.setEnabled(False)
        self.dummy2ToolButton.setAutoRaise(True)
        self.dummy2ToolButton.setObjectName(_fromUtf8("dummy2ToolButton"))
        self.horizontalLayout_2.addWidget(self.dummy2ToolButton)
        self.plotToolButton = QtGui.QToolButton(self.centralwidget)
        self.plotToolButton.setAutoRaise(True)
        self.plotToolButton.setObjectName(_fromUtf8("plotToolButton"))
        self.horizontalLayout_2.addWidget(self.plotToolButton)
        spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding,
                                       QtGui.QSizePolicy.Minimum)
        self.horizontalLayout_2.addItem(spacerItem)
        self.verticalLayout.addLayout(self.horizontalLayout_2)
        self.timeSlider = QtGui.QSlider(self.centralwidget)
        self.timeSlider.setOrientation(QtCore.Qt.Horizontal)
        self.timeSlider.setObjectName(_fromUtf8("timeSlider"))
        self.verticalLayout.addWidget(self.timeSlider)
        MainWindow.setCentralWidget(self.centralwidget)
        self.menubar = QtGui.QMenuBar(MainWindow)
        self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 25))
        self.menubar.setObjectName(_fromUtf8("menubar"))
        self.menuFile = QtGui.QMenu(self.menubar)
        self.menuFile.setObjectName(_fromUtf8("menuFile"))
        self.menu_Export = QtGui.QMenu(self.menuFile)
        self.menu_Export.setObjectName(_fromUtf8("menu_Export"))
        self.menuView = QtGui.QMenu(self.menubar)
        self.menuView.setObjectName(_fromUtf8("menuView"))
        self.menu_Help = QtGui.QMenu(self.menubar)
        self.menu_Help.setObjectName(_fromUtf8("menu_Help"))
        MainWindow.setMenuBar(self.menubar)
        self.statusbar = QtGui.QStatusBar(MainWindow)
        self.statusbar.setObjectName(_fromUtf8("statusbar"))
        MainWindow.setStatusBar(self.statusbar)
        self.actionOpen = QtGui.QAction(MainWindow)
        self.actionOpen.setObjectName(_fromUtf8("actionOpen"))
        self.actionSaveAsSnapshot = QtGui.QAction(MainWindow)
        self.actionSaveAsSnapshot.setObjectName(
            _fromUtf8("actionSaveAsSnapshot"))
        self.actionQuit = QtGui.QAction(MainWindow)
        self.actionQuit.setObjectName(_fromUtf8("actionQuit"))
        self.actionBinProperties = QtGui.QAction(MainWindow)
        self.actionBinProperties.setObjectName(
            _fromUtf8("actionBinProperties"))
        self.actionDocumentation = QtGui.QAction(MainWindow)
        self.actionDocumentation.setObjectName(
            _fromUtf8("actionDocumentation"))
        self.actionAbout = QtGui.QAction(MainWindow)
        self.actionAbout.setObjectName(_fromUtf8("actionAbout"))
        self.actionPlay = QtGui.QAction(MainWindow)
        self.actionPlay.setObjectName(_fromUtf8("actionPlay"))
        self.actionBlenderScript = QtGui.QAction(MainWindow)
        self.actionBlenderScript.setObjectName(
            _fromUtf8("actionBlenderScript"))
        self.actionClearAll = QtGui.QAction(MainWindow)
        self.actionClearAll.setObjectName(_fromUtf8("actionClearAll"))
        self.actionSaveAsMovie = QtGui.QAction(MainWindow)
        self.actionSaveAsMovie.setObjectName(_fromUtf8("actionSaveAsMovie"))
        self.actionStop = QtGui.QAction(MainWindow)
        self.actionStop.setObjectName(_fromUtf8("actionStop"))
        self.menu_Export.addAction(self.actionBlenderScript)
        self.menuFile.addAction(self.actionOpen)
        self.menuFile.addAction(self.actionSaveAsMovie)
        self.menuFile.addAction(self.actionSaveAsSnapshot)
        self.menuFile.addAction(self.actionPlay)
        self.menuFile.addAction(self.actionStop)
        self.menuFile.addAction(self.actionClearAll)
        self.menuFile.addAction(self.menu_Export.menuAction())
        self.menuFile.addAction(self.actionQuit)
        self.menuView.addAction(self.actionBinProperties)
        self.menu_Help.addAction(self.actionDocumentation)
        self.menu_Help.addAction(self.actionAbout)
        self.menubar.addAction(self.menuFile.menuAction())
        self.menubar.addAction(self.menuView.menuAction())
        self.menubar.addAction(self.menu_Help.menuAction())

        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)
Beispiel #31
0
            QImage(data, data.shape[1], data.shape[0], data.strides[0],
                   QImage.Format_RGB888))
        gc.collect()
        self.image.setPixmap(pixmap)


if __name__ == '__main__':
    argv_list = sys.argv

    if (len(argv_list) == 1):
        app = QApplication(sys.argv)
        graphic = graphic()
        sys.exit(app.exec_())

    if (len(argv_list) == 2):
        my_canvas = canvas.canvas()
        if_last = 0
        input_file = argv_list[1]
        with open(input_file, 'r') as cmd_file:
            cmd = cmd_file.readlines()
            last_cmd = ''
            if_last = 0
            for i in cmd:

                origin = i
                if (if_last == 1):
                    last_cmd = last_cmd.replace('\n', '')
                    i = last_cmd + ' ' + i
                i = i.replace('\n', '')
                tmp_list = i.split(' ')
                if (len(tmp_list) == 1):
Beispiel #32
0
    def setupUi(self, MainWindow):
        MainWindow.setObjectName(_fromUtf8("MainWindow"))
        MainWindow.resize(800, 601)
        self.centralwidget = QtGui.QWidget(MainWindow)
        self.centralwidget.setObjectName(_fromUtf8("centralwidget"))
        self.verticalLayout = QtGui.QVBoxLayout(self.centralwidget)
        self.verticalLayout.setObjectName(_fromUtf8("verticalLayout"))
        self.horizontalLayout = QtGui.QHBoxLayout()
        self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout"))
        self.canvas = canvas(self.centralwidget)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.canvas.sizePolicy().hasHeightForWidth())
        self.canvas.setSizePolicy(sizePolicy)
        self.canvas.setObjectName(_fromUtf8("canvas"))
        self.horizontalLayout.addWidget(self.canvas)
        self.verticalLayout.addLayout(self.horizontalLayout)
        self.horizontalLayout_2 = QtGui.QHBoxLayout()
        self.horizontalLayout_2.setObjectName(_fromUtf8("horizontalLayout_2"))
        self.playButton = QtGui.QToolButton(self.centralwidget)
        self.playButton.setToolButtonStyle(QtCore.Qt.ToolButtonIconOnly)
        self.playButton.setAutoRaise(True)
        self.playButton.setObjectName(_fromUtf8("playButton"))
        self.horizontalLayout_2.addWidget(self.playButton)
        self.stopButton = QtGui.QToolButton(self.centralwidget)
        self.stopButton.setAutoRaise(True)
        self.stopButton.setObjectName(_fromUtf8("stopButton"))
        self.horizontalLayout_2.addWidget(self.stopButton)
        self.dummytoolButton = QtGui.QToolButton(self.centralwidget)
        self.dummytoolButton.setEnabled(False)
        self.dummytoolButton.setAutoRaise(True)
        self.dummytoolButton.setObjectName(_fromUtf8("dummytoolButton"))
        self.horizontalLayout_2.addWidget(self.dummytoolButton)
        self.openToolButton = QtGui.QToolButton(self.centralwidget)
        self.openToolButton.setAutoRaise(True)
        self.openToolButton.setObjectName(_fromUtf8("openToolButton"))
        self.horizontalLayout_2.addWidget(self.openToolButton)
        self.saveSnapButton = QtGui.QToolButton(self.centralwidget)
        self.saveSnapButton.setAutoRaise(True)
        self.saveSnapButton.setObjectName(_fromUtf8("saveSnapButton"))
        self.horizontalLayout_2.addWidget(self.saveSnapButton)
        self.saveMovieButton = QtGui.QToolButton(self.centralwidget)
        self.saveMovieButton.setAutoRaise(True)
        self.saveMovieButton.setObjectName(_fromUtf8("saveMovieButton"))
        self.horizontalLayout_2.addWidget(self.saveMovieButton)
        self.dummy2ToolButton = QtGui.QToolButton(self.centralwidget)
        self.dummy2ToolButton.setEnabled(False)
        self.dummy2ToolButton.setAutoRaise(True)
        self.dummy2ToolButton.setObjectName(_fromUtf8("dummy2ToolButton"))
        self.horizontalLayout_2.addWidget(self.dummy2ToolButton)
        self.plotToolButton = QtGui.QToolButton(self.centralwidget)
        self.plotToolButton.setAutoRaise(True)
        self.plotToolButton.setObjectName(_fromUtf8("plotToolButton"))
        self.horizontalLayout_2.addWidget(self.plotToolButton)
        spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
        self.horizontalLayout_2.addItem(spacerItem)
        self.verticalLayout.addLayout(self.horizontalLayout_2)
        self.timeSlider = QtGui.QSlider(self.centralwidget)
        self.timeSlider.setOrientation(QtCore.Qt.Horizontal)
        self.timeSlider.setObjectName(_fromUtf8("timeSlider"))
        self.verticalLayout.addWidget(self.timeSlider)
        MainWindow.setCentralWidget(self.centralwidget)
        self.menubar = QtGui.QMenuBar(MainWindow)
        self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 25))
        self.menubar.setObjectName(_fromUtf8("menubar"))
        self.menuFile = QtGui.QMenu(self.menubar)
        self.menuFile.setObjectName(_fromUtf8("menuFile"))
        self.menu_Export = QtGui.QMenu(self.menuFile)
        self.menu_Export.setObjectName(_fromUtf8("menu_Export"))
        self.menuView = QtGui.QMenu(self.menubar)
        self.menuView.setObjectName(_fromUtf8("menuView"))
        self.menu_Help = QtGui.QMenu(self.menubar)
        self.menu_Help.setObjectName(_fromUtf8("menu_Help"))
        MainWindow.setMenuBar(self.menubar)
        self.statusbar = QtGui.QStatusBar(MainWindow)
        self.statusbar.setObjectName(_fromUtf8("statusbar"))
        MainWindow.setStatusBar(self.statusbar)
        self.actionOpen = QtGui.QAction(MainWindow)
        self.actionOpen.setObjectName(_fromUtf8("actionOpen"))
        self.actionSaveAsSnapshot = QtGui.QAction(MainWindow)
        self.actionSaveAsSnapshot.setObjectName(_fromUtf8("actionSaveAsSnapshot"))
        self.actionQuit = QtGui.QAction(MainWindow)
        self.actionQuit.setObjectName(_fromUtf8("actionQuit"))
        self.actionBinProperties = QtGui.QAction(MainWindow)
        self.actionBinProperties.setObjectName(_fromUtf8("actionBinProperties"))
        self.actionDocumentation = QtGui.QAction(MainWindow)
        self.actionDocumentation.setObjectName(_fromUtf8("actionDocumentation"))
        self.actionAbout = QtGui.QAction(MainWindow)
        self.actionAbout.setObjectName(_fromUtf8("actionAbout"))
        self.actionPlay = QtGui.QAction(MainWindow)
        self.actionPlay.setObjectName(_fromUtf8("actionPlay"))
        self.actionBlenderScript = QtGui.QAction(MainWindow)
        self.actionBlenderScript.setObjectName(_fromUtf8("actionBlenderScript"))
        self.actionClearAll = QtGui.QAction(MainWindow)
        self.actionClearAll.setObjectName(_fromUtf8("actionClearAll"))
        self.actionSaveAsMovie = QtGui.QAction(MainWindow)
        self.actionSaveAsMovie.setObjectName(_fromUtf8("actionSaveAsMovie"))
        self.actionStop = QtGui.QAction(MainWindow)
        self.actionStop.setObjectName(_fromUtf8("actionStop"))
        self.menu_Export.addAction(self.actionBlenderScript)
        self.menuFile.addAction(self.actionOpen)
        self.menuFile.addAction(self.actionSaveAsMovie)
        self.menuFile.addAction(self.actionSaveAsSnapshot)
        self.menuFile.addAction(self.actionPlay)
        self.menuFile.addAction(self.actionStop)
        self.menuFile.addAction(self.actionClearAll)
        self.menuFile.addAction(self.menu_Export.menuAction())
        self.menuFile.addAction(self.actionQuit)
        self.menuView.addAction(self.actionBinProperties)
        self.menu_Help.addAction(self.actionDocumentation)
        self.menu_Help.addAction(self.actionAbout)
        self.menubar.addAction(self.menuFile.menuAction())
        self.menubar.addAction(self.menuView.menuAction())
        self.menubar.addAction(self.menu_Help.menuAction())

        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)
Beispiel #33
0
elif sys.argv[1] == 'emailClearCache':
    os.chdir(subdirName)        
    if len(sys.argv) > 2:
        emailClearCache(sys.argv[2:])
    else:
        emailClearCache(dirs)

elif sys.argv[1] == 'stats' or sys.argv[1] == 'stat':
    os.chdir(subdirName)
    if len(sys.argv) > 2:
        stats(sys.argv[2:])
    else:
        stats(dirs)

elif sys.argv[1] == 'download':
    c = canvas.canvas()
    if len(sys.argv) == 2:
        c.downloadAssignment(courseName=courseName, assignmentName=assignmentName, subdirName=subdirName)
    elif len(sys.argv) == 3:
        c.downloadAssignment(courseName=courseName, assignmentName=assignmentName, subdirName=subdirName, userid=sys.argv[2])
    elif len(sys.argv) == 4:
        # Delete the any existing submission with the given name
        if os.path.exists(os.path.join(subdirName, sys.argv[2])):
            shutil.rmtree(os.path.join(subdirName, sys.argv[2]))
        c.downloadAssignment(courseName=courseName, assignmentName=assignmentName, subdirName=subdirName, userid=sys.argv[2], attempt=int(sys.argv[3]))
    else:
        print("Usage:")
        print(" ag.py download   --> downloads all non-late submissions")
        print(" ag.py download username attempt# --> downloads one specific submission (even if it is late)")
        exit(1)
Beispiel #34
0
# Configure the server for the assignment we're checking
config = autograder.config()
settings = config.get()
homework_dir_name = settings['subdirName']
homework_path = os.path.abspath(homework_dir_name)
course_name = settings['courseName']
assignment_name = settings['assignmentName']

# Collect list of all program files we're expecting to find
ref_homework_dir = os.path.abspath('../reference/' + homework_dir_name)
# Collect list of all program files we're expecting to find
reference_soln = None
with open(ref_homework_dir + "/" + homework_dir_name + ".json", "r") as ref:
    reference_soln = json.load(ref)

c = canvas.canvas()
courses = c.getCourses()
course_id = c.findCourseId(courses, 'ME EN 6250-001 Fall 2016 Programming for Engin')
c = canvas.canvas(courseId=course_id)

# A dict of the students that have submitted so far, and the number of times
# they've submitted
student_submission_count = {}

# Check for new submissions and grade them
def grade_new_submissions():
    print("Checking for new submissions")
    students = c.downloadAssignment(courseName=course_name, assignmentName=assignment_name,
            subdirName=homework_path, allowLate=True)
    print("Downloaded new submissions from {}".format(students))
    # Check if there's any students we failed to grade and comment on
Beispiel #35
0
import canvas
import random
canvas = canvas.canvas(32, 24)
while True:
    canvas.draw()
    canvas.pixel(random.randrange(0, 32), random.randrange(0, 24), random.randrange(0, 3))