def get_sc_cargo(cargo_colour_id, load_state): # returns sequences with correct y offset for current load state if load_state.name == 'empty': cargo_colour = 19 else: cargo_colour = cargo_colours[cargo_colour_id] bulk_load = [(0, 0, cargo_colour)] return PixaSequenceCollection( sequences={ 141: PixaSequence(points=bulk_load, transforms=[PixaShiftDY(load_state.yoffs)]), 140: PixaSequence(points=bulk_load, transforms=[ PixaShiftColour(0, 255, -1), PixaShiftDY(load_state.yoffs) ]), 139: PixaSequence(points=bulk_load, transforms=[ PixaShiftColour(0, 255, -2), PixaShiftDY(load_state.yoffs) ]), 138: PixaSequence(points=bulk_load, transforms=[ PixaShiftColour(0, 255, -3), PixaShiftDY(load_state.yoffs) ]), })
def sc_cab_nearside(cab_sprites, truck_length): return PixaSequenceCollection( sequences = { 45: PixaSequence(points = cab_sprites['4'], transforms = [PixaShiftXY(*common.get_cab_offsets(4, truck_length))]), 46: PixaSequence(points = cab_sprites['5'], transforms = [PixaShiftXY(*common.get_cab_offsets(5, truck_length))]), 47: PixaSequence(points = cab_sprites['6'], transforms = [PixaShiftXY(*common.get_cab_offsets(6, truck_length))]), } )
def sc_cab_farside(cab_sprites, truck_length): return PixaSequenceCollection( sequences = { 42: PixaSequence(points = cab_sprites['1'], transforms = [PixaShiftXY(*common.get_cab_offsets(1, truck_length))]), 43: PixaSequence(points = cab_sprites['2'], transforms = [PixaShiftXY(*common.get_cab_offsets(2, truck_length))]), 44: PixaSequence(points = cab_sprites['3'], transforms = [PixaShiftXY(*common.get_cab_offsets(3, truck_length))]), 48: PixaSequence(points = cab_sprites['7'], transforms = [PixaShiftXY(*common.get_cab_offsets(7, truck_length))]), 49: PixaSequence(points = cab_sprites['8'], transforms = [PixaShiftXY(*common.get_cab_offsets(8, truck_length))]), } )
def sc_body(body_path, row_num, truck_length): body_loader = PixaImageLoader(mask=(0,255)) body_sprites = {} for spritenum in ('1', '2', '3', '4', '5', '6', '7', '8'): # crops out the body sprite for each angle, appropriate to the required load state crop_start_x = common.get_standard_crop(spritenum)[0][0] crop_end_x = common.get_standard_crop(spritenum)[1][0] row_offset_y = (row_num) * common.SPRITEROW_HEIGHT crop_start_y = row_offset_y + FLOORPLAN_START_Y + common.get_standard_crop(spritenum)[0][1] crop_end_y = row_offset_y + FLOORPLAN_START_Y + common.get_standard_crop(spritenum)[1][1] crop_box = (crop_start_x, crop_start_y, crop_end_x, crop_end_y) body_sprites[spritenum] = body_loader.make_points(body_path, crop_box, origin=(0, 0)) if 'body_fifth_wheel' in body_path: colour_shift = PixaShiftColour(244, 244, -244) # for masking out chassis on fifth wheel trucks else: colour_shift = None return PixaSequenceCollection( sequences = { 42: PixaSequence(points = body_sprites['1'], transforms = [colour_shift, PixaShiftXY(*common.get_truck_body_offsets(1, truck_length))]), 43: PixaSequence(points = body_sprites['2'], transforms = [colour_shift, PixaShiftXY(*common.get_truck_body_offsets(2, truck_length))]), 44: PixaSequence(points = body_sprites['3'], transforms = [colour_shift, PixaShiftXY(*common.get_truck_body_offsets(3, truck_length))]), 45: PixaSequence(points = body_sprites['4'], transforms = [colour_shift, PixaShiftXY(*common.get_truck_body_offsets(4, truck_length))]), 46: PixaSequence(points = body_sprites['5'], transforms = [colour_shift, PixaShiftXY(*common.get_truck_body_offsets(5, truck_length))]), 47: PixaSequence(points = body_sprites['6'], transforms = [colour_shift, PixaShiftXY(*common.get_truck_body_offsets(6, truck_length))]), 48: PixaSequence(points = body_sprites['7'], transforms = [colour_shift, PixaShiftXY(*common.get_truck_body_offsets(7, truck_length))]), 49: PixaSequence(points = body_sprites['8'], transforms = [colour_shift, PixaShiftXY(*common.get_truck_body_offsets(8, truck_length))]), } )
def get_body(body_path, row_num): body_loader = PixaImageLoader(mask=(0, 255)) crop_start_y = (row_num) * common.SPRITEROW_HEIGHT crop_end_y = crop_start_y + common.SPRITEROW_HEIGHT crop_box = (0, crop_start_y, common.BODY_SPRITE_WIDTH, crop_end_y) body = body_loader.make_points(body_path, crop_box, origin=(0, 9)) return PixaSequenceCollection(sequences={226: PixaSequence(points=body)})
def sc_chassis(chassis_floorplan_start_y): chassis_loader = PixaImageLoader(mask=(0, 226, 255)) chassis_path = os.path.join(currentdir, 'input','trucks_chassis', 'tandem.png') crop_start_y = chassis_floorplan_start_y crop_end_y = chassis_floorplan_start_y + common.SPRITEROW_HEIGHT crop_box = (0, crop_start_y, common.BODY_SPRITE_WIDTH, crop_end_y) chassis = chassis_loader.make_points(chassis_path, crop_box, origin=(0, 0)) return PixaSequenceCollection( sequences = {226: PixaSequence(points = chassis, transforms = [PixaShiftXY(0, -9)])} )
def get_load_sequence(set_name, load_state): colour_shift_amount = colourshifts[set_name] magic_colours = { 191: {'sprite':'large_tarp_1', 'load_states':(1,2,3,4)}, 190: {'sprite':'small_tarp_1', 'load_states':(3,4)}, 189: {'sprite':'large_tarp_2', 'load_states':(1,2,3,4)}, 188: {'sprite':'small_tarp_2', 'load_states':(3,4)}, 187: {'sprite':'large_tarp_3', 'load_states':(1,2,3,4)}, 186: {'sprite':'small_tarp_3', 'load_states':(3,4)}, 185: {'sprite':'large_tarp_4', 'load_states':(1,2,3,4)}, 184: {'sprite':'small_tarp_4', 'load_states':(3,4)}, } sequences = {} for i in magic_colours: if load_state.num_id in magic_colours[i]['load_states']: points = load_sprites[magic_colours[i]['sprite']] sequences[i] = PixaSequence(points=points, transforms=[PixaShiftColour(147, 153, colour_shift_amount)]) else: sequences[i] = PixaSequence(points=[(0, 0, common.COL_MASK)]) return PixaSequenceCollection( sequences = sequences )
def get_cargo_load(cargo_path, load_state, increment): if load_state.name == 'empty': return PixaSequenceCollection(sequences={}) else: cargo_loader = PixaImageLoader(mask=(0, 255)) crop_start_y = (increment - 1) * common.SPRITEROW_HEIGHT crop_end_y = crop_start_y + common.SPRITEROW_HEIGHT crop_box = (0, crop_start_y, common.CARGO_SPRITE_WIDTH, crop_end_y) cargo_load = cargo_loader.make_points(cargo_path, crop_box, origin=(0, 9)) return PixaSequenceCollection(sequences={ 226: PixaSequence(points=cargo_load), })
def hide_or_show_drawbar_dolly_wheels(connection_type): """ returns sequences to draw in dolly wheels for drawbar trailers, or mask them out with blue """ if connection_type == 'drawbar': transform = None else: transform = PixaMaskColour(0) return PixaSequenceCollection( sequences={ 49: PixaSequence(points=[(0, 0, 19)], transforms=[transform]), 48: PixaSequence(points=[(0, 0, 18)], transforms=[transform]), 230: PixaSequence(points=[(0, 0, 5)], transforms=[transform]), 229: PixaSequence(points=[(0, 0, 4)], transforms=[transform]), 228: PixaSequence(points=[(0, 0, 3)], transforms=[transform]), 227: PixaSequence(points=[(0, 0, 2)], transforms=[transform]), })
(0, -3, pc_body()), (0, -4, 13), ] body_inner = [ (0, 0, 16), (0, -1, 17), (0, -2, 18), (0, -3, 19), (0, -4, 14), ] # sequence collections sc_pass_1 = PixaSequenceCollection( sequences={ 94: PixaSequence(points=body_inner), 93: PixaSequence(points=body_inner, transforms=[PixaShiftColour(0, 255, 1)]), }) def get_sc_cargo(cargo_colour_id, load_state): # returns sequences with correct y offset for current load state if load_state.name == 'empty': cargo_colour = 19 else: cargo_colour = cargo_colours[cargo_colour_id] bulk_load = [(0, 0, cargo_colour)] return PixaSequenceCollection(
from pixa import PixaColour, PixaSequence, PixaSequenceCollection from pixa import Spritesheet import Image import common gestalt_id = 'fifth_wheel_mask_body' floorplan_filename = 'fifth_wheel_mask_body_floorplan.png' # for this case we just redraw the mask shape pixels in the same colour sc_passthrough = PixaSequenceCollection( sequences={244: PixaSequence(points=[ (0, 0, 244), ])}) def generate(filename): gv = common.GestaltBodyVariation(filename) floorplan = common.get_gestalt_floorplan(gv, floorplan_filename) spritesheet = common.make_spritesheet(floorplan, row_count=1) spriterows = [] # spriterow holds data needed to render the row # only one spriterow for tank trailers; only one load state needed spriterow = {'height': common.SPRITEROW_HEIGHT, 'floorplan': floorplan} # add n render passes to the spriterow (list controls render order, index 0 = first pass) spriterow['render_passes'] = [ { 'seq': sc_passthrough, 'colourset': None }, ]
pc_cc1 = PixaColour(name='company_colour_1', default=common.CC1) # pixel sequences # x,y,colour (or colour object with optional shift) flatbed = [ (0, 0, pc_deck()), ] stakes = [ (0, 0, 133), (0, -1, 21), ] # sequence collections sc_body_pass_1 = PixaSequenceCollection( sequences={ 94: PixaSequence(points=flatbed, transforms=[PixaShiftColour(0, 255, -1)]), 93: PixaSequence(points=stakes), 141: PixaSequence(points=flatbed, transforms=[PixaShiftColour(0, 255, 1) ]), #143-136 flatbed 140: PixaSequence(points=flatbed, transforms=[PixaShiftColour(0, 255, 0) ]), #143-136 flatbed 139: PixaSequence(points=flatbed, transforms=[PixaShiftColour(0, 255, -1) ]), #143-136 flatbed 165: PixaSequence(points=[(0, 0, pc_cc1(-1))]), }) sc_body_pass_2 = PixaSequenceCollection( sequences={ 195: PixaSequence(points=[(0, 0, pc_cc1())]),
FLOORPLAN_START_Y = 10 # points cargo_loader = PixaImageLoader(mask=(0,255)) load_sprites = {} for spritename in ('large_tarp_1','large_tarp_2','large_tarp_3','large_tarp_4', 'small_tarp_1','small_tarp_2','small_tarp_3','small_tarp_4'): filename = spritename + '.png' tarp_path = os.path.join(currentdir, 'input','cargos', 'tarps', filename) load_sprites[spritename] = cargo_loader.make_points(tarp_path, origin=(2,4)) #tarp_sprite = cargo_loader.get_image(tarp_path) #make_cheatsheet(tarp_sprite, os.path.join(currentdir, 'cheatsheets', filename), origin=(2,4)) # sequence collections sc_mask_out_template_guides = PixaSequenceCollection( sequences = { 66: PixaSequence(points=[(0, 0, common.COL_MASK)]), 85: PixaSequence(points=[(0, 0, common.COL_MASK)]), 140: PixaSequence(points=[(0, 0, common.COL_MASK)]), 151: PixaSequence(points=[(0, 0, common.COL_MASK)]), 182: PixaSequence(points=[(0, 0, common.COL_MASK)]), } ) def get_load_sequence(set_name, load_state): colour_shift_amount = colourshifts[set_name] magic_colours = { 191: {'sprite':'large_tarp_1', 'load_states':(1,2,3,4)}, 190: {'sprite':'small_tarp_1', 'load_states':(3,4)}, 189: {'sprite':'large_tarp_2', 'load_states':(1,2,3,4)}, 188: {'sprite':'small_tarp_2', 'load_states':(3,4)}, 187: {'sprite':'large_tarp_3', 'load_states':(1,2,3,4)},
(1, -1, pc_tank()), (0, -1, pc_tank(-1)), (6, 0, pc_tank()), (5, 0, pc_tank()), (4, 0, pc_tank()), (3, 0, pc_tank()), (2, 0, pc_tank()), (1, 0, pc_tank(-1)), (0, 0, 2), ] # sequence collections sc_pass_1 = PixaSequenceCollection( sequences={ 47: PixaSequence(points=tank_far_end_nw_se), #47-40 NW-SE 45: PixaSequence(points=tank_nw_se), #47-40 NW-SE 44: PixaSequence(points=tank_nw_se, transforms=[PixaShiftColour(0, 255, -1)]), #47-40 NW-SE 40: PixaSequence(points=tank_near_end_nw_se), #47-40 NW-SE 92: PixaSequence(points=tank_n_s, transforms=[PixaShiftColour(0, 255, -1) ]), #88-95 N-S 93: PixaSequence(points=tank_n_s), #88-95 N-S 94: PixaSequence(points=tank_end_n_s), #88-95 N-S 143: