如何解决为什么将svg渲染为倾斜处理中?
我的目标是使用Processing 3在Windows 10上重新制作经典的Freecell纸牌游戏,适用于Windows Xp。
为此,我从here下载了一组最类似于旧卡外观的svg文件。
在我的代码中,我有一个名为Deck
的类,其中包含ArrayList
的卡片,并且在构造时会初始化卡片,从而为卡片提供所需的svg文件的路径以及x和y坐标。
class Deck
{
String[] seeds = {"HEART","DIAMOND","CLUB","SPADE"};
String[] values = {"1","2","3","4","5","6","7","8","9","10","11","12","13"};
ArrayList<Card> cards = new ArrayList<Card>();
Deck()
{
//Create the cards and store them into the array.
for(int seed = 0; seed < seeds.length; seed++)
{
for(int value = 0; value < values.length; value++)
{
String cardName = seeds[seed] + "-" + values[value] + ".svg";
cards.add(new Card(cardName));
}
}
//Shuffle the deck.
//this.shuffle();
//Give the cards x and y coordinates.
for(int c = 0; c < cards.size(); c++)
{
int x = cardspace + (cardWidth+cardspace)*(c%8);
int y = 32 + cardHeight + edge*2 + cardspace + 25*(c/8);
cards.get(c).setxy(x,y);
}
}
void shuffle()
{
for(int c = cards.size()-1; c > 0; c--)
{
int k = (int)Math.floor(Math.random() * (c + 1));
Card card = cards.get(c);
cards.set(c,cards.get(k));
cards.set(k,card);
}
}
void render()
{
for(Card card : cards)
{
card.render();
}
}
}
卡类:
class Card
{
PShape svg;
int x;
int y;
Card(String svgName)
{
this.svg = loadShape(svgName);
}
void setxy(int x,int y)
{
this.x = x;
this.y = y;
}
boolean isMouSEOver()
{
return mouseX > x && mouseX < (x+cardWidth) && mouseY > y && mouseY < (y+cardHeight);
}
void render()
{
shape(svg,x,y,cardWidth,cardHeight);
}
}
类render()
的{{1}}方法在每个Deck
循环中调用一次,并且draw()
设置为10。
无论如何,代码工作正常,唯一的问题是如何呈现两个svg,如您在此处看到的:
由于某些原因,只有 5铁锹和心jack 的内部图完全倾斜。
但是,当使用Inkscape或任何浏览器打开时,它们的方向正确,因此很困惑。
我尝试使用这两个svg的原始版本,但它们仍呈现倾斜状态。我试图比较这两个svg的xml,但是我不明白是什么原因引起的。
它可能也在处理中,但是我不知道为什么或如何解决它。
在此先感谢您的任何帮助。
编辑
根据注释中的要求添加主草图文件。
但是请注意,它已从上方的灰色条和矩形中去除。
frameRate
解决方法
我对其进行了测试,并且似乎可以解决该问题。
在SPADE-5.svg的第84/85行中,删除
transform="rotate(180,1744.645,-315.5025)"
HEART-11-JACK.svg,第123/124行,删除
transform="rotate(0.33810995,363.27095,269.89449)"
(请确保不要删除>
)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。