Exemple #1
0
def setup():
    ratio = 1.8
    pf.size(1280 / ratio, 720 / ratio)
    pf.text_font(font)
    pf.text_size(50)
    pf.no_stroke()
    pf.no_loop()
Exemple #2
0
def setup():
    size(640, 360)
    no_stroke()
    background(0)
    global perlx
    global perly
    perlx = random_uniform(1000)
    perly = 0
Exemple #3
0
def draw():
    # Arka planı siyah yap
    p5.background(0)
    # Orijini pencerenin merkezine taşı
    p5.translate(width / 2, height / 2)

    # clock fonsiyonundan gelen değerleri
    # sırasıyla h, m ve s değişkenlerine ata
    h, m, s = clock()

    # Çevre çizgisi çizme
    p5.no_stroke()

    # [0, 360) aralığında 6'şar derece aralıklarla değer oluştur
    # 0, 6, 12, ...,  342, 348, 354
    for i in range(0, 360, 6):

        # Kutupsal koordinat sisteminde
        # (r_d, i) değerini kartezyen koordinat sistemine dönüştür
        d_x, d_y = pol2car(r_d, i)

        # i değeri 30'un tam katıysa,
        if i % 30 == 0:
            # saat değerleri için nokta koyacağız
            p5.fill(255, 0, 0)
            r = 15
        else:
            # dakika/saniye değerleri için nokta koyacağız
            p5.fill(255)
            r = 10

        # Belirlenen özelliklerle hesaplanan noktada
        # bir daire çiz
        p5.circle((d_x, d_y), r)

    # Akrep kolunun ucunun konumunu hesala
    h_x, h_y = pol2car(r_h, h)
    # Akrep kolunun şekil ayarlarını yap
    p5.stroke(255)
    p5.stroke_weight(5)
    # Akrep konu çiz
    p5.line((0, 0), (h_x, h_y))

    # Yelkovan kolunun ucunun konumunu hesala
    m_x, m_y = pol2car(r_m, m)
    # Yelkovan kolunun şekil ayarlarını yap
    p5.stroke(255)
    p5.stroke_weight(3)
    # Yelkovan konu çiz
    p5.line((0, 0), (m_x, m_y))

    # Saniye kolunun ucunun konumunu hesala
    s_x, s_y = pol2car(r_s, s)
    # Saniye kolunun şekil ayarlarını yap
    p5.stroke(255, 0, 0)
    p5.stroke_weight(1)
    # Saniye konu çiz
    p5.line((0, 0), (s_x, s_y))
Exemple #4
0
 def rect(self):
     if self.is_rect:
         with pf.push_style():
             if not self.is_stroke and not self.is_fill:
                 return
             pf.color_mode("RGB")
             if self.is_fill:
                 pf.fill(*self.fill_rgb)
             else:
                 pf.no_fill()
             if self.is_stroke:
                 pf.stroke_weight(self.stroke_weight)
                 pf.stroke(*self.stroke_rgb)
             else:
                 pf.no_stroke()
             pf.rect([self.get_rect_x(), self.get_rect_y()], self.w, self.h)
Exemple #5
0
def draw():
    # Arka alanı siyah yap
    p5.background(0)
    # Orijini (Yani (0, 0) noktasını) pencerenin ortasına taşı
    p5.translate(w / 2, h / 2)

    # Analog saatte, saat değerlerinin olduğu konumlara
    # kırmızı noktalar koymak için döngü
    # [0, 360) aralığında 30'ar derece açılarla değer oluştur:
    # Böylece 0, 30, 60, ..., 270, 300, 330 değerleri elde edilecek
    for i in range(0, 360, 30):
        # Her bir açı için x ve y konumlarını hesapla
        x = r * math.cos(math.radians(i))
        y = r * math.sin(math.radians(i))

        # Çizilecek nesnenin içini kırmızı renk ile doldur
        p5.fill(255, 0, 0)
        # Çizilecek nesne için çevre çizgisi çizme
        p5.no_stroke()
        # x ve y konumuna 15 piksel çapında bir daire çiz.
        p5.circle((x, y), 15)

    # Analog saatte, dakika değerlerinin olduğu konumlara
    # beyaz noktalar koymak için döngü
    # [0, 360) aralığında 6'şar derece açılarla değer oluştur:
    # Böylece 0, 6, 12, ..., 342, 348, 354 değerleri elde edilecek
    for u in range(0, 360, 6):
        # Eğer u açısı 30'a tm bölünebiliyorsa işlemi YAPMA
        if u % 30:
            # Her bir açı için x ve y konumlarını hesapla
            x = r * math.cos(math.radians(u))
            y = r * math.sin(math.radians(u))

            # Çizilecek nesnenin içini beyaz renk ile doldur
            p5.fill(255)
            # Çizilecek nesne için çevre çizgisi çizme
            p5.no_stroke()
            # x ve y konumuna 10 piksel çapında bir daire çiz.
            p5.circle((x, y), 10)
Exemple #6
0
def draw():
    if verbose:
        print(f"Drawing background.")
    background('#ffffff')
    no_stroke()

    # draw non-organic elements
    if verbose:
        print(f"Drawing shapes...")
    for i, row in df[(df.area_page != 0)
                     & (~df.label.isin(['organic', 'ads']))].iterrows():
        dimensions = row['dimensions']
        location = row['location']
        category = row['category']
        color = cat2color[category.split('-')[0]]

        h = dimensions['height']
        w = dimensions['width']
        x = location['x']
        y = location['y']

        c = fill(color)
        rect((x, y), w, h)

    for i, row in df[(df.area_page != 0) & (df.label == 'ads')].iterrows():
        dimensions = row['dimensions']
        location = row['location']
        category = row['category']
        color = cat2color[category.split('-')[0]]

        h = dimensions['height']
        w = dimensions['width']
        x = location['x']
        y = location['y']

        c = fill(color)
        rect((x, y), w, h)

    # draw organic elements
    for i, row in df[(df.area_page != 0) & (df.label == 'organic')].iterrows():
        dimensions = row['dimensions']
        location = row['location']
        category = row['category']
        color = cat2color[category.split('-')[0]]

        h = dimensions['height']
        w = dimensions['width']
        x = location['x']
        y = location['y']

        c = fill(color)
        rect((x, y), w, h)

    # draw buttons elements
    for i, row in df[(df.area_page != 0)
                     & (df.category == 'link-button')].iterrows():
        dimensions = row['dimensions']
        location = row['location']
        category = row['category']
        color = cat2color[category.split('-')[0]]

        h = dimensions['height']
        w = dimensions['width']
        x = location['x']
        y = location['y']

        c = fill(color)
        rect((x, y), w, h)

    if fn_img:
        tint(255, 60)
        image(img, (0, 0))

    if verbose:
        print(f"Saving file")

    # save the file...
    save(fn_out)
    os.rename(fn_out.replace('.png', '0000.png'), fn_out)
    # draw reference image
    if verbose:
        print(f"Done.")
    exit()
Exemple #7
0
def setup():
    p.size(width, height)
    p.color_mode('HSB')
    p.no_stroke()
    p.no_loop()
Exemple #8
0
def setup():
    p.size(width, height)
    p.no_stroke()
    p.no_loop()
 def addCircle(self, x, y, r, color=WHITE):
     with p5.push_style():
         p5.no_stroke()
         p5.fill(*color)
         p5.circle((x, y), 2*r)
Exemple #10
0
def draw():
    global corner_handle

    p5.background(0)

    with p5.push_matrix():
        p5.apply_matrix(canvas_surface.get_transform_mat())

        # GIS shapes and objects
        if show_basemap:
            _gis.draw_basemap()

        if show_shapes:
            _gis.draw_polygon_layer(buildings, 0, 1, p5.Color(96, 205, 21),
                                    p5.Color(213, 50, 21), 'co2')
            _gis.draw_polygon_layer(typologiezonen, 0, 1,
                                    p5.Color(123, 201, 230, 50))
            _gis.draw_linestring_layer(nahwaermenetz, p5.Color(217, 9, 9), 3)
            _gis.draw_polygon_layer(waermezentrale, 0, 1,
                                    p5.Color(252, 137, 0))

            # find buildings intersecting with selected grid cells
            buildings['selected'] = False

            for y, row in enumerate(_grid.grid):
                for x, cell in enumerate(row):
                    if cell.selected:
                        # get viewport coordinates of the cell rectangle
                        cell_vertices = _grid.surface.transform([[
                            _x, _y
                        ] for _x, _y in [[x, y], [x + 1, y], [x + 1, y +
                                                              1], [x, y + 1]]])
                        ii = _gis.get_intersection_indexer(
                            buildings, cell_vertices)
                        buildings.loc[ii, 'selected'] = True

            # highlight selected buildings
            _gis.draw_polygon_layer(buildings[buildings.selected],
                                    p5.Color(255, 0, 127), 2, None)

        # grid
        if show_grid:
            _grid.draw(p5.Color(255, 255, 255), 1)

        # mask
        border = 1000
        with p5.push_style():
            p5.fill(p5.Color(0, 0, 0))
            p5.rect(-border, -border, width + 2 * border, border)
            p5.rect(-border, height, width + 2 * border, height + border)
            p5.rect(-border, -border, border, height + 2 * border)
            p5.rect(width, -border, width + border, height + 2 * border)

    # get the drag handle (if the mouse hovers over it)
    corner_handle = canvas_surface.get_corner_handle(20)

    if corner_handle:
        with p5.push_style():
            p5.no_stroke()
            p5.fill(p5.Color(255, 255, 255, 200))
            p5.circle(list(corner_handle)[0], list(corner_handle)[1], 20)