Skip to content

Commit 37b20ec

Browse files
committed
Change draw_npatch(...) to draw_texture_npatch(...); NPatch to NPatchInfo and added NPatchType enum.
1 parent 2cc5f5d commit 37b20ec

File tree

4 files changed

+39
-17
lines changed

4 files changed

+39
-17
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ build/
88
dist/
99
_unused
1010
test.py
11+
rayguipy.py
1112
templates/
1213
libraylib_shared_no9patch.dll
1314
libraylib_shared_pre9patch.dll

examples/core/core_2d_camera.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# core_2d_camera.py
22

3+
# import os
4+
# os.environ['RAYLIB_BIN_PATH'] = "C:/raylib/raylib/release/libs/win32/mingw32/"
5+
36
from raylibpy import *
47

58

@@ -101,8 +104,10 @@ def main():
101104

102105
draw_rectangle_rec(player, RED)
103106

107+
begin_clip_rec((0, 0, 400, 450))
104108
draw_rectangle(int(camera.target.x), int(-500), 1, screen_height * 4, GREEN)
105109
draw_rectangle(int(-500), int(camera.target.y), screen_width * 4, 1, GREEN)
110+
end_clip_rec()
106111

107112
end_mode2d()
108113

raylibpy/__init__.py

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
RAYLIB_BIN_PATH = os.path.dirname(sys.modules['__main__'].__file__)
4141
elif env_path == '__file__':
4242
RAYLIB_BIN_PATH = os.path.abspath(os.path.dirname(__file__))
43-
elif os.path.exists(env_path) and os.path.isfile(env_path):
43+
elif os.path.exists(env_path) and os.path.isdir(env_path):
4444
RAYLIB_BIN_PATH = env_path
4545
else:
4646
first_path = os.path.abspath(os.path.dirname(__file__))
@@ -297,7 +297,7 @@
297297
'WRAP_REPEAT',
298298
'WRAP_CLAMP',
299299
'WRAP_MIRROR',
300-
'TextureBlendMode',
300+
'BlendMode',
301301
'BLEND_ALPHA',
302302
'BLEND_ADDITIVE',
303303
'BLEND_MULTIPLIED',
@@ -329,7 +329,7 @@
329329
'HMD_OCULUS_GO',
330330
'HMD_VALVE_HTC_VIVE',
331331
'HMD_SONY_PSVR',
332-
'NPatchInfo',
332+
'NPatchType',
333333
'NPT_9PATCH',
334334
'NPT_3PATCH_VERTICAL',
335335
'NPT_3PATCH_HORIZONTAL',
@@ -363,7 +363,7 @@
363363
'Rectangle',
364364
'RenderTexture',
365365
'RenderTexture2D',
366-
'NPatch',
366+
'NPatchInfo',
367367
'Shader',
368368
'Sound',
369369
'SpriteFont',
@@ -601,7 +601,7 @@
601601
'draw_texture_ex',
602602
'draw_texture_rec',
603603
'draw_texture_pro',
604-
'draw_npatch',
604+
'draw_texture_npatch',
605605

606606
# Module: TEXT
607607
'get_font_default',
@@ -694,6 +694,8 @@
694694
'begin_shader_mode',
695695
'end_shader_mode',
696696
'begin_blend_mode',
697+
'begin_clip_rec',
698+
'end_clip_rec',
697699
'end_blend_mode',
698700
'get_vr_device_info',
699701
'init_vr_simulator',
@@ -1723,13 +1725,13 @@ def __str__(self) -> str:
17231725
return "(RENDERTEXTURE: {}w, {}h, texture: {}, depth: {})".format(self.width, self.height, self.texture, self.depth)
17241726

17251727

1726-
class NPatch(Structure):
1728+
class NPatchInfo(Structure):
17271729
_fields_ = [
1728-
('texture', Texture2D),
17291730
('sourceRec', Rectangle),
1730-
('minSize', Vector2),
1731-
('borderWidth', c_float * 4),
1732-
('padding', c_int * 4),
1731+
('left', c_int),
1732+
('top', c_int),
1733+
('right', c_int),
1734+
('bottom', c_int),
17331735
('type', c_int),
17341736
]
17351737

@@ -2271,8 +2273,8 @@ class CameraType(IntEnum):
22712273
CAMERA_ORTHOGRAPHIC = 1
22722274

22732275

2274-
CAMERA_PERSPECTIVE = CameraMode.CAMERA_PERSPECTIVE
2275-
CAMERA_ORTHOGRAPHIC = CameraMode.CAMERA_ORTHOGRAPHIC
2276+
CAMERA_PERSPECTIVE = CameraType.CAMERA_PERSPECTIVE
2277+
CAMERA_ORTHOGRAPHIC = CameraType.CAMERA_ORTHOGRAPHIC
22762278

22772279

22782280
class VrDeviceType(IntEnum):
@@ -2313,7 +2315,7 @@ def init_window(width: int, height: int, title: AnyStr) -> None:
23132315
return _rl.InitWindow(_int(width), _int(height), _str_in(title))
23142316

23152317

2316-
def init_window_v(size: Union[Vector, Seq], title: AnyStr) -> None:
2318+
def init_window_v(size: Union[Vector2, Seq], title: AnyStr) -> None:
23172319
"""Initialize window (with a sequence type as size) and OpenGL context"""
23182320
size = _vec2(size)
23192321
init_window(size.x, size.y, title)
@@ -3702,11 +3704,11 @@ def draw_texture_pro(texture: Texture2D, source_rec: Union[Rectangle, Seq], dest
37023704
"""Draw a part of a texture defined by a rectangle with 'pro' parameters"""
37033705
return _rl.DrawTexturePro(texture, _rect(source_rec), _rect(dest_rec), _vec2(origin), _float(rotation), _color(tint))
37043706

3705-
_rl.DrawNPatch.argtypes = [NPatch, Rectangle, Bool, Vector2, Float, Color]
3706-
_rl.DrawNPatch.restype = None
3707-
def draw_npatch(npatch: NPatch, dest_rec: Union[Rectangle, Seq], use_padding: bool, origin: Union[Vector2, Seq], rotation: float, tint: Union[Color, Seq]) -> None:
3707+
_rl.DrawTextureNPatch.argtypes = [Texture2D, NPatchInfo, Rectangle, Vector2, Float, Color]
3708+
_rl.DrawTextureNPatch.restype = None
3709+
def draw_texture_npatch(texture: Texture2D, npatch_info: NPatchInfo, dest_rec: Union[Rectangle, Seq], origin: Union[Vector2, Seq], rotation: float, tint: Union[Color, Seq]) -> None:
37083710
"""Draw a part of a texture defined by a rectangle with 'pro' parameters"""
3709-
return _rl.DrawNPatch(npatch, _rect(dest_rec), use_padding, _vec2(origin), _float(rotation), _color(tint))
3711+
return _rl.DrawNPatch(texture, npatch_info, _rect(dest_rec), _vec2(origin), _float(rotation), _color(tint))
37103712

37113713

37123714
# -----------------------------------------------------------------------------------
@@ -4349,6 +4351,20 @@ def end_blend_mode() -> None:
43494351
"""End blending mode (reset to default: alpha blending)"""
43504352
return _rl.EndBlendMode()
43514353

4354+
_rl.BeginClipRec.argtypes = [Rectangle]
4355+
_rl.BeginClipRec.restype = None
4356+
def begin_clip_rec(rec: Rectangle) -> None:
4357+
"""Drawing functions change only pixels inside rec.
4358+
4359+
Can be nested.
4360+
"""
4361+
_rl.BeginClipRec(_rect(rec))
4362+
4363+
_rl.EndClipRec.argtypes = _NOARGS
4364+
_rl.EndClipRec.restype = None
4365+
def end_clip_rec() -> None:
4366+
"""Restore previous clip rec."""
4367+
_rl.EndClipRec()
43524368

43534369
# VR control functions
43544370
_rl.GetVrDeviceInfo.argtypes = [Int]

raylibpy/libraylib_shared.dll

686 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)