Skip to content

Commit

Permalink
Node [Panel] 3.30 [Object] 28.4 [Actions] 2.72 Updates:
Browse files Browse the repository at this point in the history
- #72 bugfixed target mode toggle button + other align state option buttons;
- fix #75 Interpolated nudge.
  • Loading branch information
kateliev committed Feb 21, 2023
1 parent 1253fe2 commit 86f774c
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 22 deletions.
7 changes: 5 additions & 2 deletions Lib/typerig/core/objects/cubicbezier.py
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,9 @@ def lerp_last(self, shift):
if __name__ == "__main__":
a = Line(((113.73076629638672, 283.6538391113281), (357.96154022216797, 415.3846130371094)))
b = CubicBezier((145.7924041748047, 367.8679504394531), (222.71548461914062, 405.3679504394531), (317.9077911376953, 376.5217971801758), (328.48471450805664, 229.40641021728516))

c = b.intersect_line(a)
print(b.doSwap())
print(b.doSwap())

f = CubicBezier((150, 370), (220, 400), (320, 380), (330, 230))
print(f.lerp_last(Point(10,0)))
13 changes: 7 additions & 6 deletions Lib/typerig/proxy/fl/actions/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import typerig.proxy.fl.gui.dialogs as TRDialogs

# - Init ----------------------------------------------------------------------------
__version__ = '2.71'
__version__ = '2.72'
active_workspace = pWorkspace()

# - Keep compatibility for basestring checks
Expand Down Expand Up @@ -799,11 +799,12 @@ def nodes_move(glyph:eGlyph, pLayers:tuple, offset_x:int, offset_y:int, method:s
node.shift(offset_x, offset_y)

elif method == 'LERP':
for node in selectedNodes:
if in_percent_of_advance:
node.interpShift(*scale_offset(node, offset_x, offset_y, width, height))
else:
node.interpShift(offset_x, offset_y)
for node in sorted(selectedNodes, key= lambda n: (n.x, n.y)):
if node.isOn:
if in_percent_of_advance:
node.interpShift(*scale_offset(node, offset_x, offset_y, width, height))
else:
node.interpShift(offset_x, offset_y)

elif method == 'SLANT':
if italic_angle != 0:
Expand Down
21 changes: 11 additions & 10 deletions Lib/typerig/proxy/fl/objects/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from typerig.proxy.fl.objects.base import Coord, Line, Vector, Curve

# - Init ---------------------------------
__version__ = '0.28.3'
__version__ = '0.28.4'

# - Keep compatibility for basestring checks
try:
Expand Down Expand Up @@ -245,15 +245,15 @@ def update(self):
# - Transformation -----------------------------------------------
def reloc(self, newX, newY):
'''Relocate the node to new coordinates'''
self.fl.x, self.fl.y = newX, newY
#self.fl.x, self.fl.y = newX, newY
self.x, self.y = newX, newY
#self.update()

def shift(self, deltaX, deltaY):
'''Shift the node by given amout'''
self.fl.x += deltaX
self.fl.y += deltaY
self.x, self.y = self.fl.x, self.fl.y
self.x += deltaX
self.y += deltaY
#self.x, self.y = self.fl.x, self.fl.y
#self.update()

def smartReloc(self, newX, newY):
Expand Down Expand Up @@ -710,27 +710,28 @@ def interpShift(self, shift_x, shift_y):

currNode_bcpOut = self.getNext(False)
nextNode_bcpIn = currNode_bcpOut.getNext(False)
nextNode = nextNode_bcpIn.getOn(False)
nextNode = self.getNextOn(False)

currSegmetNodes = [self, currNode_bcpOut, nextNode_bcpIn, nextNode]

# - Set node positions
for i in range(len(currSegmetNodes)):
currSegmetNodes[i].smartReloc(*new_currCurve.points[i].tuple)

currSegmetNodes[i].reloc(*new_currCurve.tuple[i])

if len(prevSegment) == 4:
prevCurve = Curve(prevSegment)
new_prevCurve = prevCurve.lerp_last(shift)

currNode_bcpIn = self.getPrev(False)
prevNode_bcpOut = currNode_bcpIn.getPrev(False)
prevNode = prevNode_bcpOut.getOn(False)
prevNode = self.getPrevOn(False)

prevSegmentNodes = [prevNode, prevNode_bcpOut, currNode_bcpIn, self]

# - Set node positions
for i in range(len(prevSegmentNodes)-1,-1,-1):
prevSegmentNodes[i].smartReloc(*new_prevCurve.points[i].tuple)
prevSegmentNodes[i].reloc(*new_prevCurve.points[i].tuple)

if len(currSegmet) == 2 and len(prevSegment) == 2:
self.smartShift(*shift.tuple)
Expand Down
8 changes: 4 additions & 4 deletions Scripts/TypeRig GUI/Panel/Node.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
global pMode
pLayers = None
pMode = 0
app_name, app_version = 'TypeRig | Nodes', '3.29'
app_name, app_version = 'TypeRig | Nodes', '3.30'

TRToolFont = getTRIconFontPath()
font_loaded = QtGui.QFontDatabase.addApplicationFont(TRToolFont)
Expand Down Expand Up @@ -250,18 +250,18 @@ def __init__(self):

tooltip_button = "Keep relations between selected nodes"
self.chk_shift_keep_dimension = CustomPushButton("shift_keep_dimension", checkable=True, checked=False, tooltip=tooltip_button, obj_name='btn_panel_opt')
self.grp_align_options_other.addButton(self.chk_shift_keep_dimension, 1)
#self.grp_align_options_other.addButton(self.chk_shift_keep_dimension, 1)
lay_align_options.addWidget(self.chk_shift_keep_dimension)

tooltip_button = "Intercept vertical position"
self.chk_shift_intercept = CustomPushButton("shift_intercept", checkable=True, checked=False, tooltip=tooltip_button, obj_name='btn_panel_opt')
self.grp_align_options_other.addButton(self.chk_shift_intercept, 2)
#self.grp_align_options_other.addButton(self.chk_shift_intercept, 2)
lay_align_options.addWidget(self.chk_shift_intercept)

tooltip_button = "Pick target node for alignment"
self.chk_node_target = CustomPushButton("node_target", checkable=True, checked=False, tooltip=tooltip_button, obj_name='btn_panel_opt')
self.chk_node_target.clicked.connect(self.target_set)
self.grp_align_options_other.addButton(self.chk_node_target, 3)
#self.grp_align_options_other.addButton(self.chk_node_target, 3)
lay_align_options.addWidget(self.chk_node_target)

# --- Actions
Expand Down

0 comments on commit 86f774c

Please sign in to comment.