ChenyuRabbitLove commited on
Commit
1141bac
โ€ข
1 Parent(s): 4d44b71

bugfix: fix minor bugs

Browse files
Files changed (2) hide show
  1. css/style.css +2 -2
  2. utils/completion_reward.py +28 -24
css/style.css CHANGED
@@ -342,8 +342,8 @@ input[type="range"]::-ms-track {
342
 
343
  .selected {
344
  color: #fff !important;
345
- background: #d29512 !important;
346
- border: 2px solid #b77f0e !important;
347
  border-radius: 8px !important;
348
  }
349
 
 
342
 
343
  .selected {
344
  color: #fff !important;
345
+ background: #f3b868 !important;
346
+ border: 2px solid #eb6584 !important;
347
  border-radius: 8px !important;
348
  }
349
 
utils/completion_reward.py CHANGED
@@ -478,19 +478,6 @@ class ImageProcessor:
478
  tmp_img = Image.new("RGBA", img.size, (0, 0, 0, 0))
479
  draw = ImageDraw.Draw(tmp_img)
480
 
481
- # Fonts
482
- title_font = ImageFont.truetype("NotoSansTC-Bold.ttf", 34)
483
- body_font = ImageFont.truetype("NotoSansTC-Light.ttf", 14)
484
-
485
- # Text contents
486
- title = f"ๅ…‰ๆŸๅฎˆ่ญท่€… - {player_name} ็š„ๅ†’้šชๆ•…ไบ‹"
487
- paragraph = "Your long paragraph text goes here..." # Replace with your paragraph
488
-
489
- # Calculate text size
490
- left, right = 50, img.width - 50
491
- title_x, title_y = left + 20, 20 # Title position
492
- body_x, body_y = left + 20, title_y + 60 # Body position
493
-
494
  # Calculate space required by the paragraph
495
  paragraph_height = 0
496
  for line in paragraph.split("\n"):
@@ -499,27 +486,44 @@ class ImageProcessor:
499
  line_height = draw.textsize(wrapped_line, font=body_font)[1]
500
  paragraph_height += line_height + 25
501
 
502
- # Calculate box height and top, bottom position
503
- padding = 40 # Additional padding
504
- box_height = max(600, paragraph_height + padding) # Minimum height or paragraph height
 
505
  top = (img.height - box_height) // 2
506
  bottom = (img.height + box_height) // 2
 
507
 
508
  # Draw the rounded rectangle
509
- border_radius = 20
510
  fill_color = (255, 255, 255, 200)
511
- draw.rounded_rectangle([left, top, right, bottom], fill=fill_color, outline=None, radius=border_radius)
 
 
 
 
 
 
 
 
 
512
 
513
- # Draw the title text
514
- draw.text((title_x, top + 20), title, font=title_font, fill="black")
 
 
 
 
 
 
 
 
 
515
 
516
- # Draw the paragraph text
517
- body_y = top + 60 + title_font.getsize(title)[1]
518
  for line in paragraph.split("\n"):
519
- wrapped_lines = textwrap.wrap(line, width=60)
520
  for wrapped_line in wrapped_lines:
521
  draw.text((body_x, body_y), wrapped_line, font=body_font, fill="black")
522
- body_y += draw.textsize(wrapped_line, font=body_font)[1] + 25
523
 
524
  # Save the image with the text
525
 
 
478
  tmp_img = Image.new("RGBA", img.size, (0, 0, 0, 0))
479
  draw = ImageDraw.Draw(tmp_img)
480
 
 
 
 
 
 
 
 
 
 
 
 
 
 
481
  # Calculate space required by the paragraph
482
  paragraph_height = 0
483
  for line in paragraph.split("\n"):
 
486
  line_height = draw.textsize(wrapped_line, font=body_font)[1]
487
  paragraph_height += line_height + 25
488
 
489
+ # Draw the box
490
+ padding = 40
491
+ left, right = 50, img.width - 50
492
+ box_height = min(800, paragraph_height + padding)
493
  top = (img.height - box_height) // 2
494
  bottom = (img.height + box_height) // 2
495
+ border_radius = 20
496
 
497
  # Draw the rounded rectangle
 
498
  fill_color = (255, 255, 255, 200)
499
+ draw.rounded_rectangle(
500
+ [left, top, right, bottom],
501
+ fill=fill_color,
502
+ outline=None,
503
+ radius=border_radius,
504
+ )
505
+
506
+ img.paste(Image.alpha_composite(img.convert("RGBA"), tmp_img), (0, 0), tmp_img)
507
+
508
+ draw = ImageDraw.Draw(img)
509
 
510
+ # Draw the text
511
+ title_font = ImageFont.truetype("NotoSansTC-Bold.ttf", 34)
512
+ body_font = ImageFont.truetype("NotoSansTC-Light.ttf", 14)
513
+
514
+ # Title text
515
+ title = f"ๅ…‰ๆŸๅฎˆ่ญท่€… - {player_name} ็š„ๅ†’้šชๆ•…ไบ‹"
516
+ title_x, title_y = left + 20, top + 20 # Adjust padding as needed
517
+ draw.text((title_x, title_y), title, font=title_font, fill="black")
518
+
519
+ # Paragraph text with newlines
520
+ body_x, body_y = left + 20, title_y + 60 # Adjust position as needed
521
 
 
 
522
  for line in paragraph.split("\n"):
523
+ wrapped_lines = textwrap.wrap(line, width=55)
524
  for wrapped_line in wrapped_lines:
525
  draw.text((body_x, body_y), wrapped_line, font=body_font, fill="black")
526
+ body_y += 25
527
 
528
  # Save the image with the text
529