我正在尝试创建一个透明的png图像,并将各种其他png和jpgs分层,以创建一个具有透明度的最终png.我在创建我的初始空透明png时遇到了麻烦.它目前有白色背景.
任何人都可以指出我正确的方向.到目前为止这是我的代码......
$image = imagecreatetruecolor(485, 500);
imagealphablending($image, false);
imagesavealpha($image, true);
$col=imagecolorallocatealpha($image,255,255,255,127);
imagefill($image, 0, 0, $col);
//imagefilledrectangle($image,0,0,485, 500,$col);
/* add door glass */
$img_doorGlass = imagecreatefrompng("glass/$doorStyle/$doorGlass.png");
imagecopyresampled($image, $img_doorGlass, 106, 15, 0, 0, 185, 450, 185, 450);
/* add door */
$img_doorStyle = imagecreatefrompng("door/$doorStyle/$doorStyle"."_"."$doorColor.png");
imagecopyresampled($image, $img_doorStyle, 106, 15, 0, 0, 185, 450, 185, 450);
$fn = md5(microtime()."door_builder").".png";
if(imagepng($image, "user_doors/$fn", 1)){
echo "user_doors/$fn";
}
imagedestroy($image);
Run Code Online (Sandbox Code Playgroud) 嗨,我正在尝试将我当前的URL存储在会话变量中.
我的应用使用了www.domain.com/add?url=http://www.google.com等查询字符串
但是current_url()返回'ww.domain.com/add'.没有查询字符串的网址.
我检查了帮助文件,current_url似乎只是将uri段附加到配置中设置的site_url.
function current_url()
{
$CI =& get_instance();
return $CI->config->site_url($CI->uri->uri_string());
}
Run Code Online (Sandbox Code Playgroud)
任何人都知道我如何抓住查询字符串来追加它们,甚至只是抓住整个网址.
嗨我正在使用grunt browserify任务来设置我的代码,我已经在jQuery中填充了,我现在正在尝试包含jquery.tablesorter.
jquery插件可以用这种方式与browserify一起使用吗?
shim: {
jquery: {
path: 'lib/bower/jquery/jquery.js',
exports: '$'
},
'jquery.tablesorter': {
path: 'lib/bower/jquery.tablesorter/js/jquery.tablesorter.js',
exports: 'tablesorter',
depends: {
jquery: '$',
}
}
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用布朗运动来创建一组随机移动的粒子. http://jsfiddle.net/J75Em/16/
到目前为止,我已经让粒子随机移动但我不确定如何设置前进方向以使其看起来更自然.
我试图使用x和y轴的变化来计算使用atan的旋转,你可以通过取消注释旋转来看到这一点,但这似乎表现不佳.
这是这种运动的正确方法吗?谢谢;
我试图在我自己的函数中使用jQuery ajax调用的返回,但它仍然返回undefined.
function checkUser2(asdf) {
$.ajax({
type: "POST",
async: false,
url: "check_user.php",
data: { name: asdf },
success: function(data){
return data;
//alert(data);
}
});
}
$("#check").click(function(){
alert(checkUser2("muma"));
});
Run Code Online (Sandbox Code Playgroud)
ajax调用肯定有效,因为当我取消注释我的警报时,我得到正确的返回,我可以在firebug中看到它.我做了些蠢事吗?
我正在寻找关于在元素加载时插入加载GIF的任何教程/文章,我在一些网站上看到过.我似乎只能找到有关预加载图像的文章.
嗨我有这个代码,我希望它从文本区域删除所有的双空格,但它只会删除每次第一次出现.
$(document).ready(function(){
$("#article").blur(function(){
///alert($(this).val());
$(this).val($(this).val().replace(/\s\s+/, ' '));
});
});
Run Code Online (Sandbox Code Playgroud)
我也尝试过removeAll(),但它根本不起作用.任何帮助都会很棒,谢谢.我在http://jsbin.com/ogasu/2/edit上有一个在线实例
我有div元素,包含图像.我想使用jQuery-UI使div可调整大小,调整div和子图像元素的大小.
我已尝试使用alsoResize,如下所示,但它似乎调整了第一个div图像而不是相应的子图像.
$('div').resizable({
alsoResize: $(this).find('img'),
aspectRatio: true,
maxHeight: 140
});
Run Code Online (Sandbox Code Playgroud)
我创建了一个小提琴来演示这个http://jsfiddle.net/letsgojuno/EhyGy/
看起来这个上下文总是第一个div,而不是当前正在调整大小的div.
我正在尝试使用Raphael JS创建一个图像动画.
我想要蜜蜂在页面上随机移动的效果,我有一个有效的例子,但它有点"紧张",我在控制台中收到这个警告:
"资源解释为图像,但使用MIME类型text/html传输"
我不确定这个警告是引起了"紧张"的动作,还是我用数学来接近它的方式.
如果有人有更好的方法来创建效果或改进,请告诉我.
我在这里有一个在线演示
并继承我的javascript代码:
function random(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
function BEE(x, y, scale) {
this.x = x;
this.y = y;
this.s = scale;
this.paper = Raphael("head", 915, 250);
this.draw = function() {
this.paper.clear();
this.paper.image("bee.png", this.x, this.y, 159*this.s, 217*this.s);
}
this.update = function() {
var deg = random(-25, 25);
var newX = Math.cos(Raphael.rad(deg)) * 2;
var newY = Math.sin(Raphael.rad(deg)) * 2;
this.x += newX;
this.y …Run Code Online (Sandbox Code Playgroud) 我创建了一个使用 raphaeljs 库绘制各种 SVG 元素的页面,但我在 Safari 中遇到了一些问题。
我正在绘制图像并使用剪切路径来掩盖某些区域。然后,用户可以点击这些图像“浏览”到放置在后面的其他图像。
这在 Firefox 和 Chrome 甚至 IE 中都能正常工作。但在 Safari 中我无法点击浏览图像。剪切路径似乎在 Safari 中不起作用。
我通过这个问题发现Safari 的内容类型必须设置为“application/xhtml+xml”,因为它不使用 html5 解析器。
我已经尝试过将其放在页面顶部的建议......
<?php
header('Content-type: application/xhtml+xml');
?>
Run Code Online (Sandbox Code Playgroud)
...但是浏览器只输出 html 文件。
我只是想知道我需要什么文档类型才能使 safari 正确绘制嵌入 SVG,例如 chrome 和 firefox?
这就是我绘制 SVG 图像的方式,它在 chrome 和 firefox 中运行良好
function myDraw(path, url, x, y, w, h, id){
//create clipPath Element
var clippath = document.createElementNS("http://www.w3.org/2000/svg","clipPath");
clippath.setAttribute("id", id);
svgcanv.appendChild(clippath);
//draw the path
var cp=paper.path(path).translate(x, y).attr({stroke: 0});
$(cp.node).appendTo('#'+id+'');
//assoc clipPath with image
var img = paper.image(url,x,y,w,h);//.attr({fill:"#111",opacity:0.7}); …Run Code Online (Sandbox Code Playgroud) 嗨,我正在尝试制作一个将条纹效果添加到无序列表的函数,到目前为止,我已经获得了以下内容,但无法确定选择器的工作方式。
(function($) {
$.fn.stripe = function(){
this.$("li:even").css("background-color","#f00");
};
})(jQuery);
$("list_id").stripe();
Run Code Online (Sandbox Code Playgroud) 我已经创建了一个PHP分页系统,但我想隐藏地址栏中的_GET变量.
目前我的看起来像这样: http://example.com/images.php?page=1
但我见过一些网站http://example.com/images/1/.
只是想知道他们是怎么回事?谁能指出我正确的方向?干杯
jquery ×5
javascript ×3
php ×3
math ×2
raphael ×2
ajax ×1
animation ×1
browserify ×1
clipping ×1
codeigniter ×1
doctype ×1
gd ×1
gruntjs ×1
image ×1
jquery-ui ×1
list ×1
particles ×1
query-string ×1
regex ×1
return-value ×1
safari ×1
shim ×1
svg ×1
transparency ×1
uri ×1