我一直在尝试增强我用Java编写的GUI系统以使用子像素抗锯齿并且已经成功,除了两个剩余的异常.这是几个星期前我的另一个问题的后续问题.
第一个问题是将设置渲染提示KEY_ANTIALIASING设置为VALUE_ANTIALIAS_ON会导致KEY_TEXT_ANTIALIASING在设置为LCD(子像素)AA值时被忽略.任何人都可以对此有所了解吗?目前我在渲染文本之前被迫使用VALUE_ANTIALIAS_OFF,并在渲染文本后将其重新打开(以便其他绘画,如圆圈等,是AA'd).下面的独立测试程序证明了这个问题.
第二个问题是我找不到查询AA的底层操作系统设置,所以我必须做一个相当大的解决方法,即创建一个Swing JLabel,获取它的FontMetrics,得到它的FontRenderContext然后得到AA提示.除了在一个程序中涉及Swing,否则完全不使用Swing,它将无法在运行任何J2ME JVM的设备上运行.任何人都可以提出更好的方法吗?如果它需要J5或J6就可以了,因为当前的kludge已经需要J6(但只需要J4就是最好的).我已经尝试了每个默认设置并使用AWT组件而不是JLabel.
该程序验证要使子像素AA工作,必须首先禁用一般AA设置.(PS:我写入后台缓冲区,因为我的底层GUI确实如此,我想在等效的上下文中进行测试).
import java.awt.*;
import java.awt.event.*;
public class AwtTestFrame1b extends Panel {
private final Font font=new Font(Font.SANS_SERIF, Font.PLAIN, 16);
private final int line=25;
AwtTestFrame1b() {
setBackground(SystemColor.control);
}
public void paint(Graphics g) {
Graphics2D g2d = (Graphics2D)g;
int py=0;
py=paintText(g2d,py,null ,false);
py=paintText(g2d,py,null ,true );
py+=line;
py=paintText(g2d,py,RenderingHints.VALUE_TEXT_ANTIALIAS_OFF ,false);
py=paintText(g2d,py,RenderingHints.VALUE_TEXT_ANTIALIAS_DEFAULT ,false);
py=paintText(g2d,py,RenderingHints.VALUE_TEXT_ANTIALIAS_ON ,false);
py=paintText(g2d,py,RenderingHints.VALUE_TEXT_ANTIALIAS_GASP ,false);
py=paintText(g2d,py,RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB,false);
py+=line;
py=paintText(g2d,py,RenderingHints.VALUE_TEXT_ANTIALIAS_OFF ,true );
py=paintText(g2d,py,RenderingHints.VALUE_TEXT_ANTIALIAS_DEFAULT ,true );
py=paintText(g2d,py,RenderingHints.VALUE_TEXT_ANTIALIAS_ON ,true );
py=paintText(g2d,py,RenderingHints.VALUE_TEXT_ANTIALIAS_GASP ,true );
py=paintText(g2d,py,RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB,true );
py+=line; …Run Code Online (Sandbox Code Playgroud) 有没有人曾尝试使用Swing构建一个合适的多缓冲渲染环境,在此环境中可以添加Swing用户界面元素?
在这种情况下,我有一个动画红色矩形绘制在背景上.背景不需要每帧更新,因此我将其渲染到BufferedImage上,并仅重绘清除矩形的先前位置所需的部分.请参见下面的完整代码,这扩展了以前的线程通过@trashgod给出的例子,在这里.
到现在为止还挺好; 流畅的动画,低CPU使用率,无闪烁.
然后我将JTextField添加到Jpanel(通过单击屏幕上的任何位置),并通过在文本框内单击来关注它.现在,清除矩形的先前位置会在每个光标闪烁时失败,请参见下图.
我很好奇是否有人知道为什么会发生这种情况(Swing不是线程安全的?图像是异步绘制的?)以及寻找可能解决方案的方向.
这是在Mac OS 10.5,Java 1.6上
JPanel重绘失败了http://www.arttech.nl/javaredrawerror.png
import java.awt.Color;
import java.awt.Dimension;
import java.awt.EventQueue;
import java.awt.Graphics;
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Insets;
import java.awt.Rectangle;
import java.awt.Transparency;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.image.BufferedImage;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.Timer;
public class NewTest extends JPanel implements
MouseListener,
ActionListener,
ComponentListener,
Runnable
{
JFrame f;
Insets insets;
private Timer t = new Timer(20, …Run Code Online (Sandbox Code Playgroud) 我遇到了需要为Mailchimp准备时事通讯的rake任务.
使用rails 2.x东西googled我现在有这个代码:
desc "Sends newsletter to Mailchimp list"
task :send_newsletter => :environment do
begin
# get render helpers
av = ActionView::Base.new(Rails::Application::Configuration.new(Rails.root).view_path)
av.class_eval do
include ApplicationHelper
end
things = Stuff.do.things
h = Hominid::Base.new({:api_key => "xxx"})
h.create_campaign(
{
:list_id => "xxx",
:subject => "Hey...",
:from_email => "xxx",
:from_name => "xxx",
:to_email => "",
:auto_footer => true,
:generate_text => true
},
{
:html => av.render(:template => "stuff/newsletter", :locals => {:things => things}, :layout => false)
},
"regular")
rescue Exception => e
STDERR.puts …Run Code Online (Sandbox Code Playgroud) 我注意到IE9以非常低的质量呈现尺寸缩小的图像:如果我在200x150 IMG标签中显示800x600 jpg图像,IE9中的结果非常令人失望.
在IE8和Chrome中,同一页面显示完美.IE7也行,只要我使用CSS样式-ms-interpolation-mode: bicubic;).Firefox显示与IE9相同的令人沮丧的结果,但这似乎是一个已知的错误,请参阅https://bugzilla.mozilla.org/show_bug.cgi?id=486918
我已经搜索了Stack Overflow和其他论坛,但没有发现有关IE9渲染与IE8的任何投诉.
有没有人知道这是IE9中的一个错误.有解决方法吗?
我无法提交图片,因为我是Stack Overflow的新用户.但您可以轻松重现该问题:
在Paint.Net中创建一个带有画笔宽度为1或2的椭圆的800x600.jpg.以200px x 150px IMG标签显示此图像将IE9与Chrome和IE8进行比较(使用IEtester)
我试图弄清楚如何在Windows游戏中手动管理整个游戏循环,而不使用常规游戏Microsoft.Xna.Framework.Game类.
这样做的原因是使用常规的Game类会导致我的游戏中出现一些口吃.不多,但由于游戏的特殊性,它仍然是非常明显的.
在尝试了一堆不同的设置(vsync,fixedtimestep,各种帧率等)后,我决定尝试编写自己的Game类来完全控制时间.我不确定会解决它,但至少这样我完全可以控制.
基本上我需要:
谁知道怎么做?事实上这听起来很容易,但找不到任何关于如何做的文档.
不确定我做错了什么,但我有以下代码(仅用于测试,时间将以不同方式处理),并且循环将运行一段时间然后停止.一旦我将鼠标指针移过窗口,循环将再次运行一段时间.
private void Application_Idle(object pSender, EventArgs pEventArgs)
{
Thread.Sleep(500);
//Message message;
//while (!PeekMessage(out message, IntPtr.Zero, 0, 0, 0))
{
gametime.update();
Update(gametime);
Draw(gametime);
GraphicsDevice.Present();
}
}
Run Code Online (Sandbox Code Playgroud)
如果启用"while PeekMessage",循环将连续运行,但忽略睡眠并在鼠标移动窗口时停止.不确定这里发生了什么......
我认为最好我只想在主渲染循环中做这样简单的事情:
while (alive)
{
Thread.Sleep(100);
gametime.update();
Update(gametime);
Draw(gametime);
GraphicsDevice.Present();
}
Run Code Online (Sandbox Code Playgroud)
但在这种情况下,窗口仍然是空白的,因为看起来窗口实际上没有使用新内容重绘.我尝试了一个form.Refresh(),但仍然没有...任何想法?
在IE9中看一下这个:
http://jsfiddle.net/dalgard/n6PDB/show/
屏幕转储:

阅读这些评论:
/*
* IE9: Upon moving the mouse a ghostly 1px vertical line appears 53px into the
* blue area - only works with normalized CSS (!?) and not inside an iframe
*/
#test {
width: 152px; /* must be 152px or larger! */
height: 200px; /* can be any height */
border-radius: 1px; /* must be 1px or larger */
background-color: #44f; /* ghost-line becomes invisible with #00f */
}
#test:hover {} /* removing this makes …Run Code Online (Sandbox Code Playgroud) 目前我使用45度角为我的gluPerspective().这是正确的角度,使渲染在人类感知它时看起来真实吗?窗口纵横比也存在问题,例如2:1窗口将使得45度角看起来更像是具有3:4比例等的屏幕上的80度角.因此窗口尺寸也改变了视角.
那么,与人类如何看待世界相比,使游戏看起来最真实的窗口大小比例和视角是多少?
我是blender和python的新手.我有一个搅拌器模型(.blend),我想批量渲染为几个图像,为每个图像提供一些属性.
我用这些参数编写了一个python脚本,如:
import bpy
pi = 3.14159265
fov = 50
scene = bpy.data.scenes["Scene"]
# Set render resolution
scene.render.resolution_x = 480
scene.render.resolution_y = 359
# Set camera fov in degrees
scene.camera.data.angle = fov*(pi/180.0)
# Set camera rotation in euler angles
scene.camera.rotation_mode = 'XYZ'
scene.camera.rotation_euler[0] = 0.0*(pi/180.0)
scene.camera.rotation_euler[1] = 0.0*(pi/180.0)
scene.camera.rotation_euler[2] = -30.0*(pi/180.0)
# Set camera translation
scene.camera.location.x = 0.0
scene.camera.location.y = 0.0
scene.camera.location.z = 80.0
Run Code Online (Sandbox Code Playgroud)
那么我就像运行它一样
blender -b marker_a4.blend --python "marker_a4.py" -o //out -F JPEG -x 1 -f 1
Run Code Online (Sandbox Code Playgroud)
然后,例如,如果我尝试使用python脚本的参数
... …Run Code Online (Sandbox Code Playgroud) 我正在寻找一种可以随着时间的推移可视化文字云变化的工具.
我有一个包含大量条目的数据库,我生成的词云帮助我的团队更好地了解产品的使用方式.
但我意识到,展示趋势如何随时间而变化会更有趣.
使用Google WebFonts(在本例中为"Oswald"),我发现我的字体比它们应该更大胆.我使用以下方法在基于webkit的浏览器中解决了这个问题
-webkit-font-smoothing: antialiased;
Run Code Online (Sandbox Code Playgroud)
但在Firefox中我找不到控制它的声明.我听说使用text-shadow黑客来解决这个问题,但我不想使用它,因为它无疑会改变字体的几何属性.
以下是webkit(Chrome)中的内容:

这是由于Firefox的块状可怕渲染:

我知道有一种方法可以在FireFox中实现这一点,因为我在font-combinator.com上找到了这个字体,并且它使用Firefox在font-combinator上正确呈现.以下是通过font-combinator.com在Firefox上看起来的样子:

在浏览用于创建font-combinator的css之后,我发现了这个声明:text-rendering: optimizelegibility;但是当应用于我的元素时这不起作用.
我也尝试过:
text-rendering: optimizeLegibility;
text-rendering: geometricPrecision;
font-smooth: always;
font-smooth: never;
font-smoothing: antialiased;
-moz-font-smoothing: antialiased;
Run Code Online (Sandbox Code Playgroud)
我怎样才能让Firefox对我的字体进行抗锯齿处理,以便它们在显示时看起来正确?您能找到使它们在www.font-combinator.com上正确显示的声明或声明组合吗?
我使用的是相对旧版本的FireFox(16.0.2),因为这台机器安装了旧版本的OSX.
rendering ×10
css ×2
fonts ×2
java ×2
animation ×1
antialiasing ×1
batch-file ×1
blender-2.50 ×1
buffering ×1
fieldofview ×1
firefox ×1
game-loop ×1
html ×1
image ×1
macos ×1
opengl ×1
python ×1
rake ×1
render ×1
swing ×1
word-cloud ×1
xna ×1