标签: shape

如何在XAML/WPF中存储和检索多个形状?

使用XAML/WPF做一些简单的事情似乎有很多问题 - 我使用像Rectangle和Ellipse这样的形状创建了一些基于XAML的图像来创建我需要应用程序的其他部分使用的图标 - 但我不能似乎找到了如何做到这一点 - 我似乎能够在资源字典中存储Canvas,但无法在任何其他窗口中使用它.这是怎么做的 - 这些是我想要在整个项目中使用的两三个形状的简单图像!
图像也必须可调整大小 - 我知道如何存储路径,但是这些形状包含我想保留的渐变样式,而且我不知道矩形如何转换为路径和颜色数据.

谢谢!

vb.net wpf resources xaml shape

3
推荐指数
1
解决办法
3628
查看次数

3
推荐指数
2
解决办法
5332
查看次数

用另一个SVG形状填充SVG形状

是否可以使用一个SVG形状作为另一个形状的填充?

svg shape fill

3
推荐指数
1
解决办法
941
查看次数

我怎么能在矩形形状android内画一条线

我有这样的自定义矩形

<?xml version="1.0" encoding="utf-8"?>
    <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" android:padding="10dp">
    <solid android:color="#FFFFFF" />
    <stroke android:width="1dip" android:color="#ff6600" />
    <corners
        android:bottomRightRadius="5dp"
        android:bottomLeftRadius="5dp"
        android:topLeftRadius="5dp"
        android:topRightRadius="5dp"/>
</shape>
Run Code Online (Sandbox Code Playgroud)

我想在这个矩形内画一条线

<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="line" >
    <solid android:color="@color/cafe" />    
    <stroke android:width="5dip" 
    android:color="#FF0000" android:dashWidth="5dip"/>
</shape>
Run Code Online (Sandbox Code Playgroud)

我怎么能这样做,帮助

android shape line

3
推荐指数
1
解决办法
9290
查看次数

Java - 从图像边框创建一个形状

我有一个从png图像中绘制形状的类,这样我就可以使用该形状绘制我项目所需的自定义按钮的边框.这是绘制图像形状的类的代码:

public class CreateShapeClass {
    public static Area createArea(BufferedImage image, int maxTransparency) {
        Area area = new Area();
        Rectangle rectangle = new Rectangle();
        for (int x = 0; x < image.getWidth(); x++) {
            for (int y = 0; y < image.getHeight(); y++) {
                int rgb = image.getRGB(x, y);
                rgb = rgb >>> 24;
                if (rgb >= maxTransparency) {
                    rectangle.setBounds(x, y, 1, 1);
                    area.add(new Area(rectangle));
                }
            }
        }
        return area;
    }
}
Run Code Online (Sandbox Code Playgroud)

然而,这需要很长时间来处理,我认为通过在主应用程序中预先绘制形状然后将它们存储到数组并传递给其他类,它将减少渲染时间.但是,paintBorder()方法绘制按钮边框所花费的时间也需要相当长的时间(尽管比绘制形状所需的时间短),因为上面的类生成的形状是填充的而不是空.我曾尝试使用java2d绘制形状,例如,Ellipse2D,并且按钮的渲染只需要很短的时间.在这个领域有经验的人可以教我如何生成一个BufferedImage边界的形状?我使用上面的类从PNG图像创建具有透明背景的形状.

java image border awt shape

3
推荐指数
1
解决办法
4706
查看次数

JAVA(Swing)中的镜像形状

大家好,

我有一个功课,涉及在Swing GUI中绘制和操作形状.

我遇到了一个问题,当我试图镜像我的形状时,我得不到我想要的结果.

drawallnodes方法在Jpanels paintComponent中调用.

public void drawallnodes(ArrayList<DevicesEditor> nodes, Graphics2D g2)
{
    int arraysize = nodes.size();
    ArrayList<DevicesEditor> temparray;

    AffineTransform at = new AffineTransform();

    if (nodes.size() != 0)
    {
        System.out.println("nodes.size " + nodes.size());
        if (currentarrayindex >= 0)
        {

            AffineTransform afx = new AffineTransform();// for rotate

            for (int i = 0; i <= currentarrayindex; i++)
            {
                if (nodes.get(i).getWasAngleChanged())
                {
                    afx.rotate(
                        Math.toRadians(nodes.get(i).getAngleInDegrees()), 
                        nodes.get(i).getCenter().x,
                        nodes.get(i).getCenter().y);
                    nodes.get(i).setShape(
                            afx.createTransformedShape(nodes.get(i).getShape()));
                    nodes.get(i).setWasAngleChanged(false);
                    nodes.get(i).setokrajRectangle();
                }

                try
                {
                    Rectangle r = nodes.get(i).getShape().getBounds();
                }
                catch (Exception e)
                {
                    System.out.println(
                        "Exception …
Run Code Online (Sandbox Code Playgroud)

java swing mirror shape graphics2d

3
推荐指数
1
解决办法
2137
查看次数

3
推荐指数
1
解决办法
2131
查看次数

如何使用xml(shape)下面的EditText将行设置为背景?

我想使用shape xml将行设置为EditText下面的背景但是当我在中心设置行设置时

我想在下面

在此输入图像描述

但是当我设置下面的形状时

绘制/ line.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="line" >
<stroke
    android:height="4dp"
    android:color="@color/crabfx_dark_gray" />
</shape>
Run Code Online (Sandbox Code Playgroud)

activity_main.xml中

<EditText
    android:id="@+id/edt"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:textColor="@android:color/black"
    android:layout_margin="20dp" 
    android:background="@drawable/line"/>
Run Code Online (Sandbox Code Playgroud)

我得到了以下输出

在此输入图像描述

有什么办法吗?

xml android shape

3
推荐指数
1
解决办法
4030
查看次数

具有圆角xml形状的蒙版布局

我有这个LinearLayout:

<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="vertical">

    <ImageView
        android:layout_width="100dp"
        android:layout_height="70dp"
        android:src="@drawable/ic_launcher"
        android:scaleType="centerCrop"/>

    <TextView
        android:layout_width="100dp"
        android:layout_height="30dp"
        android:background="#FFD800"
        android:textColor="@android:color/black"
        android:gravity="center"
        android:text="Text View"/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

我想用圆角遮盖它,如下所示:

在此处输入图片说明

我试图将其放置在具有Layout.xml之上的另一个布局的FrameLayout中,

但是我得到的最多是:

在此处输入图片说明

要么

在此处输入图片说明

我正在寻找一种使用shape.xml背景的方法,

但是边框内部是透明的,外面是白色。

我的shape.xml:

<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid
    android:color="#FFFFFF">
</solid>

<stroke
android:width="2dp"
android:color="#000000" >
</stroke>

<padding
    android:left="5dp"
    android:top="5dp"
    android:right="5dp"
    android:bottom="5dp">
</padding>

<corners
    android:radius="50dp">
</corners>
</shape>
Run Code Online (Sandbox Code Playgroud)

xml android mask shape

3
推荐指数
1
解决办法
4156
查看次数

在WPF中将Shape转换为可重用的几何体

我试图将System.Windows.Shapes.Shape对象转换为System.Windows.Media.Geometry对象.

使用该Geometry对象,我将根据一组数据点使用自定义图形控件多次渲染它.这要求Geometry对象的每个实例都有一个唯一的TranslateTransform对象.

现在,我正以两种不同的方式处理这个问题,但似乎都没有正常工作.我的自定义控件使用以下代码来绘制几何:

//Create an instance of the geometry the shape uses.
Geometry geo = DataPointShape.RenderedGeometry.Clone();
//Apply transformation.
TranslateTransform translation = new TranslateTransform(dataPoint.X, dataPoint.Y);
geo.Transform = translation;
//Create pen and draw geometry.
Pen shapePen = new Pen(DataPointShape.Stroke, DataPointShape.StrokeThickness);
dc.DrawGeometry(DataPointShape.Fill, shapePen, geo);
Run Code Online (Sandbox Code Playgroud)

我还尝试了以下替代代码:

//Create an instance of the geometry the shape uses.
Geometry geo = DataPointShape.RenderedGeometry;
//Apply transformation.
TranslateTransform translation = new TranslateTransform(dataPoint.X, dataPoint.Y);
dc.PushTransform(translation);
//Create pen and draw geometry.
Pen …
Run Code Online (Sandbox Code Playgroud)

c# wpf geometry shape custom-controls

3
推荐指数
1
解决办法
4610
查看次数

标签 统计

shape ×10

android ×4

java ×2

wpf ×2

xml ×2

awt ×1

border ×1

c# ×1

colors ×1

custom-controls ×1

delphi ×1

fill ×1

geometry ×1

gradient ×1

graphics2d ×1

image ×1

line ×1

mask ×1

mirror ×1

resources ×1

svg ×1

swing ×1

vb.net ×1

xaml ×1