@@ -65,70 +65,96 @@ def print_palette(new_palette):
6565# Test of append()
6666print ("\n " + ("=" * 15 ))
6767print ("TEST append()" )
68- test = 0xF0F0F0
69- print (f" value to insert : { test :#08x} " )
68+ test_value = 0xF0F0F0
69+ print (f" value to append : { test_value :#08x} " )
7070
7171(last_color , last_transparency ) = pal_sliceable .reference_list [- 1 ]
7272length = len (pal_sliceable )
7373print (
7474 f"length BEFORE append: { length } last item: { last_color :#08x} { last_transparency } "
7575)
7676
77- pal_sliceable .append (test )
77+ pal_sliceable .append (test_value )
7878
7979(last_color , last_transparency ) = pal_sliceable .reference_list [- 1 ]
8080length = len (pal_sliceable )
8181print (
8282 f"length AFTER append: { length } last item: { last_color :#08x} { last_transparency } "
8383)
8484
85+ # Test of insert()
86+ print ("\n " + ("=" * 15 ))
87+ print ("TEST insert()" )
88+ test_value = 0xA0A0A0
89+ test_index = 100
90+ print (f" value to insert: { test_value :#08x} at index: { test_index } " )
91+
92+ (old_color , old_transparency ) = pal_sliceable .reference_list [test_index ]
93+ length = len (pal_sliceable )
94+ print (f"length BEFORE insert: { length } item: { old_color :#08x} { old_transparency } " )
95+
96+ pal_sliceable .insert (test_index , test_value )
97+
98+ (new_color , new_transparency ) = pal_sliceable .reference_list [test_index ]
99+ length = len (pal_sliceable )
100+ print (f"length AFTER insert: { length } item: { new_color :#08x} { new_transparency } " )
101+
85102# Test of is_transparent(), make_transparent(), make_opaque()
86103print ("\n " + ("=" * 15 ))
87- test = - 1 # Index to test
104+ test_value = - 1 # Index to test
88105print ("TEST is_transparent(), make_transparent(), make_opaque()" )
89- print (f" index value for test: { test } " )
90- print (f" is_transparent: { pal_sliceable .is_transparent (test )} " )
91- pal_sliceable .make_transparent (test )
92- print (f"AFTER make_transparent -> is_transparent: { pal_sliceable .is_transparent (test )} " )
93- pal_sliceable .make_opaque (test )
94- print (f"AFTER make_opaque -> is_transparent: { pal_sliceable .is_transparent (test )} " )
106+ print (f" index value for test: { test_value } " )
107+ print (f" is_transparent: { pal_sliceable .is_transparent (test_value )} " )
108+ pal_sliceable .make_transparent (test_value )
109+ print (
110+ f"AFTER make_transparent -> is_transparent: { pal_sliceable .is_transparent (test_value )} "
111+ )
112+ pal_sliceable .make_opaque (test_value )
113+ print (
114+ f"AFTER make_opaque -> is_transparent: { pal_sliceable .is_transparent (test_value )} "
115+ )
95116
96117# Test of count()
97118print ("\n " + ("=" * 15 ))
98119print ("TEST count()" )
99- test = 0xFFFFFF # Color value for search
100- print (f" color value for search: { test :#08x} " )
120+ test_value = 0xFFFFFF # Color value for search
121+ print (f" color value for search: { test_value :#08x} " )
101122
102- print (f"number of occurrences: { pal_sliceable .count (test )} " )
123+ print (f"number of occurrences: { pal_sliceable .count (test_value )} " )
103124
104125# Test of index()
105126print ("\n " + ("=" * 15 ))
106127print ("TEST index()" )
107- test = 0xFFFFF0 # Color value for search
108- print (f" color value for search: { test :#08x} " )
128+ test_value = 0xFFFFF0 # Color value for search
129+ print (f" color value for search: { test_value :#08x} " )
130+
131+ print (f"first index found: { pal_sliceable .index (test_value )} " )
109132
110- print (f"first index found: { pal_sliceable .index (test )} " )
133+ test_value = 0xFFFFFF # Color value for search
134+ print (f" color value for search: { test_value :#08x} " )
135+
136+ print (f"first index found: { pal_sliceable .index (test_value )} " )
111137
112138# Test of pop()
113139print ("\n " + ("=" * 15 ))
114140print ("TEST pop()" )
115- test = - 1 # Remove last item
116- print (f" index to pop: { test } " )
141+ test_value = - 1 # Remove last item
142+ print (f" index to pop: { test_value } " )
117143
118144print (f" length BEFORE pop: { len (pal_sliceable )} " )
119- print (f"value removed: { pal_sliceable .pop (test ):#08x} " )
145+ print (f"value removed: { pal_sliceable .pop (test_value ):#08x} " )
120146print (f" length AFTER pop: { len (pal_sliceable )} " )
121147
122148# Test of __contains__
123149print ("\n " + ("=" * 15 ))
124150print ("TEST __contains__" )
125- test = 0
126- print (f" value to find: { test } " )
151+ test_value = 0
152+ print (f" value to find: { test_value } " )
127153
128- if test in pal_sliceable :
129- print (f"< { test } > in pal_sliceable (True)" )
154+ if test_value in pal_sliceable :
155+ print (f"< { test_value } > in pal_sliceable (True)" )
130156else :
131- print (f"< { test } > NOT in pal_sliceable (False)" )
157+ print (f"< { test_value } > NOT in pal_sliceable (False)" )
132158
133159# Place the test image into a tile and append to the primary display group
134160test_tile = displayio .TileGrid (test_bitmap , pixel_shader = test_palette_source )
@@ -142,11 +168,13 @@ def print_palette(new_palette):
142168
143169# Show the test image and label
144170display .show (primary_group )
171+ print ("\n " + ("=" * 15 ))
145172print ("TEST of source image" )
146173slice_label .text = "PALETTE SLICE: source image and palette"
147174time .sleep (2 )
148175
149176# Continuous random slice test
177+ print ("\n " + ("=" * 15 ))
150178print ("TEST of random slices" )
151179while True :
152180 # Create a random slice object; prohibit step == 0
0 commit comments