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)

1  
please include function drawThoughtLine.
2  
3  
!include once #1010984 // drawThoughtLineText_shift
4  
5  
static void drawThoughtLineText_multiLine(BufferedImage bg,
6  
  BufferedImage img1, int x1, int y1,
7  
  BufferedImage img2, int x2, int y2,
8  
  S text, Color color) {
9  
  
10  
  Graphics2D g = imageGraphics(bg);
11  
  g.setColor(color);
12  
  g.setFont(sansSerif(20));
13  
  
14  
  int w1 = img_minOfWidthAndHeight(img1);
15  
  int w2 = img_minOfWidthAndHeight(img2);
16  
  int sideShift = (w1-w2)/4;
17  
  int len = vectorLength(x2-x1, y2-y1);
18  
  int dx = iround(sideShift*(x2-x1)/len), dy = iround(sideShift*(y2-y1)/len);
19  
  x1 += dx; x2 += dx;
20  
  y1 += dy; y2 += dy;
21  
  
22  
  FontMetrics fm = g.getFontMetrics();
23  
  int lineHeight = fm.getHeight();
24  
  
25  
  float yshift = 0;
26  
  for (S line : reversed(lines(text))) {
27  
    drawOutlineTextAlongLine(g, line, x1, y1, x2, y2, drawThoughtLine_width/2+drawThoughtLineText_shift, yshift, color, Color.black);
28  
    yshift -= lineHeight; 
29  
  }
30  
  
31  
  g.dispose();
32  
}

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: 443 / 476
Version history: 5 change(s)
Referenced in: [show references]