我有一个png图像作为背景,我想为这个背景添加透明网格,但这不能按预期工作.在我应用透明网格的地方,背景图像会转换为透明.
我在做:
from PIL import Image, ImageDraw
map_background = Image.open(MAP_BACKGROUND_FILE).convert('RGBA')
map_mesh = Image.new('RGBA', (width, height), (0, 0, 0, 0))
draw = ImageDraw.Draw(map_mesh)
# Create mesh using: draw.line([...], fill=(255, 255, 255, 50), width=1)
...
map_background.paste(map_mesh, (0, 0), map_mesh)
Run Code Online (Sandbox Code Playgroud)
但结果是:

如果仔细观察(在图形程序中用作无背景),您可以看到棋盘图案.透明线条使得背景图层在两个层都满足的位置也是透明的.但我只想在背景上添加透明线.
我可以解决它:
map_background.paste((255,255,255), (0, 0), map_mesh)
Run Code Online (Sandbox Code Playgroud)
但是当我对不同的线条使用不同的颜色时,我必须为这个过程制作每种颜色.如果我有100种颜色,那么我需要100层不是很好的解决方案.
我正在尝试将lat/lon对转换为像素坐标.我找到了这个墨卡托投影,但我不明白代码.x_adj,y_adj变量的因素是什么?当我运行没有这些常量的代码时,我的lat/lon对不在我的地图上,x和y像素坐标不是我想要的.
function get_xy(lat, lng)
{
var mapWidth=2058;
var mapHeight=1746;
var factor=.404;
var x_adj=-391;
var y_adj=37;
var x = (mapWidth*(180+lng)/360)%mapWidth+(mapWidth/2);
var latRad = lat*Math.PI/180;
var mercN = Math.log(Math.tan((Math.PI/4)+(latRad/2)));
var y = (mapHeight/2)-(mapWidth*mercN/(2*Math.PI));
return { x: x*factor+x_adj,y: y*factor+y_adj}
}
Run Code Online (Sandbox Code Playgroud)
资料来源:http://webdesignerwall.com/tutorials/interactive-world-javascript-map/comment-page-1? replytocom = 103225
我正在使用Python创建图像
myImage = Image.new('RGB', (250, 250), 'rgb(155,89,182)')
Run Code Online (Sandbox Code Playgroud)
这实际上创造了图像.但有没有办法创建一个图像,背景为我选择的颜色,但有渐变?我想选择蓝色作为我的颜色,然后,我希望边缘呈深蓝色,图像中心呈浅蓝色.这可能使用简单的PIL和Python吗?
先感谢您.
到目前为止,我比其他Flux实现更喜欢Redux,我用它来重写我们的前端应用程序.
我面临的主要困难点:
第一个问题可以通过将状态字段保持在每种类型数据的子状态来解决.例如:
function postsReducer(state, action) {
switch(action.type) {
case "FETCH_POSTS":
return {
...state,
status: "loading",
};
case "LOADED_POSTS":
return {
status: "complete",
posts: action.posts,
};
}
}
function commentsReducer(state, action) {
const { type, postId } = action;
switch(type) {
case "FETCH_COMMENTS_OF_POST":
return {
...state,
status: { ...state.status, [postId]: "loading" },
};
case "LOADED_COMMENTS_OF_POST":
return {
status: { ...state.status, [postId]: "complete" },
posts: { ...state.posts, [postId]: action.posts },
};
}
}
Run Code Online (Sandbox Code Playgroud)
现在我可以为帖子制作一个Saga,为评论制作另一个.每个Sagas都知道如何获取请求的状态.但这很快就会导致很多重复的代码(例如帖子,评论,喜欢,反应,作者等).
我想知道是否有一种避免所有重复代码的好方法.
当我需要通过redux商店的ID获得评论时,第二个问题就出现了.是否有处理数据之间关系的最佳实践?
谢谢!
我问这个是因为我获取的资产的响应标题包含否
内容编码:gzip
我正在研究将文档拆分为段落的方法,并且发现文本平铺是实现此目的的一种可能方法。
这是我使用它的尝试。但是,我不明白如何处理输出。我很感激你的帮助。
t = unidecode(doclist[0].decode('utf-8','ignore'))
nltk.tokenize.texttiling.TextTilingTokenizer(t)
Run Code Online (Sandbox Code Playgroud)
输出:
<nltk.tokenize.texttiling.TextTilingTokenizer at 0x11e9c6350>
Run Code Online (Sandbox Code Playgroud) 在IPython笔记本版本3.0之前,默认情况下可以隐藏笔记本标题,方法是将其添加到".ipython\profile_default\static\custom\custom.js"(在Windows上):
$([IPython.events]).on("app_initialized.NotebookApp", function () {
$('div#header').hide();
$('div#maintoolbar').hide();
});
Run Code Online (Sandbox Code Playgroud)
或者对于Jupyter,"〜/ .jupyter/custom/custom.js",IPython替换为Jupyter.
这似乎不再起作用了.它隐藏了标题,但它也在页面的顶部和底部留下了很大的空白.我不熟悉javascript和css.有没有人找到解决方案呢?
customization ipython ipython-notebook jupyter jupyter-notebook
我正在将一个值存储到类型为 的 postgres 字段中timestamp with time zone。我在 Apollo 模式中将该字段定义为 int,但在解析器中收到此错误消息:
列“apptDateTime”的类型为带时区的时间戳,但表达式的类型为整数
查找GraphQL 数据类型,我还没有看到任何被引用为与时间戳类型字段相对应的类型。
对于数据库中时间戳类型的字段,在 Apollo 模式中使用的正确字段类型是什么?
我是React的新手,我觉得我没有抓住组件生命周期流程,这是我拥有的组件:
import React, {Component, PropTypes} from 'react';
import { connect } from 'react-redux';
import { fetchMyWishlist, fetchSpecificBook } from '../actions/index';
class Cart extends Component {
static contextTypes = {
router:PropTypes.object
};
constructor(props) {
super(props);
this.state = { currentCart:[], currentBook:[], wishlist:[] };
var self = this;
if (this.props.authenticated){
this.props.fetchMyWishlist(this.props.signedInUserInfo._id).then(function(data){
self.setState({ currentCart: data});
});
}
else {
this.context.router.push('/signin');
}
}
componentWillMount(){}
componentDidMount(){
// I get undefined here
console.log("component has been mounted: "+this.state.currentCart.payload);
}
componentDidUpdate(prevProps, prevState){
var jsonObj = this.state.currentCart.payload;
console.log("test: "+JSON.stringify(this.state.currentCart.payload));
var …Run Code Online (Sandbox Code Playgroud) 我将 rowData 和 columnDefs 作为 props 传递。网格正在正确加载。但是,当数据更改时,网格不会重新渲染。它来到父组件的渲染中,并传递给AgGridReact。但是,仍然没有重新渲染。
由于它是一个完整的React应用程序,因此我在https://github.com/jintoppy/ag-grid-upgrade中添加了代码
主要代码如下。
<AgGridReact
// properties
columnDefs={this.state.columnDefs}
rowData={this.props.data}
// events
onGridReady={this.onGridReady}>
</AgGridReact>
Run Code Online (Sandbox Code Playgroud) javascript ×4
python ×3
ag-grid ×1
apollostack ×1
firebase ×1
geometry ×1
graphql ×1
image ×1
ipython ×1
jupyter ×1
nltk ×1
postgresql ×1
projection ×1
reactjs ×1
redux ×1
redux-saga ×1
trigonometry ×1