Äîêóìåíò âçÿò èç êýøà ïîèñêîâîé ìàøèíû. Àäðåñ îðèãèíàëüíîãî äîêóìåíòà : http://kodomo.cmm.msu.su/trac/cca/changeset/8
Äàòà èçìåíåíèÿ: Unknown
Äàòà èíäåêñèðîâàíèÿ: Sun Apr 10 00:43:29 2016
Êîäèðîâêà: IBM-866
Changeset 8:cda6324b8518 òÀÓ Cyclyc Cell Automata

Changeset 8:cda6324b8518


Ignore:
Timestamp:
12/04/10 16:26:02 (5 years ago)
Author:
is_rusinov
Branch:
default
Children:
9:2b99826c4d29, 14:9d820c8401c0
Message:

+ change_size

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Interface.py

    r7 r8 ˆà
    33class Handlers(object):ˆà
    44        ˆà
    5ˆà        def __init__(self, cell_size, delay, offset_x, offset_y):# cell_size is size of cell, including line width, if there is itˆà
    ˆà5        def __init__(self, cell_size=5, delay=10, offset_x=0, offset_y=0):# cell_size is size of cell, including line width, if there is itˆà
    66                self.cell_size = cell_sizeˆà
    77                self.delay = delayˆà
    òÀæ òÀæ ˆà
    1212        ˆà
    1313        def start(self):ˆà
    14ˆà                if ! self.is_started:ˆà
    ˆà14                if not self.is_started:ˆà
    1515                        self.is_started = Trueˆà
    1616                        self.next_step()ˆà
    òÀæ òÀæ ˆà
    3535        ˆà
    3636        def close_help_windowˆà
    37ˆà                ˆà
    38ˆà        def zoom_in(self):ˆà
    ˆà37                passˆà
    ˆà38        ˆà
    ˆà39        def zoom_in(self, zoom_rate=1):ˆà
    3940                if self.cell_size < 50:ˆà
    40ˆà                        self.cell_size ++ˆà
    ˆà41                        self.cell_size = self.cell_size + zoom_rateˆà
    4142                        self.draw()ˆà
    4243        ˆà
    43ˆà        def zoom_out(self):ˆà
    ˆà44        def zoom_out(self, zoom_rate=1):ˆà
    4445                if self.cell_size > 1:ˆà
    45ˆà                        self.cell_size --ˆà
    ˆà46                        self.cell_size = self.cell_size - zoom_rateˆà
    4647                        self.draw()ˆà
    4748        ˆà
    48ˆà        def slower(self, speed_rate):ˆà
    ˆà49        def slower(self, speed_rate=1):ˆà
    4950                self.delay = self.delay + speed_rateˆà
    5051        ˆà
    51ˆà        def faster(self, speed_rate):ˆà
    ˆà52        def faster(self, speed_rate=1):ˆà
    5253                if self.speed > speed_rate:ˆà
    5354                        self.delay = self.delay - speed_rateˆà
    òÀæ òÀæ ˆà
    5556                        self.delay = 0ˆà
    5657        ˆà
    57ˆà        def change_size(x, y):ˆà
    58ˆà                automata.change_size(x, y)ˆà
    59ˆà                self.draw()ˆà
    ˆà58        def change_size(dx, dy, position=0):ˆà
    ˆà59                if position < 9:ˆà
    ˆà60                        if position == 0 or position == 3 or position == 6:ˆà
    ˆà61                                automata.change_size(dx, 3)ˆà
    ˆà62                        elif position == 1 or position == 4 or position == 7:ˆà
    ˆà63                                automata.change_size(dx / 2, 3)ˆà
    ˆà64                                automata.change_size(dx - dx / 2, 1)ˆà
    ˆà65                        else ˆà
    ˆà66                                automata.change_size(dx, 1)ˆà
    ˆà67                        if position == 0 or position == 1 or position == 2:ˆà
    ˆà68                                automata.change_size(dy, 0)ˆà
    ˆà69                        elif position == 3 or position == 4 or position == 5:ˆà
    ˆà70                                automata.change_size(dy / 2, 0)ˆà
    ˆà71                                automata.change_size(dy - dy / 2, 2)ˆà
    ˆà72                        else ˆà
    ˆà73                                automata.change_size(dy, 2)ˆà
    ˆà74                        self.draw()ˆà
    6075        ˆà
    6176        def draw():ˆà
    òÀæ òÀæ ˆà
    86101                passˆà
    87102        ˆà
    88ˆà        def automata_frame():# show automata_frameˆà
    ˆà103        def automata_frame(self):# show automata_frameˆà
    89104                frame1.pack(side="right", fill="y", expand="no", before=canvas)ˆà
    90105        ˆà
    91ˆà        def to_top():# replace choosen state to topˆà
    ˆà106        def to_top(self):# replace choosen state to topˆà
    92107                index = symbols.get(state_list.get("active").split()[1])ˆà
    93108                state = states[index]ˆà
    òÀæ òÀæ ˆà
    95110                states.insert(0, state)ˆà
    96111        ˆà
    97ˆà        def to_bottom():# replace choosen state to bottonˆà
    ˆà112        def to_bottom(self):# replace choosen state to bottonˆà
    98113                index = symbols.get(state_list.get("active").split()[1])ˆà
    99114                state = states[index]ˆà
    òÀæ òÀæ ˆà
    101116                states.append(state)ˆà
    102117        ˆà
    103ˆà        def upwards():ˆà
    ˆà118        def upwards(self):ˆà
    104119                index = symbols.get(state_list.get("active").split()[1])ˆà
    105120                state = states[index]ˆà
    òÀæ òÀæ ˆà
    107122                states.insert(index - 1, state)ˆà
    108123        ˆà
    109ˆà        def downwards():ˆà
    ˆà124        def downwards(self):ˆà
    110125                index = symbols.get(state_list.get("active").split()[1])ˆà
    111126                state = states[index]ˆà
    òÀæ òÀæ ˆà
    113128                states.insert(index + 1, state)ˆà
    114129        ˆà
    115ˆà        def delete_state():# delete choosen stateˆà
    ˆà130        def delete_state(self):# delete choosen stateˆà
    116131                index = symbols.get(state_list.get("active").split()[1])ˆà
    117132                del states[index]ˆà
Note: See TracChangeset for help on using the changeset viewer.