Beispiel #1
0
    def process(self):
        if CTM() > self.start + 50:
            self.ang = math.radians(glm.simplex(self.pos) * 360.0)
            self.start = CTM()

        self.rot = glm.vec2(
            glm.vec4(1) * glm.rotate(glm.mat4(), self.ang, [0, 0, 1]))
        self.pre = int(self.pos.x), int(self.pos.y)
        self.pos += self.rot * rl.GetFrameTime() * 64
        rl.DrawLine(int(self.pos.x), int(self.pos.y), *self.pre, self.clr)

        if self.pos.x < 0: self.pos.x = rl.GetScreenWidth() - 1
        if self.pos.y < 0: self.pos.y = rl.GetScreenHeight() - 1
        if self.pos.x >= rl.GetScreenWidth(): self.pos.x = 0
        if self.pos.y >= rl.GetScreenHeight(): self.pos.y = 0

        hlf = self.scl // 2
        self.mem = int(self.pos.x) - hlf, int(self.pos.y) - hlf
        rl.DrawRectangle(*self.mem, self.scl if not BEES else hlf, self.scl,
                         self.clr)
        if BEES:
            rl.DrawRectangle(self.mem[0] + hlf, self.mem[1], hlf, self.scl,
                             [0, 0, 0, 55])
Beispiel #2
0
    if drag:
        window_pos += mouse_pos - offset
        drag = not rl.IsMouseButtonReleased(rl.MOUSE_LEFT_BUTTON)
        rl.SetWindowPosition(int(window_pos.x), int(window_pos.y))

        if not drag:
            window_vel = (mouse_pos - offset) * glm.vec2(1, 0.6) * 0.8
            if any(glm.isnan(window_vel)):
                window_vel = glm.vec2()

    rl.BeginDrawing()
    rl.ClearBackground([0] * 4)

    rl.BeginTextureMode(target)
    rl.ClearBackground([0] * 4)
    rl.DrawRectangle(0, 0, width, height, [0] * 4)

    rl.DrawTextureEx(
        awd,
        tween.getPointOnLine(*start1, *end1, tween.easeInOutQuad(elapsed)),
        0,
        32,
        [255, 200, 0, trans]  # Yellow
    )

    rl.DrawTextureEx(
        awd,
        tween.getPointOnLine(*start2, *end2, tween.easeInOutQuad(elapsed)),
        -90,
        32,
        [255, 0, 55, trans]  # Red
Beispiel #3
0
]
while not rl.WindowShouldClose():
    if (rl.GetScreenWidth(), rl.GetScreenHeight()) != dims:
        canvas = rl.LoadRenderTexture(rl.GetScreenWidth(),
                                      rl.GetScreenHeight())
        rl.SetTextureWrap(canvas.texture, rl.WRAP_MIRROR_REPEAT)
        ini = False
        dims = rl.GetScreenWidth(), rl.GetScreenHeight()

    rl.BeginDrawing()

    rl.BeginTextureMode(canvas)
    if not ini:
        rl.ClearBackground([200, 200, 0, 255] if BEES else WHITE)
        if BEES:
            rl.DrawRectangle(0, 0, dims[0], dims[1] // 2, (0, 200, 255, 255))
            rl.DrawCircle(dims[0] - 72, 72, 32, [255, 200, 0, 255])
        else:
            ini = True

    for part in parts:
        part.process()

    rl.EndTextureMode()

    tex = canvas.texture
    rl.DrawTexturePro(tex, [0.0, 0.0, tex.width, -tex.height],
                      [0, 0, tex.width, tex.height], [0, 0], 0.0, WHITE)

    rl.EndDrawing()
Beispiel #4
0
        file_count = ffi.new('int *')
        files = rl.GetDroppedFiles(file_count)
        files = [ffi.string(files[i]).decode() for i in range(file_count[0])]
        rl.ClearDroppedFiles()
    return files


while not rl.WindowShouldClose():
    for file in get_dropped_files():
        h = Haishoku.loadHaishoku(file)
        colors = {str(blob): blob[1] for blob in h.palette}

    rl.BeginDrawing()
    rl.ClearBackground(WHITE)

    x, y = 0, 0
    for name, color in colors.items():
        r, g, b = color
        rl.DrawRectangle(x, y, TILE_SIZE, TILE_SIZE, (r, g, b, 255))
        x += TILE_SIZE
        if x > WIDTH:
            x = 0
            y += TILE_SIZE

    rl.EndDrawing()

    if rl.IsKeyPressed(rl.KEY_E):
        rl.TakeScreenshot(b'pallet.png')

rl.CloseWindow()