Compare commits
4 Commits
7.6.0.23050201
...
blit
| Author | SHA1 | Date | |
|---|---|---|---|
| 76ed4fefe1 | |||
| f73799f4fc | |||
| da9691a195 | |||
| 2b829dbc07 |
@@ -268,6 +268,7 @@ init -1100 python:
|
||||
config.history_current_dialogue = False
|
||||
config.scry_extend = False
|
||||
config.fadeout_audio = 0.0
|
||||
config.int_render_blit = True
|
||||
|
||||
if version > (6, 99, 5):
|
||||
config.search_prefixes.append("images/")
|
||||
|
||||
@@ -1373,6 +1373,9 @@ check_translate_none = True
|
||||
# Like developer, but available at the end of python early blocks.
|
||||
early_developer = False
|
||||
|
||||
# Does Render.blit round down its pos parameter ?
|
||||
int_render_blit = False
|
||||
|
||||
|
||||
del os
|
||||
del collections
|
||||
|
||||
+15
-61
@@ -786,7 +786,8 @@ cdef class Render:
|
||||
If `focus` is true, then focuses are added from the child to the
|
||||
parent.
|
||||
|
||||
This will only blit on integer pixel boundaries.
|
||||
The elements of `pos` are interpreted as a ``position`` :
|
||||
int and absolute are numbers of pixels, pure-float is relative to the size of this render.
|
||||
"""
|
||||
|
||||
if source is self:
|
||||
@@ -798,8 +799,15 @@ cdef class Render:
|
||||
|
||||
(xo, yo) = pos
|
||||
|
||||
xo = int(xo)
|
||||
yo = int(yo)
|
||||
if renpy.config.int_render_blit:
|
||||
xo = int(xo)
|
||||
yo = int(yo)
|
||||
else:
|
||||
if type(xo) is float:
|
||||
xo *= self.width
|
||||
if type(yo) is float:
|
||||
yo *= self.height
|
||||
# no need to convert to absolute
|
||||
|
||||
if index is None:
|
||||
self.children.append((source, xo, yo, focus, main))
|
||||
@@ -812,73 +820,19 @@ cdef class Render:
|
||||
|
||||
return 0
|
||||
|
||||
cpdef int subpixel_blit(Render self, source, tuple pos, object focus=True, object main=True, object index=None):
|
||||
cpdef int absolute_blit(Render self, source, tuple pos, *args, **kwargs):
|
||||
"""
|
||||
Blits `source` (a Render, Surface, or GL2Model) to this Render, offset by
|
||||
xo and yo.
|
||||
|
||||
If `focus` is true, then focuses are added from the child to the
|
||||
parent.
|
||||
|
||||
This blits at fractional pixel boundaries.
|
||||
An proxy for blit that blits at fractional pixel boundaries.
|
||||
"""
|
||||
|
||||
if source is self:
|
||||
raise Exception("Blitting to self.")
|
||||
|
||||
if models:
|
||||
if isinstance(source, pygame.Surface):
|
||||
source = renpy.display.draw.load_texture(source)
|
||||
|
||||
(xo, yo) = pos
|
||||
|
||||
xo = float(xo)
|
||||
yo = float(yo)
|
||||
|
||||
if index is None:
|
||||
self.children.append((source, xo, yo, focus, main))
|
||||
else:
|
||||
self.children.insert(index, (source, xo, yo, focus, main))
|
||||
|
||||
if isinstance(source, Render):
|
||||
self.depends_on_list.append(source)
|
||||
source.parents.add(self)
|
||||
|
||||
return 0
|
||||
|
||||
cpdef int absolute_blit(Render self, source, tuple pos, object focus=True, object main=True, object index=None):
|
||||
"""
|
||||
Blits `source` (a Render or Surface) to this Render, offset by
|
||||
xo and yo.
|
||||
|
||||
If `focus` is true, then focuses are added from the child to the
|
||||
parent.
|
||||
|
||||
This blits at fractional pixel boundaries.
|
||||
"""
|
||||
|
||||
if source is self:
|
||||
raise Exception("Blitting to self.")
|
||||
|
||||
if models:
|
||||
if isinstance(source, pygame.Surface):
|
||||
source = renpy.display.draw.load_texture(source)
|
||||
|
||||
(xo, yo) = pos
|
||||
|
||||
xo = renpy.display.core.absolute(xo)
|
||||
yo = renpy.display.core.absolute(yo)
|
||||
|
||||
if index is None:
|
||||
self.children.append((source, xo, yo, focus, main))
|
||||
else:
|
||||
self.children.insert(index, (source, xo, yo, focus, main))
|
||||
return self.blit(source, (xo, yo), *args, **kwargs)
|
||||
|
||||
if isinstance(source, Render):
|
||||
self.depends_on_list.append(source)
|
||||
source.parents.add(self)
|
||||
|
||||
return 0
|
||||
subpixel_blit = absolute_blit # legacy
|
||||
|
||||
|
||||
def get_size(self):
|
||||
|
||||
@@ -257,9 +257,11 @@ the implicit `self` parameter.
|
||||
The render object to draw.
|
||||
|
||||
`pos`
|
||||
The location to draw into. This is an (x, y) tuple
|
||||
with the coordinates being pixels relative to the
|
||||
upper-left corner of the target render.
|
||||
The location to draw into. This is an (x, y) tuple of
|
||||
:ref:`positions <style-property-values>` : integers and
|
||||
``absolute``\ s are a number of pixels relative to the upper-left
|
||||
corner of the target render, and floats are interpreted as a
|
||||
fraction of the width or height of the target render.
|
||||
|
||||
`main`
|
||||
A keyword-only parameter. If true, `source` will be displayed
|
||||
|
||||
@@ -465,6 +465,10 @@ safer to use.
|
||||
When Ren'Py used to normalize every whitespaces into standard spaces, it now
|
||||
supports non-standard spaces such as \\u3000, the full-width ideographic space.
|
||||
|
||||
:meth:`renpy.Render.blit` now takes :ref:`positions <style-property-values>`
|
||||
for its `pos` parameter, allowing one to pass values relative to the size of
|
||||
the Render.
|
||||
|
||||
|
||||
.. _renpy-7.5.3:
|
||||
.. _renpy-8.0.3:
|
||||
|
||||
@@ -139,6 +139,11 @@ Alternatively, you can determine new default volumes for :var:`config.default_mu
|
||||
:var:`config.default_sfx_volume`, and :var:`config.default_voice_volume` variables. If any
|
||||
of these is 0.0 or 1.0, it can be left unchanged.
|
||||
|
||||
**Render.blit** : this method now takes :ref:`positions <style-property-values>` as `pos` values,
|
||||
and will not round them down to integers. To revert to the old behavior::
|
||||
|
||||
define config.int_render_blit = True
|
||||
|
||||
|
||||
.. _incompatible-8.0.2:
|
||||
.. _incompatible-7.5.2:
|
||||
|
||||
@@ -94,6 +94,8 @@ text.::
|
||||
selected_color "#ff0"
|
||||
|
||||
|
||||
.. _style-property-values:
|
||||
|
||||
Style Property Values
|
||||
=====================
|
||||
|
||||
|
||||
Reference in New Issue
Block a user