當前位置: 首頁>>代碼示例>>Java>>正文


Java ColorFactory類代碼示例

本文整理匯總了Java中org.patchca.color.ColorFactory的典型用法代碼示例。如果您正苦於以下問題:Java ColorFactory類的具體用法?Java ColorFactory怎麽用?Java ColorFactory使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ColorFactory類屬於org.patchca.color包,在下文中一共展示了ColorFactory類的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: init

import org.patchca.color.ColorFactory; //導入依賴的package包/類
private void init(int min, int max){
	MIN_LEN = min;
	MAX_LEN = max;
	cs.setColorFactory(new ColorFactory() {
           @Override
           public Color getColor(int x) {
               int[] c = new int[3];
               int i = random.nextInt(c.length);
               for (int fi = 0; fi < c.length; fi++) {
                   if (fi == i) {
                       c[fi] = random.nextInt(71);
                   } else {
                       c[fi] = random.nextInt(256);
                   }
               }
               return new Color(c[0], c[1], c[2]);
           }
       });
       RandomWordFactory wf = new RandomWordFactory();
       wf.setCharacters(RANDOM_CHAR);
       wf.setMaxLength(MIN_LEN);
       wf.setMinLength(MAX_LEN);
       cs.setWordFactory(wf);
}
 
開發者ID:mattxia,項目名稱:unique-web,代碼行數:25,代碼來源:PatchcaRender.java

示例2: convertToCharacters

import org.patchca.color.ColorFactory; //導入依賴的package包/類
protected TextString convertToCharacters(String text, Graphics2D g, FontFactory fontFactory, ColorFactory colorFactory) {
	TextString characters = new TextString();
	FontRenderContext frc = g.getFontRenderContext();
	double lastx = 0;
	for (int i = 0; i < text.length(); i++) {
		Font font = fontFactory.getFont(i);
		char c = text.charAt(i);
		FontMetrics fm = g.getFontMetrics(font);
		Rectangle2D bounds = font.getStringBounds(String.valueOf(c), frc);
		TextCharacter tc = new TextCharacter();
		tc.setCharacter(c);
		tc.setFont(font);
		tc.setWidth(fm.charWidth(c));
		tc.setHeight(fm.getAscent() + fm.getDescent());
		tc.setAscent(fm.getAscent());
		tc.setDescent(fm.getDescent());
		tc.setX(lastx);
		tc.setY(0);
		tc.setFont(font);
		tc.setColor(colorFactory.getColor(i));
		lastx += bounds.getWidth();
		characters.addCharacter(tc);
	}
	return characters;
}
 
開發者ID:pusuo,項目名稱:patchca,代碼行數:26,代碼來源:AbstractTextRenderer.java

示例3: draw

import org.patchca.color.ColorFactory; //導入依賴的package包/類
@Override
public void draw(String text, BufferedImage canvas, FontFactory fontFactory, ColorFactory colorFactory) {
	Graphics2D g = (Graphics2D) canvas.getGraphics();
	TextString ts = convertToCharacters(text, g, fontFactory, colorFactory);
	arrangeCharacters(canvas.getWidth(), canvas.getHeight(), ts);
	g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
	g.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);
	g.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
	for (TextCharacter tc : ts.getCharacters()) {
		g.setColor(tc.getColor());
		g.drawString(tc.iterator(), (float) tc.getX(), (float) tc.getY());
	}
}
 
開發者ID:pusuo,項目名稱:patchca,代碼行數:14,代碼來源:AbstractTextRenderer.java

示例4: setColorFactory

import org.patchca.color.ColorFactory; //導入依賴的package包/類
public void setColorFactory(ColorFactory colorFactory) {
	this.colorFactory = colorFactory;
}
 
開發者ID:pusuo,項目名稱:patchca,代碼行數:4,代碼來源:SingleColorBackgroundFactory.java

示例5: getColorFactory

import org.patchca.color.ColorFactory; //導入依賴的package包/類
public ColorFactory getColorFactory() {
	return colorFactory;
}
 
開發者ID:pusuo,項目名稱:patchca,代碼行數:4,代碼來源:AbstractCaptchaService.java

示例6: CurvesRippleFilterFactory

import org.patchca.color.ColorFactory; //導入依賴的package包/類
public CurvesRippleFilterFactory(ColorFactory colorFactory) {
	setColorFactory(colorFactory);
}
 
開發者ID:pusuo,項目名稱:patchca,代碼行數:4,代碼來源:CurvesRippleFilterFactory.java

示例7: setColorFactory

import org.patchca.color.ColorFactory; //導入依賴的package包/類
public void setColorFactory(ColorFactory colorFactory) {
	curves.setColorFactory(colorFactory);
}
 
開發者ID:pusuo,項目名稱:patchca,代碼行數:4,代碼來源:CurvesRippleFilterFactory.java

示例8: draw

import org.patchca.color.ColorFactory; //導入依賴的package包/類
void draw(String text, BufferedImage canvas, FontFactory fontFactory, ColorFactory colorFactory); 
開發者ID:pusuo,項目名稱:patchca,代碼行數:2,代碼來源:TextRenderer.java


注:本文中的org.patchca.color.ColorFactory類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。