main
Alexandre B A Villares 2021-09-08 23:40:43 -03:00
rodzic 84b1b712aa
commit 206aa44ef3
6 zmienionych plików z 730 dodań i 0 usunięć

Wyświetl plik

@ -0,0 +1,523 @@
(dp0
S'a'
p1
(iglyphs
Glyph
p2
(dp3
S'current_path'
p4
I-1
sS'name'
p5
g1
sS'width'
p6
I4
sS'paths'
p7
(lp8
(lp9
(F3.0
F5.0
(dp10
tp11
a(F4.0
F4.0
(dp12
tp13
a(F5.0
F4.0
(dp14
tp15
a(F6.0
F5.0
(dp16
tp17
a(F6.0
F10.0
(dp18
tp19
aa(lp20
(F6.0
F9.0
(dp21
tp22
a(F5.0
F10.0
(dp23
tp24
a(F4.0
F10.0
(dp25
tp26
a(F3.0
F9.0
(dp27
tp28
a(F3.0
F8.0
(dp29
tp30
a(F6.0
F6.0
(dp31
tp32
aa(lp33
a(lp34
asbsVb
p35
(iglyphs
Glyph
p36
(dp37
S'current_path'
p38
NsS'name'
p39
Vb
p40
sS'width'
p41
I4
sS'paths'
p42
(lp43
(lp44
(F3.0
F1.0
(dp45
tp46
a(F3.0
F10.0
(dp47
tp48
aa(lp49
(F3.0
F9.0
(dp50
tp51
a(F4.0
F10.0
(dp52
tp53
a(F5.0
F10.0
(dp54
tp55
a(F6.0
F9.0
(dp56
tp57
a(F6.0
F5.0
(dp58
tp59
a(F5.0
F4.0
(dp60
tp61
a(F4.0
F4.0
(dp62
tp63
a(F3.0
F5.0
(dp64
tp65
aasbsVc
p66
(iglyphs
Glyph
p67
(dp68
S'current_path'
p69
I-1
sS'name'
p70
Vc
p71
sS'width'
p72
I4
sS'paths'
p73
(lp74
(lp75
(F6.0
F5.0
(dp76
tp77
a(F5.0
F4.0
(dp78
tp79
a(F4.0
F4.0
(dp80
tp81
a(F3.0
F5.0
(dp82
tp83
a(F3.0
F9.0
(dp84
tp85
a(F4.0
F10.0
(dp86
tp87
a(F5.0
F10.0
(dp88
tp89
a(F6.0
F9.0
(dp90
tp91
aasbsVd
p92
(iglyphs
Glyph
p93
(dp94
S'current_path'
p95
NsS'name'
p96
Vd
p97
sS'width'
p98
I4
sS'paths'
p99
(lp100
(lp101
(F6.0
F1.0
(dp102
tp103
a(F6.0
F10.0
(dp104
tp105
aa(lp106
(F6.0
F9.0
(dp107
tp108
a(F5.0
F10.0
(dp109
tp110
a(F4.0
F10.0
(dp111
tp112
a(F3.0
F9.0
(dp113
tp114
a(F3.0
F5.0
(dp115
tp116
a(F4.0
F4.0
(dp117
tp118
a(F5.0
F4.0
(dp119
tp120
a(F6.0
F5.0
(dp121
tp122
aasbsVe
p123
(iglyphs
Glyph
p124
(dp125
S'name'
p126
Ve
p127
sS'width'
p128
I4
sS'paths'
p129
(lp130
(lp131
(F6.0
F9.0
(dp132
tp133
a(F5.0
F10.0
(dp134
tp135
a(F4.0
F10.0
(dp136
tp137
a(F3.0
F9.0
(dp138
tp139
a(F3.0
F5.0
(dp140
tp141
a(F4.0
F4.0
(dp142
tp143
a(F5.0
F4.0
(dp144
tp145
a(F6.0
F5.0
(dp146
tp147
a(F6.0
F6.0
(dp148
tp149
a(F3.0
F8.0
(dp150
tp151
aasbsVf
p152
(iglyphs
Glyph
p153
(dp154
S'name'
p155
Vf
p156
sS'width'
p157
I4
sS'paths'
p158
(lp159
(lp160
a(lp161
(F3.0
F10.0
(dp162
tp163
a(F3.0
F2.0
(dp164
tp165
a(F4.0
F1.0
(dp166
tp167
a(F5.0
F1.0
(dp168
tp169
a(F6.0
F2.0
(dp170
tp171
aa(lp172
(F5.0
F4.0
(dp173
tp174
a(F3.0
F4.0
(dp175
tp176
aasbsVg
p177
(iglyphs
Glyph
p178
(dp179
S'name'
p180
Vg
p181
sS'width'
p182
I4
sS'paths'
p183
(lp184
(lp185
(F3.0
F10.0
(dp186
tp187
a(F2.0
F9.0
(dp188
tp189
a(F2.0
F5.0
(dp190
tp191
a(F3.0
F4.0
(dp192
tp193
a(F4.0
F4.0
(dp194
tp195
a(F5.0
F5.0
(dp196
tp197
a(F5.0
F12.0
(dp198
tp199
a(F4.0
F13.0
(dp200
tp201
a(F3.0
F13.0
(dp202
tp203
a(F2.0
F12.0
(dp204
tp205
a(F2.0
F12.0
(dp206
tp207
a(F2.0
F11.0
(dp208
tp209
aa(lp210
(F3.0
F10.0
(dp211
tp212
a(F4.0
F10.0
(dp213
tp214
a(F5.0
F9.0
(dp215
tp216
aasbsVh
p217
(iglyphs
Glyph
p218
(dp219
S'name'
p220
Vh
p221
sS'width'
p222
I4
sS'paths'
p223
(lp224
(lp225
(F3.0
F1.0
(dp226
tp227
a(F3.0
F10.0
(dp228
tp229
a(F3.0
F5.0
(dp230
tp231
a(F4.0
F4.0
(dp232
tp233
a(F5.0
F4.0
(dp234
tp235
a(F6.0
F5.0
(dp236
tp237
a(F6.0
F10.0
(dp238
tp239
aasbsVs
p240
(iglyphs
Glyph
p241
(dp242
S'name'
p243
Vs
p244
sS'width'
p245
I4
sS'paths'
p246
(lp247
sbsV
p248
(iglyphs
Glyph
p249
(dp250
S'current_path'
p251
NsS'name'
p252
V
p253
sS'width'
p254
I4
sS'paths'
p255
(lp256
sbsI65535
(iglyphs
Glyph
p257
(dp258
S'current_path'
p259
I-1
sS'name'
p260
I65535
sS'width'
p261
I4
sS'paths'
p262
(lp263
(lp264
(F6.0
F7.0
(dp265
tp266
aasbs.

Wyświetl plik

@ -0,0 +1,23 @@
import interface
class Glyph:
glyphs = {}
def __init__(self, name):
self.name = name
self.glyphs[name] = self
self.paths = []
self.width = 4
def plot(self, s=1):
gs = interface.grid_size
for path in self.paths:
beginShape()
noFill()
strokeWeight(2)
for x, y, d in path:
vertex(x * gs * s, y * gs * s)
endShape()

Wyświetl plik

@ -0,0 +1,132 @@
from __future__ import division
import pickle
import glyphs
ADD, MOVE, EDIT = modes = ("add", "move", "edit")
mode = ADD
current_glyph = None # None or Glyph object
current_path = None # None or index to path
current_vertex = None # index to vertex in path for EDIT or (px, py) for MOVE
keys_pressed = {}
grid_size = 20
def mouse_pressed(mb):
global current_glyph, current_path, current_vertex
mx, my = grid_mouse()
if current_glyph is None:
current_glyph = glyphs.Glyph('a')
if mode == ADD:
if current_glyph and current_path is None:
current_glyph.paths.append([(mx, my, {})])
current_path = -1
elif mb == LEFT and current_path is not None:
current_glyph.paths[current_path].append((mx, my, {}))
else:
current_path = None
elif mode == MOVE:
if current_glyph:
for i, path in enumerate(current_glyph.paths):
for j, (x, y, _) in enumerate(path):
if (mx, my) == (x, y):
current_path = i
current_vertex = (mx, my)
print(i, current_vertex)
return
elif mode == EDIT:
if current_glyph:
for i, path in enumerate(current_glyph.paths):
for j, (x, y, _) in enumerate(path):
if (mx, my) == (x, y):
current_path = i
current_vertex = j
return
def mouse_dragged(mb):
global current_vertex
mx, my = grid_mouse()
if mode == EDIT and current_vertex is not None:
cps = current_glyph.paths[current_path]
x, y, d = cps[current_vertex]
cps[current_vertex] = (mx, my, d)
elif mode == MOVE and current_path is not None:
cps = current_glyph.paths[current_path]
px, py = current_vertex # position where mouse was pressed
dx, dy = mx - px, my - py
current_vertex = mx, my
for i, (x, y, d) in enumerate(cps):
cps[i] = (x + dx, y + dy, d)
def mouse_released(mb):
global current_vertex
current_path = None
def grid_mouse():
gs = grid_size
mx = round(mouseX / gs)
my = round(mouseY / gs)
return mx, my
def draw_grid():
push()
for x in range(0, width, grid_size):
for y in range(0, height, grid_size):
if dist(mouseX, mouseY, x, y) < grid_size / 2:
stroke(255, 0, 0)
else:
stroke(255)
strokeWeight(2)
point(x, y)
pop()
# print(check_keys(CONTROL))
def show_mode():
fill(0)
textSize(20)
text(mode, width - grid_size * 5, grid_size)
def check_keys(*args, **kwargs):
if kwargs.get('ANY'):
return any(keys_pressed.get(k, False) for k in args)
else:
return all(keys_pressed.get(k, False) for k in args)
def key_released(k, kc):
global current_glyph, current_path
if check_keys(ALT) and kc != ALT:
glyphs_dict = glyphs.Glyph.glyphs
if k in glyphs_dict:
current_glyph = glyphs_dict[k]
else:
current_glyph = glyphs.Glyph(k)
keys_pressed.pop(ALT)
current_path = None
elif k == 's':
with open("data.pickle", "w") as f:
pickle.dump(glyphs.Glyph.glyphs, f)
print('data saved')
elif k == 'l':
with open("data.pickle") as f:
glyphs.Glyph.glyphs = pickle.load(f)
print('data loaded')
elif k == 'e':
cps = current_glyph.paths if current_glyph else None
if cps:
cps[:] = [[]]
current_path = None
elif k == 'm':
global mode
mode = modes[modes.index(mode) - 1]
elif check_keys(BACKSPACE, DELETE, ANY=True):
cps = current_glyph.paths if current_glyph else None
if cps and current_path is None:
current_path = -1
if cps is not None and cps[current_path]:
cps[current_path].pop()

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 12 KiB

Wyświetl plik

@ -0,0 +1,46 @@
"""
A reboot of a simple poly / linerar glyphs editor
"""
from glyphs import Glyph
import interface
def setup():
global half_grid_h
size(600, 600)
strokeJoin(ROUND)
# interface.grid_size = 20
half_grid_h = height // interface.grid_size // 2
def draw():
background(200)
interface.draw_grid()
interface.show_mode()
gs = interface.grid_size
gc = interface.current_glyph
if gc:
fill(0)
textSize(20)
text(gc.name, gs, gs)
textSize(8)
gc.plot()
text(str(gc.paths), gs, gs * half_grid_h)
translate(0, gs * half_grid_h)
for gl in Glyph.glyphs.values():
s = 0.25
gl.plot(s)
translate(gl.width * gs * s, 0)
def mousePressed(): interface.mouse_pressed(mouseButton)
def mouseDragged(): interface.mouse_dragged(mouseButton)
def mouseReleased(): interface.mouse_released(mouseButton)
def keyPressed():
interface.keys_pressed[key if key != CODED else keyCode] = True
def keyReleased():
interface.key_released(key, keyCode)
interface.keys_pressed[key if key != CODED else keyCode] = False

Wyświetl plik

@ -26,6 +26,12 @@ Here are listed some of the tools I have been using:
## [2018](2018.md) | [2019](2019.md) | [2020](2020.md) | 2021
---
![sketch_2021_09_08_glypheditor](2021/sketch_2021_09_08_glypheditor/sketch_2021_09_08_glypheditor.png)
[sketch_2021_09_08_glypheditor](https://github.com/villares/sketch-a-day/tree/master/2021/sketch_2021_09_08_glypheditor) [[Py.Processing](https://villares.github.io/como-instalar-o-processing-modo-python/index-EN)]
---
![sketch_2021_09_07shoebot](2021/sketch_2021_09_07shoebot/sketch_2021_09_07shoebot.svg)