Skip to content

Commit

Permalink
text_tools and texture_tools moved into root directory.
Browse files Browse the repository at this point in the history
  • Loading branch information
salt-die committed Jul 22, 2024
1 parent 46cb93c commit 2c3f1aa
Show file tree
Hide file tree
Showing 35 changed files with 67 additions and 68 deletions.
2 changes: 1 addition & 1 deletion examples/advanced/exploding_logo_redux.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
particle_data_from_texture,
)
from batgrl.gadgets.image import Image, Size
from batgrl.gadgets.texture_tools import read_texture, resize_texture
from batgrl.texture_tools import read_texture, resize_texture

LOGO_SIZE = Size(36, 36)
POWER = 2
Expand Down
2 changes: 1 addition & 1 deletion examples/advanced/infinite_tictactoe.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from batgrl.gadgets.gadget import Gadget
from batgrl.gadgets.grid_layout import GridLayout
from batgrl.gadgets.text import Text
from batgrl.gadgets.text_tools import add_text
from batgrl.text_tools import add_text

BLUES = [Color.from_hex(hexcode) for hexcode in ["2412e8", "170b93", "09053f"]]
REDS = [Color.from_hex(hexcode) for hexcode in ["ea1212", "930b0b", "3d0404"]]
Expand Down
2 changes: 1 addition & 1 deletion examples/advanced/isotiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
from batgrl.colors import AWHITE
from batgrl.gadgets.graphics import Graphics, Point, Size
from batgrl.gadgets.scroll_view import ScrollView
from batgrl.gadgets.texture_tools import composite, read_texture
from batgrl.terminal.events import MouseEvent
from batgrl.texture_tools import composite, read_texture

ASSETS = Path(__file__).parent.parent / "assets"
TILES_PATH = ASSETS / "isometric_demo.png"
Expand Down
4 changes: 2 additions & 2 deletions examples/advanced/raycasting.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
from batgrl.colors import GREEN
from batgrl.gadgets.raycaster import Raycaster, RaycasterCamera, RgbaTexture, Sprite
from batgrl.gadgets.text_raycaster import TextRaycaster
from batgrl.gadgets.text_tools import cell
from batgrl.gadgets.texture_tools import read_texture
from batgrl.gadgets.video import Video
from batgrl.geometry import lerp
from batgrl.text_tools import cell
from batgrl.texture_tools import read_texture


def load_assets():
Expand Down
3 changes: 2 additions & 1 deletion examples/advanced/rigid_body_physics.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Requires `pymunk`
"""

import asyncio
from math import ceil, degrees
from pathlib import Path
Expand All @@ -15,7 +16,7 @@
from batgrl.colors import AWHITE, AColor
from batgrl.gadgets.graphics import Graphics
from batgrl.gadgets.image import Image
from batgrl.gadgets.texture_tools import composite, read_texture, resize_texture
from batgrl.texture_tools import composite, read_texture, resize_texture
from pymunk.vec2d import Vec2d

BOX_SIZE = W, H = Vec2d(9, 9)
Expand Down
2 changes: 1 addition & 1 deletion examples/advanced/sliding_puzzle.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from batgrl.app import run_gadget_as_app
from batgrl.colors import ABLACK, AWHITE
from batgrl.gadgets.graphics import Graphics
from batgrl.gadgets.texture_tools import read_texture, resize_texture
from batgrl.texture_tools import read_texture, resize_texture

ASSETS = Path(__file__).parent.parent / "assets"
PATH_TO_LOGO = ASSETS / "python_discord_logo.png"
Expand Down
2 changes: 1 addition & 1 deletion examples/advanced/tetris/tetris/tetris.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from batgrl.gadgets.graphics import Graphics
from batgrl.gadgets.image import Image
from batgrl.gadgets.text import Text
from batgrl.gadgets.texture_tools import composite
from batgrl.texture_tools import composite

from .matrix import MatrixGadget
from .modal_screen import ModalScreen
Expand Down
2 changes: 1 addition & 1 deletion examples/basic/io_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

from batgrl.app import App
from batgrl.gadgets.text import Text
from batgrl.gadgets.text_tools import add_text
from batgrl.terminal.events import FocusEvent, KeyEvent, MouseEvent, PasteEvent
from batgrl.text_tools import add_text


class ShowIOEvents(Text):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@
This module is adapted from `https://github.com/miyuchina/mistletoe/blob/master/mistletoe/core_tokens.py`.
`mistletoe` is licensed under the MIT license.
"""

import sys
from string import punctuation
from typing import Literal
from unicodedata import category

from ..geometry import clamp
from .geometry import clamp

DELIMITERS = set("*_~^")
WHITESPACE = set(
Expand Down
File renamed without changes.
3 changes: 2 additions & 1 deletion src/batgrl/figfont.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- http://www.figlet.org/fontdb.cgi
- https://github.com/salt-die/fig-fonts
"""

import re
import zipfile
from dataclasses import dataclass, field, fields
Expand All @@ -28,7 +29,7 @@
import numpy as np
from numpy.typing import NDArray

from .gadgets.text_tools import char_width, str_width
from .text_tools import char_width, str_width

__all__ = ["FullLayout", "FIGFont"]

Expand Down
2 changes: 1 addition & 1 deletion src/batgrl/gadgets/_root.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
from ..app import App

from ..colors import Color
from ..text_tools import cell
from .gadget import Gadget, Point, Region, Size
from .text_tools import cell


class _Root(Gadget):
Expand Down
2 changes: 1 addition & 1 deletion src/batgrl/gadgets/bar_chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from numbers import Real

from ..colors import DEFAULT_PRIMARY_BG, DEFAULT_PRIMARY_FG, Color, rainbow_gradient
from ..text_tools import add_text, smooth_vertical_bar, str_width
from .gadget import (
Gadget,
Point,
Expand All @@ -16,7 +17,6 @@
from .pane import Pane
from .scroll_view import ScrollView
from .text import Text, cell
from .text_tools import add_text, smooth_vertical_bar, str_width

__all__ = ["BarChart", "Point", "Size"]

Expand Down
2 changes: 1 addition & 1 deletion src/batgrl/gadgets/box_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import cv2
import numpy as np

from ..text_tools import binary_to_box
from .gadget import (
Gadget,
Point,
Expand All @@ -15,7 +16,6 @@
SizeHintDict,
)
from .text import Text
from .text_tools import binary_to_box

__all__ = ["BoxImage", "Point", "Size"]

Expand Down
2 changes: 1 addition & 1 deletion src/batgrl/gadgets/braille_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import cv2
import numpy as np

from ..text_tools import binary_to_braille
from .gadget import (
Gadget,
Point,
Expand All @@ -15,7 +16,6 @@
SizeHintDict,
)
from .text import Text
from .text_tools import binary_to_braille

__all__ = ["BrailleImage", "Point", "Size"]

Expand Down
2 changes: 1 addition & 1 deletion src/batgrl/gadgets/braille_video.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

from ..colors import BLACK, WHITE, Color
from ..geometry import lerp
from ..text_tools import binary_to_braille
from .gadget import (
Gadget,
Point,
Expand All @@ -22,7 +23,6 @@
SizeHintDict,
)
from .text import Text
from .text_tools import binary_to_braille

__all__ = ["BrailleVideo", "Point", "Size"]

Expand Down
2 changes: 1 addition & 1 deletion src/batgrl/gadgets/file_chooser.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from collections.abc import Callable
from pathlib import Path

from ..text_tools import str_width
from .gadget import (
Gadget,
Point,
Expand All @@ -14,7 +15,6 @@
SizeHintDict,
)
from .scroll_view import ScrollView
from .text_tools import str_width
from .tree_view import TreeView, TreeViewNode

__all__ = ["FileChooser", "Point", "Size"]
Expand Down
2 changes: 1 addition & 1 deletion src/batgrl/gadgets/gadget.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from ..easings import EASINGS, Easing
from ..geometry import Point, Region, Size, clamp, lerp, round_down
from ..terminal.events import FocusEvent, KeyEvent, MouseEvent, PasteEvent
from .text_tools import Cell, cell
from ..text_tools import Cell, cell

__all__ = [
"Anchor",
Expand Down
2 changes: 1 addition & 1 deletion src/batgrl/gadgets/graphic_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from numpy.lib.recfunctions import structured_to_unstructured
from numpy.typing import NDArray

from ..texture_tools import _composite
from .gadget import (
Cell,
Gadget,
Expand All @@ -22,7 +23,6 @@
bindable,
clamp,
)
from .texture_tools import _composite

__all__ = ["GraphicParticleField", "particle_data_from_texture", "Point", "Size"]

Expand Down
2 changes: 1 addition & 1 deletion src/batgrl/gadgets/graphics.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from numpy.typing import NDArray

from ..colors import TRANSPARENT, AColor
from ..texture_tools import Interpolation, _composite, resize_texture
from .gadget import (
Cell,
Gadget,
Expand All @@ -19,7 +20,6 @@
bindable,
clamp,
)
from .texture_tools import Interpolation, _composite, resize_texture

__all__ = ["Graphics", "Interpolation", "Point", "Size"]

Expand Down
2 changes: 1 addition & 1 deletion src/batgrl/gadgets/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from numpy.typing import NDArray

from ..colors import TRANSPARENT, AColor
from ..texture_tools import read_texture, resize_texture
from .graphics import (
Graphics,
Interpolation,
Expand All @@ -16,7 +17,6 @@
SizeHint,
SizeHintDict,
)
from .texture_tools import read_texture, resize_texture

__all__ = ["Image", "Interpolation", "Point", "Size"]

Expand Down
2 changes: 1 addition & 1 deletion src/batgrl/gadgets/line_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

from ..colors import DEFAULT_PRIMARY_BG, DEFAULT_PRIMARY_FG, Color, rainbow_gradient
from ..terminal.events import MouseEvent
from ..text_tools import binary_to_box, binary_to_braille, str_width
from .behaviors.movable import Movable
from .gadget import (
Gadget,
Expand All @@ -24,7 +25,6 @@
from .pane import Pane
from .scroll_view import ScrollView
from .text import Text, add_text, cell
from .text_tools import binary_to_box, binary_to_braille, str_width

__all__ = ["LinePlot", "Point", "Size"]

Expand Down
2 changes: 1 addition & 1 deletion src/batgrl/gadgets/pane.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from numpy.typing import NDArray

from ..colors import BLACK, Color
from ..texture_tools import _composite
from .gadget import (
Cell,
Gadget,
Expand All @@ -15,7 +16,6 @@
bindable,
clamp,
)
from .texture_tools import _composite

__all__ = ["Pane", "Point", "Size"]

Expand Down
2 changes: 1 addition & 1 deletion src/batgrl/gadgets/progress_bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import asyncio
from itertools import chain, cycle

from ..text_tools import smooth_horizontal_bar, smooth_vertical_bar
from .behaviors.themable import Themable
from .gadget import (
Gadget,
Expand All @@ -16,7 +17,6 @@
clamp,
)
from .text import Text
from .text_tools import smooth_horizontal_bar, smooth_vertical_bar

__all__ = ["ProgressBar", "Point", "Size"]

Expand Down
2 changes: 1 addition & 1 deletion src/batgrl/gadgets/raycaster.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from numpy.typing import NDArray

from ..colors import BLACK, TRANSPARENT, AColor, Color
from ..texture_tools import _composite
from .graphics import (
Graphics,
Interpolation,
Expand All @@ -18,7 +19,6 @@
SizeHintDict,
clamp,
)
from .texture_tools import _composite

__all__ = ["Raycaster", "Sprite", "RaycasterCamera", "RgbaTexture", "Point", "Size"]

Expand Down
2 changes: 1 addition & 1 deletion src/batgrl/gadgets/scroll_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from ..colors import Color
from ..terminal.events import KeyEvent, MouseButton, MouseEvent
from ..text_tools import smooth_horizontal_bar, smooth_vertical_bar
from .behaviors.grabbable import Grabbable
from .behaviors.themable import Themable
from .gadget import (
Expand All @@ -17,7 +18,6 @@
)
from .pane import Pane
from .text import Text
from .text_tools import smooth_horizontal_bar, smooth_vertical_bar

__all__ = ["ScrollView", "Point", "Size"]

Expand Down
2 changes: 1 addition & 1 deletion src/batgrl/gadgets/sparkline.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

from ..colors import DEFAULT_PRIMARY_BG, DEFAULT_PRIMARY_FG, Color, lerp_colors
from ..terminal.events import MouseEvent
from ..text_tools import smooth_vertical_bar
from ._cursor import Cursor
from .gadget import (
Gadget,
Expand All @@ -19,7 +20,6 @@
SizeHintDict,
)
from .text import Text, add_text
from .text_tools import smooth_vertical_bar

__all__ = ["Sparkline", "Point", "Size"]

Expand Down
Loading

0 comments on commit 2c3f1aa

Please sign in to comment.