Skip to content

Commit 9c8cf6b

Browse files
committed
v250107.4
1 parent be2c337 commit 9c8cf6b

File tree

7 files changed

+57
-10
lines changed

7 files changed

+57
-10
lines changed
34.5 KB
Binary file not shown.
2.52 MB
Binary file not shown.

easycoder/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@
1010
from .ec_timestamp import *
1111
from .ec_value import *
1212

13-
__version__ = "250107.3"
13+
__version__ = "250107.4"

easycoder/ec_graphics.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,21 @@ def r_getui(self, command):
228228
self.ui = self.renderer.getUI()
229229
return self.nextPC()
230230

231+
# Hide an element
232+
def k_hide(self, command):
233+
if self.nextIsSymbol():
234+
record = self.getSymbolRecord()
235+
type = record['keyword']
236+
if self.isGraphicType(type):
237+
command['target'] = record['id']
238+
self.add(command)
239+
return True
240+
return False
241+
242+
def r_hide(self, command):
243+
self.ui.setVisible(self.getRuntimeValue(command['target']), False)
244+
return self.nextPC()
245+
231246
def k_image(self, command):
232247
return self.compileVariable(command)
233248

@@ -393,6 +408,21 @@ def r_set(self, command):
393408
self.ui.setAttribute(id, attribute, value)
394409
return self.nextPC()
395410

411+
# Show an element (restore it to its current position)
412+
def k_show(self, command):
413+
if self.nextIsSymbol():
414+
record = self.getSymbolRecord()
415+
type = record['keyword']
416+
if self.isGraphicType(type):
417+
command['target'] = record['id']
418+
self.add(command)
419+
return True
420+
return False
421+
422+
def r_show(self, command):
423+
self.ui.setVisible(self.getRuntimeValue(command['target']), True)
424+
return self.nextPC()
425+
396426
def k_text(self, command):
397427
return self.compileVariable(command)
398428

easycoder/ec_program.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ class Program:
1818

1919
def __init__(self, argv):
2020
global queue
21-
print(f'EasyCoder version {version("easycoder")}')
2221
if len(argv) == 0:
2322
print('No script supplied')
2423
exit()
@@ -387,6 +386,7 @@ def handleMessage(self, message):
387386

388387
# This is the program launcher
389388
def Main():
389+
print(f'EasyCoder version {version("easycoder")}')
390390
if (len(sys.argv) > 1):
391391
Program(sys.argv[1]).start()
392392
else:

easycoder/ec_renderer.py

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class Element():
3535
def __init__(self, type, spec):
3636
self.type = type
3737
self.spec = spec
38+
self.visible= True
3839
self.actionCB = None
3940

4041
def getRelativePosition(self):
@@ -57,10 +58,11 @@ def getPos(self):
5758
return pos
5859

5960
def setPos(self, pos):
60-
# Update the spec
61-
self.spec.realpos = pos
62-
# Update the displayed item
63-
self.spec.item.pos = pos
61+
if self.visible:
62+
# Update the spec
63+
self.spec.realpos = pos
64+
# Update the displayed item
65+
self.spec.item.pos = pos
6466

6567
def getSize(self):
6668
return self.spec.realsize
@@ -69,6 +71,13 @@ def setSize(self, size):
6971
self.spec.realsize = size
7072
self.spec.item.size = size
7173

74+
def setVisible(self, vis):
75+
self.visible = vis
76+
if vis:
77+
self.setPos(self.spec.realpos)
78+
else:
79+
self.spec.item.pos = (Window.width, self.getPos()[1])
80+
7281
def getChildren(self):
7382
return self.spec.children
7483

@@ -142,6 +151,14 @@ def moveElementTo(self, id, pos):
142151
self.moveElementBy(id, Vector(pos) - element.getPos())
143152
return
144153

154+
def setVisible(self, id, vis):
155+
element = self.getElement(id)
156+
if element != None:
157+
element.setVisible(vis)
158+
for id in element.getChildren():
159+
self.setVisible(id, vis)
160+
return
161+
145162
def on_touch_down(self, touch):
146163
tp = touch.pos
147164
x = tp[0]

scripts/graphics-demo.ecg

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ MoveEllipse:
103103
FlashGreen:
104104
while true
105105
begin
106-
wait 5
107-
set attribute `opacity` of GreenCircle to 0
108-
wait 1
109-
set attribute `opacity` of GreenCircle to 1
106+
wait 50 ticks
107+
hide GreenCircle
108+
wait 50 ticks
109+
show GreenCircle
110110
end

0 commit comments

Comments
 (0)