我正在定义一个XAML DrawingBrush资源,我想绘制一个自定义形状.我找到了以下GeometryDrawing示例:
<GeometryDrawing Geometry="M0,0.1 L0.1,0 1,0.9, 0.9,1z" Brush="Gray" />
Run Code Online (Sandbox Code Playgroud)
做什么的M,L以及z在信件Geometry的属性是什么意思?他们叫什么?
这是我目前正在进行的网站:http://willcrichton.net/
如果单击中间六边形每边的箭头,可以看到它使用jQuery + jQuery Cycle + jQuery Easing左右转换.但是,你也可以看到它相当丑陋 - 因为我使用六边形而不是正方形,因为div是方形的,内容六边形以令人不快的方式与背景重叠.
所以,我的问题是:我怎么能把div变成六角形呢?该六边形应该与内容div的大小/形状相同,并且当内容在六边形区域之外时,它应该是不可见的.
编辑:
HTML
<div id="content">
<div class="slide">
<a href="#"><div class="arrow left"></div></a>
<a href="#"><div class="arrow right"></div></a>
<div id="websites-title"></div>
<div class="website">
</div>
</div>
<div class="slide">
<a href="#"><div class="arrow left"></div></a>
<a href="#"><div class="arrow right"></div></a>
</div></div>
<script type="text/javascript">
$("#content").cycle({
fx: 'scrollHorz',
timeout: 0,
prev: ".left",
next: ".right",
easing: "easeInOutBack"
});
</script>
Run Code Online (Sandbox Code Playgroud)
CSS
/* Container styles */
#container {
width: 908px;
height: 787px;
left: 50%;
top: 50%;
position: absolute;
margin-top: -393.5px;
margin-left: … 鉴于凸多边形,我试图在保持其直径的同时增长其形状(如"最大区域").直径定义为可放置在多边形内的最长段的长度.由于多边形是凸的,我假设通过扫描所有顶点对总能找到这个直径.
例如,给定等边三角形作为输入多边形,三角形的直径是任何边的长度; 平滑这将导致3个圆段,如图所示
对于任意凸多边形,一种非常低效的算法是计算以每个多边形顶点为中心的最大直径半径圆的交点; 这就是我目前使用的(Java).有更好的吗?任何伪代码或指向算法的指针都将受到赞赏.
另一个例子:压扁的五边形及其相应的直径保持最大形状.这个想法是你不能在不增加直径的情况下增加这种形状的面积(也就是说,可以在比原始直径更长的形状范围内画出一条直线).在这种特殊情况下,似乎半径= polygon_diameter/2(粉红色)的单个圆优于半径= polygon_diameter(浅蓝色)的多个较大圆的交点.第二个图像叠加两个区域以使比较更容易,但区域应完全包围多边形.

我想制作一个类似于UIBackBarButtonItem的UIButton(向左指向导航堆栈的箭头.我更愿意这样做而不必使用图像,如果可能的话,因为按钮将具有不同的大小,具体取决于手机的取向.
有没有办法在代码中激活这种影响?我的想法是以某种方式使用按钮的CALayer.
谢谢!
编辑
我正在尝试使用@ Deepak的建议,但我遇到了一个问题.我希望按钮的右侧看起来像[UIBezierPath bezierPathWithRoundedRect:rect cornerRadius:4],左侧看起来像箭头.我尝试使用addQuadCurveToPoint:controlPoint方法执行此操作.
我使用矩形的角作为控制点,但路径不像我期望的那样弯曲.它仍然是走投无路的,好像我只使用了addLineToPoint:方法.我的代码如下.
float radius = 4.0;
UIBezierPath *path = [UIBezierPath bezierPath];
CGPoint startPoint = CGPointMake(rect.size.width/5.0, 0);
CGPoint pointBeforeTopCurve = CGPointMake(rect.size.width - radius, 0);
CGPoint topRightCorner = CGPointMake(rect.size.width, 0);
CGPoint pointAfterTopCurve = CGPointMake(rect.size.width, 0.0-radius);
CGPoint pointBeforeBottomCurve = CGPointMake(rect.size.width, rect.size.height-radius);
CGPoint bottomRightCorner = CGPointMake(rect.size.width, rect.size.height);
CGPoint pointAfterBottomCurve = CGPointMake(rect.size.width - radius, rect.size.height);
CGPoint pointBeforeArrow = CGPointMake(rect.size.width/5.0, rect.size.height);
CGPoint arrowPoint = CGPointMake(0, rect.size.height/2.0);
[path moveToPoint:pointBeforeTopCurve];
[path addQuadCurveToPoint:pointAfterTopCurve controlPoint:topRightCorner];
[path addLineToPoint:pointBeforeBottomCurve];
[path addQuadCurveToPoint:pointAfterBottomCurve controlPoint:bottomRightCorner];
[path addLineToPoint:pointBeforeArrow];
[path …Run Code Online (Sandbox Code Playgroud) 我有一个Numpy 3轴阵列,其元素是3维的.我想平均它们并返回相同形状的数组.正常平均函数删除3个维度并将其替换为平均值(如预期的那样):
a = np.array([[[0.1, 0.2, 0.3], [0.2, 0.3, 0.4]],
[[0.4, 0.4, 0.4], [0.7, 0.6, 0.8]]], np.float32)
b = np.average(a, axis=2)
# b = [[0.2, 0.3],
# [0.4, 0.7]]
Run Code Online (Sandbox Code Playgroud)
结果要求:
# b = [[[0.2, 0.2, 0.2], [0.3, 0.3, 0.3]],
# [[0.4, 0.4, 0.4], [0.7, 0.7, 0.7]]]
Run Code Online (Sandbox Code Playgroud)
你能优雅地做到这一点,还是只需要在Python中迭代数组(与强大的Numpy函数相比,它会慢得多).
你能否为np.mean函数将Dtype参数设置为1D数组?
谢谢.
我正在使用opencv,我需要了解fitEllipse函数是如何工作的.我查看了(https://github.com/Itseez/opencv/blob/master/modules/imgproc/src/shapedescr.cpp)的代码,我知道它使用最小二乘来确定可能的椭圆.我还查看了文档中给出的文件(Andrew W. Fitzgibbon,RBFisher.一个买方的Conic Fitting指南.Proc.5th British Machine Vision Conference,Birmingham,pp.513-522,1995.)
但我无法完全理解算法.例如,为什么它需要解决3倍最小二乘问题?为什么bd在第一个svd之前被初始化为10000(我猜它是juste初始化的一个随机值,但为什么这个值可以是随机的?)?为什么广告中的值在第一个svd之前需要为负数?
谢谢!
我正在为我的一个朋友制作一个宏,他需要在excel文档中导入一组图像,然后在其他计算机上使用该文档.我遇到的问题是,当在另一台计算机上打开此文档时,所有图像都消失了,而是你得到这些小错误标志,表明无法找到图像路径.
我已经在我自己的计算机上开发了宏,我有Excel 2007,对我来说,代码工作得非常好.我的朋友使用Excel 2013,显然,这两个版本如何处理图像导入和保存似乎有很大的不同.
总的来说,我发现了两种不同的插入图像的方法.我尝试的第一个类似于此:
Set pic = ActiveSheet.Pictures.Insert("C:\documents\somepicture.jpg")
Run Code Online (Sandbox Code Playgroud)
第二种方式看起来像这样:
Set pic = Application.ActiveSheet.Shapes.AddPicture("C:\documents\somepicture.jpg", False, True, 1, 1, 1, 1)
Run Code Online (Sandbox Code Playgroud)
在第二种方法的文档中,据说第三个参数(这里为True)负责用文档保存图片.
但是,这两种方法在最终结果中看起来大致相同:它们对我来说很好,但是如果它们在我的朋友的PC上用Excel 2013执行它将无法工作.所以我需要的是为更新的解决方案Excel版本(我从Excel 2010向上读过某些地方,有这些图像导入方法的错误或类似的东西).
这是circle.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid android:color="#00000000"/>
<padding android:left="30dp" android:top="30dp"
android:right="30dp" android:bottom="30dp" />
<stroke android:color="#439CC8" android:width="7dp" />
</shape>
Run Code Online (Sandbox Code Playgroud)
这是我的代码:
textview.setBackgroundResource(R.drawable.circle);
Run Code Online (Sandbox Code Playgroud)
我想在我的java代码中更改笔触粗细.如何以编程方式更改它?
我有一个多边形shapefile(可在这里下载),我想从中创建一个data.frame包含3列的3列:
从这个答案在这里,我知道它很容易得到这个信息作为Formal Class SpatialPoints对象.当我将此对象转换为data.frame时,我会丢失id信息.
# Load Shapefile
Legislative_areas <- readOGR(dsn = 'C:/Users/.../Downloads/Legislative2010UTM', layer ='Legislative2010UTM')
# Get centroids
cent <- gCentroid(Legislative_areas, byid=TRUE)
# Convert to data.frame, but loose id info
cent <- as.data.frame(cent)
Run Code Online (Sandbox Code Playgroud)
关于如何保存身份信息的任何想法?
我想geom_dotplot通过点的形状(而不是文档建议的颜色)来区分两个不同的变量.例如:
library(ggplot2)
set.seed(1)
x = rnorm(20)
y = rnorm(20)
df = data.frame(x,y)
ggplot(data = df) +
geom_dotplot(aes(x = x), fill = "red") +
geom_dotplot(aes(x=y), fill = "blue")
Run Code Online (Sandbox Code Playgroud)
即在下面的例子中区分x和y
我想将所有x设置为点,将y设置为三角形.
这可能吗?谢谢!