当前位置: 首页>>代码示例>>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;未经允许,请勿转载。