Commit a8ec5283 authored by cobaltcore's avatar cobaltcore
Browse files

Clearer variable names and illustrative screenshot in README

parent 7b4dae7b
# Spline Edit
A graphical spline editor for Ren'Py.
![Screenshot of SplineEdit](screenshot.png)
This is a port of the [original Spline Editor](https://www.renpy.org/wiki/renpy/Spline_Editor) project. It has been cleaned up and made compatible with Ren'Py 7. Functionality has been kept the same.
## Installation
......
......@@ -14,9 +14,9 @@ class Point(object):
self.y = y
# The size of the viewable area of the screen.
W, H = 1280, 720
X = (renpy.config.screen_width - W) // 2
Y = (renpy.config.screen_height - H) // 2
WIDTH, HEIGHT = 1280, 720
X_OFFSET = (renpy.config.screen_width - WIDTH) // 2
Y_OFFSET = (renpy.config.screen_height - HEIGHT) // 2
class SplineEditor(renpy.exports.Displayable):
......@@ -53,8 +53,8 @@ class SplineEditor(renpy.exports.Displayable):
surf = pygame.Surface((width, height), 0, renpy.display.pgrender.sample_alpha)
# draw the screen area helper
pygame.draw.rect(surf, (238, 238, 238), (X, Y, W, H))
pygame.draw.lines(surf, (0, 0, 0), True, [(X, Y), (X + W, Y), (X + W, Y + H), (X, Y + H)], 3)
pygame.draw.rect(surf, (238, 238, 238), (X_OFFSET, Y_OFFSET, WIDTH, HEIGHT))
pygame.draw.lines(surf, (0, 0, 0), True, [(X_OFFSET, Y_OFFSET), (X_OFFSET + WIDTH, Y_OFFSET), (X_OFFSET + WIDTH, Y_OFFSET + HEIGHT), (X_OFFSET, Y_OFFSET + HEIGHT)], 3)
rv.blit(surf, (0, 0))
handle = renpy.display.image.render(self.handle, width, height, st, at)
......@@ -80,12 +80,12 @@ class SplineEditor(renpy.exports.Displayable):
# draw delay timing
delay = renpy.display.image.render(Text("Time: {:.1f}".format(self.delay), color="#000"),
width, height, st, at)
rv.blit(delay, (X + 5, (renpy.config.screen_height - H) // 2))
rv.blit(delay, (X_OFFSET + 5, (renpy.config.screen_height - HEIGHT) // 2))
# draw edge notice
edge_notice = renpy.display.image.render(Text("Edge of the screen", color="#000"),
width, height, st, at)
rv.blit(edge_notice, (X + 5, ((renpy.config.screen_height - H) // 2) - 40))
rv.blit(edge_notice, (X_OFFSET + 5, ((renpy.config.screen_height - HEIGHT) // 2) - 40))
return rv
......@@ -242,12 +242,12 @@ class SplineEditor(renpy.exports.Displayable):
for j in range(0, numdots + 1):
t = 1.0 * j / numdots
x, y, xo, yo = pi(t, (W, H, DOT_SIZE, DOT_SIZE))
x, y, xo, yo = pi(t, (WIDTH, HEIGHT, DOT_SIZE, DOT_SIZE))
self.spline_dots.append((x, y))
def relative_spline(self):
def make_relative(t):
x, y = t
return (1.0 * (x - X) / W, 1.0 * (y - Y) / H)
return (1.0 * (x - X_OFFSET) / WIDTH, 1.0 * (y - Y_OFFSET) / HEIGHT)
return [tuple(make_relative(i) for i in j) for j in self.spline_points]
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment