标签: rect

你能控制SVG的笔画宽度是如何绘制的吗?

目前正在构建基于浏览器的SVG应用程序.在这个应用程序中,用户可以设置和定位各种形状,包括矩形.

当我将一个stroke-widthSVG rect元素应用于某个SVG 元素时1px,rect不同浏览器会以不同的方式将笔划应用于偏移和插入.这被证明是麻烦的,特别是当我尝试计算矩形的外部宽度和视觉位置并将其放置在其他元素旁边时.

例如:

  • Firefox增加1px插入(底部和左侧)和1px偏移(顶部和右侧)
  • Chrome增加了1px插页(顶部和左侧)和1px偏移(底部和右侧)

到目前为止,我唯一的解决方案是自己绘制实际边界(可能使用path工具)并将边框定位在描边元素后面.但是这个解决方案是一个令人不快的解决方案,如果可能的话,我宁愿不走这条路.

所以我的问题是,你能控制如何stroke-width在元素上绘制SVG 吗?

svg rect offset

188
推荐指数
6
解决办法
9万
查看次数

SVG:rect内的文本

我想 SVG中显示一些文本rect.可能吗?

我试过了

<svg xmlns="http://www.w3.org/2000/svg">
  <g>
    <rect x="0" y="0" width="100" height="100" fill="red">
      <text x="0" y="10" font-family="Verdana" font-size="55" fill="blue"> Hello </text>
    </rect>
  </g>
</svg>
Run Code Online (Sandbox Code Playgroud)

但它不起作用.

svg text rect

162
推荐指数
4
解决办法
18万
查看次数

50
推荐指数
2
解决办法
2万
查看次数

如何检查2个旋转矩形之间的交点?

有人可以解释如何检查一个旋转的矩形是否与其他矩形相交

math intersection rect

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

如何使用CGContext在swift中程序性地绘制矩形/线条

我已经在网上搜索了几天,试图找到关于如何在Swift中以程序方式绘制矩形或线条的最简单的代码示例.我已经看过如何通过覆盖DrawRect命令来完成它.我相信你可以创建一个CGContext然后绘制成一个图像,但我很想看到一些简单的代码示例.或者这是一种可怕的方法?谢谢.

class MenuController: UIViewController 
{

    override func viewDidLoad() 
    {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
        self.view.backgroundColor = UIColor.blackColor()

        var logoFrame = CGRectMake(0,0,118,40)
        var imageView = UIImageView(frame: logoFrame)
        imageView.image = UIImage(named:"Logo")
        self.view.addSubview(imageView)

        //need to draw a rectangle here
    }
}
Run Code Online (Sandbox Code Playgroud)

rect cgcontext swift

17
推荐指数
2
解决办法
4万
查看次数

确定WPF元素相对于某个父级的边界矩形

我认为这是一个非常简单的请求,但我似乎无法在搜索中找到确凿的答案.如何确定窗口中特定视觉元素相对于其他父元素的边界?

我尝试过使用,LayoutInformation.GetLayoutSlot但这似乎只返回Rect0,0并没有反映元素的实际位置.

我正在尝试做的是使用窗口的"屏幕截图",RenderTargetBitmap然后将其裁剪为特定元素,但我无法获得元素的界限,知道要将位图裁剪为什么!

c# wpf layout rect bounds

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

Android将文本绘制到中心的矩形并根据需要裁剪

我想在中心(水平和垂直)上绘制文本为矩形.如果有太多的文本裁剪它不适合rect.

我尝试做的这个例子显示,但没有运气.

有任何想法吗?

android text rect draw

13
推荐指数
2
解决办法
1万
查看次数

检测是否可以将一个矩形放入另一个矩形

这个问题不同于测试一个rect是否在另一个rect中.

已知信息是两个长度的边长.

如何计算一个矩形是否可以放入另一个矩形?

可以直接放入rect b

math rect

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

如何滚动到Horizo​​ntalScrollView的子项中心?

我需要滚动到Horizo​​ntalScrollView的childView(TextView)的中心.我通过使用下面的代码获得了中心孩子,现在我想将箭头调整到该子视图的确切中心.

在这里,我所做的是我拿了一个Horizo​​ntalScrollView,里面有一个LineaerLayout,在LinearLayout里面我有TextViews.

这是我的XML:

 <com.sample.test.ScrollViewCustom
                android:id="@+id/mHorizontalScrollViewMain"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_alignBottom="@id/relativeOne"
                android:background="@drawable/mergethree2"
                android:scrollbars="none" >

                <LinearLayout
                    android:id="@+id/llayoutfirst"
                    android:layout_width="wrap_content"
                    android:layout_height="55dip"
                    android:orientation="horizontal" >

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="12dip"
                        android:background="@drawable/blackline" />

                    <TextView
                        android:id="@+id/mtxtHome"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center"
                        android:layout_marginBottom="5dip"
                        android:layout_marginLeft="5dip"
                        android:layout_marginRight="5dip"
                        android:layout_marginTop="8dip"
                        android:text="home"
                        android:textColor="@android:color/white"
                        android:textSize="15sp"
                        android:typeface="serif" />

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="12dip"
                        android:background="@drawable/blackline" />

                    <TextView
                        android:id="@+id/mtxtSchools"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center"
                        android:layout_marginBottom="5dip"
                        android:layout_marginLeft="5dip"
                        android:layout_marginRight="5dip"
                        android:layout_marginTop="8dip"
                        android:text="schools"
                        android:textColor="@android:color/white"
                        android:textSize="15sp"
                        android:typeface="serif" />

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="12dip"
                        android:background="@drawable/blackline" />

                    <TextView
                        android:id="@+id/mtxtCalendar"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center"
                        android:layout_marginBottom="5dip"
                        android:layout_marginLeft="5dip"
                        android:layout_marginRight="5dip"
                        android:layout_marginTop="8dip"
                        android:text="calendar"
                        android:textColor="@android:color/white"
                        android:textSize="15sp"
                        android:typeface="serif" />

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content" …
Run Code Online (Sandbox Code Playgroud)

android rect horizontalscrollview

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

从矩形缩放UIView的正确转换?

我想模仿视图中的"放大".较大的视图将作为子视图添加到较小视图的超视图中,较大的视图应该看起来好像从较小的视图放大.给定较小视图的矩形fromRect和放大的视图的最终帧,finalRect适当的变换是什么?

在此输入图像描述

我想方法签名就像下面这样,view作为superview.我写这篇文章来帮助自己,但还是想不出来.

-(CGAffineTransform) translatedAndScaledTransformUsingViewRect:(CGRect)viewRect fromRect:(CGRect)fromRect inView:(UIView*) view
{
//calculate the scaling based on the final frame of viewToBeStretched (viewRect) vs the "fromRect"
CGFloat scaleX = ?, scaleY = ?;
CGAffineTransform scaleTransform = CGAffineTransformMakeScale(scaleX, scaleY);

//use translation instead of modifying the view's center, since frame changes with transforms are no good
CGFloat translationX = ?, translationY =?;
CGAffineTransform translationTransform = CGAffineTransformMakeTranslation(translationX, translationY);

CGAffineTransform final = CGAffineTransformConcat(scaleTransform, translationTransform);

return final;
}
Run Code Online (Sandbox Code Playgroud)

objective-c rect cgaffinetransform ios cgrect

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