~widelands-dev/widelands/trunk

« back to all changes in this revision

Viewing changes to utils/make_spritemap.py

  • Committer: The Widelands Bunnybot
  • Date: 2024-10-19 13:45:54 UTC
  • Revision ID: bunnybot@widelands.org-20241019134554-kz2gcbecf0y7bd7n
170 files were automatically formatted.

(by bunnybot)
5a9087b08ab9bbc48795ff0f7f1f370f60108b1a

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
 
32
32
    Note: Returns a rectangle with cost strictly greater than FRAGMENT_COST + 1 if bitmask contains
33
33
    no set pixels.
 
34
 
34
35
    """
35
36
    if bitmask.shape[0] * bitmask.shape[1] > 4000:
36
37
        raise Exception('macr_exact_bruteforce called on a large bitmask')
85
86
    Covered in bitmask)
86
87
 
87
88
    Returns (cost, rectangle)
 
89
 
88
90
    """
89
91
    return macr_exact_bruteforce(bitmask, FRAGMENT_COST=FRAGMENT_COST)
90
92
 
119
121
 
120
122
    Returns (cost, rectangle), where cost is None if no additional
121
123
    pixels can be covered.
 
124
 
122
125
    """
123
126
    best_cost = None
124
127
    best_rectangle = rectangle
230
233
    with a goal of minimizing Total Area of Covering Rectangles + FRAGMENT_COST * Number of Covering Rectangles.
231
234
 
232
235
    Returns (cost, list of rectangles)
 
236
 
233
237
    """
234
238
    # This implements the simple set cover heuristic,
235
239
    # i.e. it greedily covers pixels by adding a rectangle with minimum cost
273
277
    frame, as well as individual deltas.
274
278
 
275
279
    Returns (cost, base_pic, base_pic_rect, [frame_rectangles])
 
280
 
276
281
    """
277
282
    shape = frames[0].pic.shape
278
283
    all_opaque_mask = np.all(
308
313
    into blits accordingly.
309
314
 
310
315
    Return (avgcost, list of list of ((x, y), pic, pc_pic))
 
316
 
311
317
    """
312
318
    pc = frames[0].pc_pic is not None
313
319
    regions = []
377
383
 
378
384
    We add frames to candidate frame groups greedily as long as the average cost per frame
379
385
    decreases. As a heuristic, frames with high pixel overlap are combined first.
 
386
 
380
387
    """
381
388
    MAXREJECT = 10
382
389
    uncovered = [idx for idx in xrange(len(frames))]