当前位置: 首页>>代码示例>>Python>>正文


Python BufferedImage.getSubimage方法代码示例

本文整理汇总了Python中java.awt.image.BufferedImage.getSubimage方法的典型用法代码示例。如果您正苦于以下问题:Python BufferedImage.getSubimage方法的具体用法?Python BufferedImage.getSubimage怎么用?Python BufferedImage.getSubimage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.image.BufferedImage的用法示例。


在下文中一共展示了BufferedImage.getSubimage方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: aquaNode

# 需要导入模块: from java.awt.image import BufferedImage [as 别名]
# 或者: from java.awt.image.BufferedImage import getSubimage [as 别名]
def aquaNode(text,fSize):
	vWidth = 300
	vHeight = 100

	BLUR = array([0.10, 0.10, 0.10, 0.10, 0.30, 0.10, 0.10, 0.10, 0.10],'f')
	inset = 10
	buttonColor = Color.BLUE.brighter().brighter().brighter()
	foregroundColor = Color(1,1,1,0.6)

	toRet = BufferedImage(vWidth, vHeight, BufferedImage.TYPE_INT_RGB)
	g2 = toRet.createGraphics()

	testFont = g2.getFont().deriveFont(Font.BOLD,fSize)
	fontMetrics = Toolkit.getDefaultToolkit().getFontMetrics(testFont); 
	vWidth = Math.max(100,Math.round(fontMetrics.stringWidth(text) * 1.5)) 
	vHeight = Math.max(30,Math.round((fontMetrics.getHeight() + fontMetrics.getAscent())*1.5))
	
	toRet = BufferedImage(vWidth, vHeight, BufferedImage.TYPE_INT_RGB)
	g2 = toRet.createGraphics()
	g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON)

	vBuffer = BufferedImage(vWidth, vHeight, BufferedImage.TYPE_INT_RGB)
	bg = vBuffer.createGraphics()
	bg.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON)

	vButtonHeight = vHeight - (inset * 2);
	vButtonWidth = vWidth - (inset * 2);
	vArcSize = vButtonHeight;

	bg.setColor(getDisplayBackground());
	bg.fillRect(0, 0, vWidth, vHeight);

	vGradientStartColor =  buttonColor.darker().darker().darker();
	vGradientEndColor = buttonColor.brighter().brighter().brighter();
	vPaint = GradientPaint(0, inset, vGradientStartColor, 0, vButtonHeight, vGradientEndColor, false);
	bg.setPaint(vPaint);

	bg.fillRoundRect(inset, inset, vButtonWidth, vButtonHeight, vArcSize, vArcSize);
	vHighlightInset = 2;
	vButtonHighlightHeight = vButtonHeight - (vHighlightInset * 2);
	vButtonHighlightWidth = vButtonWidth - (vHighlightInset * 2);
	vHighlightArcSize = vButtonHighlightHeight;

	vGradientStartColor = Color.WHITE;
	vGradientEndColor = buttonColor.brighter();
	vPaint = GradientPaint(0,inset+vHighlightInset,vGradientStartColor,0,inset+vHighlightInset+(vButtonHighlightHeight/2), buttonColor.brighter(), false);

	bg.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER,.8));
	bg.setPaint(vPaint);
	bg.setClip(RoundRectangle2D.Float(inset+vHighlightInset,inset+vHighlightInset,vButtonHighlightWidth,vButtonHighlightHeight / 2,vButtonHighlightHeight / 3,vButtonHighlightHeight /3));
	bg.fillRoundRect(inset+vHighlightInset,inset+vHighlightInset,vButtonHighlightWidth,vButtonHighlightHeight,vHighlightArcSize,vHighlightArcSize);

	vBlurOp = ConvolveOp(Kernel(3, 3, BLUR));
	vBlurredBase = vBlurOp.filter(vBuffer, None);

	g2.drawImage(vBlurredBase, 0, 0, None);

	g2.setColor(foregroundColor);
	
	g2.setFont(testFont);
	vMetrics = g2.getFontMetrics();
	vStringBounds = vMetrics.getStringBounds(text,g2);

	xt = ((vWidth / 2) - (vStringBounds.getWidth() / 2));
	yt = ((vHeight / 2) + (vStringBounds.getHeight() / 2)) - vMetrics.getDescent();

	g2.drawString(text,xt,yt);

	toRet = toRet.getSubimage(inset,inset,vButtonHighlightWidth+inset/2,vButtonHighlightHeight+inset/2);
	return toRet
开发者ID:carvalhomb,项目名称:tsmells,代码行数:72,代码来源:CustomNodes.py


注:本文中的java.awt.image.BufferedImage.getSubimage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。