小编tra*_*mes的帖子

在 SVG 中切换图层

我正在尝试创建一个带有检查列表的 HTML 页面,我们也可以在不降低质量的情况下将其放大。因此,我想使用 SVG。

我想要一个脚本来操作 SVG,以便我可以svg_2打开或关闭组(复选标记),以便我们选中和取消选中框。加载时不必更改,只需要像内联命令一样即可。

<svg width="20%" height="20%" xmlns="http://www.w3.org/2000/svg">
    <rect id="svg_1" fill="#ffffff" stroke="#000000" stroke-width="10%" x="2.5%" y="2.5%" width="85%" height="85%" />
    <g id="svg_2">
        <line fill="none" stroke="#ff0000" stroke-width="10%" x1="43.5%" y1="77.5%" x2="10.5%" y2="49.5%" id="svg_3" stroke-linecap="round" stroke-linejoin="bevel"/>
        <line fill="none" stroke="#ff0000" stroke-width="10%" x1="95%" y1="9.5%" x2="44.5%" y2="78.5%" id="svg_4" stroke-linecap="round" stroke-linejoin="bevel"/>
    </g>
</svg>
Run Code Online (Sandbox Code Playgroud)

html javascript svg

4
推荐指数
1
解决办法
5309
查看次数

从R.color以编程方式检索颜色会返回错误的颜色

我正在尝试采用用户的xml文件中列出的颜色名称并返回十六进制颜色。我正在根据R.color以编程方式根据帖子检索颜色使用代码。我知道我已经接近了,因为当我在哈希图中以名称作为键使用一小组颜色时,它正在工作,但是文件中超过300种颜色并查找5或6种颜色似乎浪费了处理时间。下面的代码正在使用,但是如果需要,我可以添加更多代码。

用户的xml文件示例。

<Item>
    <Item_Name>Daily</Item_Name>
    <Price>400</Price>
    <Type>Entry</Type>
    <Color>Green</Color>
</Item>
Run Code Online (Sandbox Code Playgroud)

colors.xml

 <color name="green">#008000</color>
Run Code Online (Sandbox Code Playgroud)

Java:

 0   **pass in name from method call**
 1   Class res = R.color.class;
 2   Field field = res.getField( name );
 3   color = field.getInt(null);
Run Code Online (Sandbox Code Playgroud)

当我将其作为调试运行时,给出的结果如下:

0: name = "green"
1: res = tech.travis.poolpos.R$color
2: field = public static final int tech.travis.poolpos.R$color.green
3: color = 2131099743 (integer).  This translates to #&5f00067f,
     which is about a navy blue with an opacity of about 37%.
Run Code Online (Sandbox Code Playgroud)

应该为绿色返回的整数应该是-16744448,而不是2131099743。

如果可能的话,如何将名称作为字符串并与之匹配并返回colors.xml中列出的颜色?

xml android colors

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

Perl If-Elsif-Else总是去其他地方

我在一个更大的程序中有一段代码,假设要取一个字母(A ... D)并将其转换为数字(0 ... 3).由于某种原因,它总是跳到其他地方.这是代码:

        my $AA = shift @filearray;

        chomp($Q);
        chomp($A1);
        chomp($A2);
        chomp($A3);
        chomp($A4);
        chomp($AA);
        print "1:$AA\n";

    #convert answer to number

    my $AB = 0;
        if ($AA eq "A")
        {
            $AB = 0;
        }

        elsif ($AA eq "B")
        {
            $AB = 1;
        }

        elsif ($AA eq "C")
        {
            $AB = 2;
        }

        else {
            $AB = 3;
        }
        print "2:$AB\n\n";
Run Code Online (Sandbox Code Playgroud)

输出是沿着的

    1:B
    2:3

    1:A
    2:3

    1:D
    2:3

    1:C
    2:3

    1:D
    2:3

    1:B
    2:3

    1:B
    2:3

    1:A
    2:3

    1:D
    2:3 …
Run Code Online (Sandbox Code Playgroud)

perl if-statement

0
推荐指数
1
解决办法
75
查看次数

标签 统计

android ×1

colors ×1

html ×1

if-statement ×1

javascript ×1

perl ×1

svg ×1

xml ×1