我<circle>在SVG文档中有一个元素,我将其<radialGradient>应用于给出幻觉它是一个球体:
<svg version="1.1" id="sphere_svg" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="640px" height="640px" viewBox="0 0 640 640" enable-background="new 0 0 640 640" xml:space="preserve">
<defs>
<radialGradient id="sphere_gradient" cx="292.3262" cy="287.4077" r="249.2454" fx="147.7949" fy="274.5532" gradientTransform="matrix(1.0729 0 0 1.0729 -23.3359 -23.3359)" gradientUnits="userSpaceOnUse">
<stop id="sphere_gradient_0" offset="0" style="stop-color:#F37D7F"/>
<stop id="sphere_gradient_1" offset="0.4847" style="stop-color:#ED1F24"/>
<stop id="sphere_gradient_2" offset="1" style="stop-color:#7E1416"/>
</radialGradient>
</defs>
<circle fill="url(#sphere_gradient)" cx="320" cy="320" r="320"/>
</svg>
Run Code Online (Sandbox Code Playgroud)
它看起来像这样:

我可以WebGLRenderer使用Gabe Lerner的canvg库在three.js 容器中渲染它:
/* sphere_asset is a div containing the svg element */ …Run Code Online (Sandbox Code Playgroud) 我有以下SWT测试代码:
public static void main(String[] args) {
shell = new Shell();
shell.setText(APP_NAME + " " + APP_VERSION);
shell.addShellListener(new ShellListener() {
public void shellActivated(ShellEvent event) { }
public void shellClosed(ShellEvent event) { exit(); }
public void shellDeactivated(ShellEvent event) { }
public void shellDeiconified(ShellEvent event) { }
public void shellIconified(ShellEvent event) { }
});
shell.open();
display = shell.getDisplay();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
}
Run Code Online (Sandbox Code Playgroud)
我的exit()方法如下:
private void exit() {
System.exit(0);
}
Run Code Online (Sandbox Code Playgroud)
我尝试通过关闭shell("窗口")或下拉应用程序菜单(标记为"SWT")并选择"退出"来退出应用程序.
当我这样做时,一个SWT存根留在Dock中,并且SWT应用程序实际上没有退出.我必须通过Eclipse或Force Quit手动终止SWT应用程序.
我已经尝试使用v3.4和v3.5 SWT jar,在Mac …
在编写自定义子类时UITableViewCell,我发现结果适用于普通样式的矩形单元格UITableView,但对于分组样式表中的圆角单元格则根本不起作用.
有没有办法可靠地子类UITableViewCell绘制适用于分组样式表的单元格?(不使用Interface Builder.)
我有一个UISwitch自定义内部UITableViewCell(我调用的子类RootLabeledSwitchTableCell).
单元格包含a UILabel并且UISwitch彼此相邻.
我有一个@property调用keychainSwitch指向此自定义单元格内的开关:
@interface RootLabeledSwitchTableCell : UITableViewCell {
IBOutlet UILabel *textLabel;
IBOutlet UISwitch *labeledSwitch;
}
@property (nonatomic, retain) IBOutlet UILabel *textLabel;
@property (nonatomic, retain) IBOutlet UISwitch *labeledSwitch;
@end
Run Code Online (Sandbox Code Playgroud)
在我的表视图委托中,我添加了一个在翻转开关状态时调用的选择器:
- (UITableViewCell *) tableView:(UITableView *)tv cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NSString *CellIdentifier = [NSString stringWithFormat: @"%d:%d", [indexPath indexAtPosition:0], [indexPath indexAtPosition:1]];
UITableViewCell *cell = [tv dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
switch (indexPath.section) {
case(kMyFirstSection): {
switch (indexPath.row) {
case(kMyFirstSectionFirstRow) …Run Code Online (Sandbox Code Playgroud) 我正在制作一个格子levelplot,x并且y因子范围为[0,1]:
x y level
1 m3134 m3134 1.0000000
2 m3134 m416B 0.4189057
3 m416B m3134 0.2696508
4 m3134 mA20 0.3322170
5 mA20 m3134 0.2454191
6 m3134 mB 0.3176792
...
Run Code Online (Sandbox Code Playgroud)
这是我用来根据这些数据制作图形的R脚本:
#!/foo/bar/bin/Rscript --vanilla
args <- commandArgs(TRUE)
mtxFn <- args[1]
pdfFn <- args[2]
mtx <- read.table(mtxFn, col.names=c("x", "y", "level"))
mtx$level[(mtx$level == 1)] <- NA
library(lattice)
trellis.device(dev=pdf, file=pdfFn)
colors <- colorRampPalette(c('red', 'white'))(256)
fig <- levelplot(level~x*y,
data=mtx,
col.regions=colors,
xlab="",
ylab="",
aspect="iso",
scales=list(
x=list(rot=90)
),
panel=function(...) {
arg <- …Run Code Online (Sandbox Code Playgroud) 如果在管道的任何步骤中存在非零错误的情况下捕获到非零错误,则设置bash pipefail选项(via set -o pipefail)允许脚本失败.
但是,我们SIGPIPE遇到了错误(错误代码141),其中数据被写入不再存在的管道.
有没有办法设置bash来忽略SIGPIPE错误,或者是否有一种方法来编写一个错误处理程序来处理所有错误状态代码,比如0和141?
例如,在Python中,我们可以添加:
signal.signal(signal.SIGPIPE, signal.SIG_DFL)
Run Code Online (Sandbox Code Playgroud)
将默认行为应用于SIGPIPE错误:忽略它们(参见http://coding.derkeiler.com/Archive/Python/comp.lang.python/2004-06/3823.html).
bash中是否有类似的选项?
可以使用JavaScript来设置a的像素y偏移量UIWebView,例如:
[webView stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"scrollTo(0, %d)", offset]];
Run Code Online (Sandbox Code Playgroud)
有没有办法得到:
这些信息UIWebView是否可以通过其他方式获得?
我想如果我有页数(通过CGPDFDocumentGetNumberOfPages),页面之间的像素高度差距,或单个页面的像素高度,我可以计算offset使用JavaScript调用.然后我只是连接一个UIButton或UISlider在页面之间移动.
编辑我
我有一个解决方案,但它使用UIWebDocumentView了一个私人子视图UIWebView.
我创建了一个名为的视图控制器PDFViewerViewController,它是一个子类WebViewerViewController,它本身就是一个视图控制器,它包含a UIToolbar,a UIWebView,并且符合UIWebViewDelegate协议.
在调用PDFViewerViewControllerWeb视图委托方法之后,我会计算有关封闭Web视图和PDF数据的一些信息-webViewDidFinishLoad:.
此信息用于计算通过JavaScript提供给Web视图的大致每页偏移量.
PDFViewerViewController.h
#import <UIKit/UIKit.h>
#import "WebViewerViewController.h"
@interface UIWebDocumentView : NSObject {}
@end
@interface PDFViewerViewController : WebViewerViewController {
NSUInteger offset;
NSUInteger currentPage;
NSUInteger documentPages;
CGFloat documentHeight;
CGFloat pageHeight;
}
@property (assign) NSUInteger offset;
@property (assign) NSUInteger …Run Code Online (Sandbox Code Playgroud) 我有一个C应用程序,我正在尝试为Mac OS X 10.6.4编译:
$ uname -v
Darwin Kernel Version 10.4.0: Fri Apr 23 18:28:53 PDT 2010; root:xnu-1504.7.4~1/RELEASE_I386
Run Code Online (Sandbox Code Playgroud)
我的gcc情况如下:
$ gcc --version
i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5664)
Run Code Online (Sandbox Code Playgroud)
我的Makefile情况如下:
CC=gcc
CFLAGS=-D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -O3 -Wformat -Wall -pedantic -std=gnu99
all: myApp
rm -rf *~
myApp: myApp.o
${CC} ${CFLAGS} myApp.o -lbz2 -o myApp
rm -rf *~
clean:
rm -rf *.o myApp
Run Code Online (Sandbox Code Playgroud)
问题是我的应用程序调用fseeko64和fopen64,并使用off64_t类型进行偏移.当我编译我的应用程序时,我收到以下警告和错误:
$ make myApp
gcc -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -O3 -Wformat -Wall -pedantic …Run Code Online (Sandbox Code Playgroud) 我有一个input领域:
<input type="text" name="notifyEmail" id="parametersEmail" value="" size=40 />
Run Code Online (Sandbox Code Playgroud)
我有一大块jquery代码,当我点击tab或以其他方式离开字段时,它会调用验证例程:
$("#parametersEmail").blur(function(event) {
validateParameterEmail();
});
Run Code Online (Sandbox Code Playgroud)
我想做的是validateParameterEmail()每当输入字段的值或内容发生变化时运行该函数.
所以我接着尝试了.change()处理程序:
$("#parametersEmail").change(function(event) {
validateParameterEmail();
});
Run Code Online (Sandbox Code Playgroud)
但是当我更改内容时parametersEmail,此处理程序不会调用验证函数.
我应该使用另一个处理程序吗?或者我不能将多个事件处理程序附加到输入字段?
我File::Find::Rule用于在以下指定的目录中找到一级深度的用户可执行文件夹$dir:
my @subDirs = File::Find::Rule->permissions(isExecutable => 1, user => "$uid")->
extras({ follow => 1, follow_skip => 2 })->
directory->
maxdepth(1)->
in( $dir );
Run Code Online (Sandbox Code Playgroud)
这是使用UNIX find实用程序的粗略等效项:
my $subDirStr = `find $dir -maxdepth 1 -type d -user $username -perm -100`;
chomp($subDirStr);
my @subDirs = split("\n", $subDirStr);
Run Code Online (Sandbox Code Playgroud)
两者都在具有恢复此数据权限的脚本中运行.
如果我find在命令行上运行语句,结果会立即返回.
如果我通过Perl脚本运行上述任一语句,结果需要几秒钟才能运行.
我可以通过编程方式来提高两种Perl方法中的任何一种的性能吗?
iphone ×3
uitableview ×2
bash ×1
blur ×1
c ×1
darwin ×1
file ×1
find ×1
fopen ×1
input ×1
java ×1
javascript ×1
jquery ×1
lattice ×1
levelplot ×1
linux ×1
macos ×1
na ×1
onchange ×1
pdf ×1
perl ×1
posix ×1
properties ×1
python ×1
r ×1
signals ×1
sigpipe ×1
subclass ×1
svg ×1
swt ×1
three.js ×1
uiswitch ×1
uiwebview ×1
unix ×1
validation ×1
webgl ×1