Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

32
LINES

< > BotCompany Repo | #1010983 // drawThoughtLineText_multiLine - draws on bg

JavaX fragment (include)

please include function drawThoughtLine.

!include once #1010984 // drawThoughtLineText_shift

static void drawThoughtLineText_multiLine(BufferedImage bg,
  BufferedImage img1, int x1, int y1,
  BufferedImage img2, int x2, int y2,
  S text, Color color) {
  
  Graphics2D g = imageGraphics(bg);
  g.setColor(color);
  g.setFont(sansSerif(20));
  
  int w1 = img_minOfWidthAndHeight(img1);
  int w2 = img_minOfWidthAndHeight(img2);
  int sideShift = (w1-w2)/4;
  int len = vectorLength(x2-x1, y2-y1);
  int dx = iround(sideShift*(x2-x1)/len), dy = iround(sideShift*(y2-y1)/len);
  x1 += dx; x2 += dx;
  y1 += dy; y2 += dy;
  
  FontMetrics fm = g.getFontMetrics();
  int lineHeight = fm.getHeight();
  
  float yshift = 0;
  for (S line : reversed(lines(text))) {
    drawOutlineTextAlongLine(g, line, x1, y1, x2, y2, drawThoughtLine_width/2+drawThoughtLineText_shift, yshift, color, Color.black);
    yshift -= lineHeight; 
  }
  
  g.dispose();
}

Author comment

Began life as a copy of #1007309

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1010983
Snippet name: drawThoughtLineText_multiLine - draws on bg
Eternal ID of this version: #1010983/6
Text MD5: 0e1400b9860660093c9c8121a2d2944f
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-10-11 01:57:54
Source code size: 978 bytes / 32 lines
Pitched / IR pitched: No / No
Views / Downloads: 442 / 475
Version history: 5 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)