首先,推荐使用 -i https://pypi.tuna.tsinghua.edu.cn/simple
对于Python开发用户来讲,PIP安装软件包是家常便饭。但国外的源下载速度实在太慢,浪费时间。而且经常出现下载后安装出错问题。所以把PIP安装源替换成国内镜像,可以大幅提升下载速度,还可以提高安装成功率。
国内源:
新版ubuntu要求使用https源,要注意。
清华:https://pypi.tuna.tsinghua.edu.cn/simple
阿里云:http://mirrors.aliyun.com/pypi/simple/
中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/
华中理工大学:http://pypi.hustunique.com/
山东理工大学:http://pypi.sdutlinux.org/
豆瓣:http://pypi.douban.com/simple/
临时使用:
可以在使用pip的时候加参数-i https://pypi.tuna.tsinghua.edu.cn/simple
例如:pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pyspider,这样就会从清华这边的镜像去安装pyspider库。
永久修改,一劳永逸:
Linux下,修改 ~/.pip/pip.conf (没有就创建一个文件夹及文件。文件夹要加“.”,表示是隐藏文件夹)
内容如下:
-
[global]
-
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
-
[install]
-
trusted-host=mirrors.aliyun.com
windows下,直接在user目录中创建一个pip目录,如:C:\Users\xx\pip,新建文件pip.ini。内容同上。
public Image RotateImg(Image b, int angle)
{
//原图的宽和高
int w = b.Width;
int h = b.Height;
int squartWidth = Math.Max(w, h) * 3;//目标图边长
int radius = (squartWidth - 1) / 2;//圆半径
//目标位图
Bitmap dsImage = new Bitmap(squartWidth, squartWidth);
System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(dsImage);
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.Bilinear;
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
Pen pen = new Pen(Color.Black,1) ;
g.DrawEllipse(pen, 0, 0, squartWidth - 1, squartWidth - 1);//画个圆圈用于确认功能是否正确
angle = angle % 360;
g.TranslateTransform(radius, radius);
g.RotateTransform(360 - angle);
g.TranslateTransform(-radius, -radius);
g.DrawImage(b, radius - w / 2, radius - h * 2);//平面几何这个算不来了,所以直接写死了
////重至绘图的所有变换
g.ResetTransform();
g.Save();
g.Dispose();
////保存旋转后的图片
b.Dispose();
return dsImage;
}
int number = 0;
private void timer1_Tick(object sender, EventArgs e)
{
var img = this.RotateImg(Resources._1, 10 * (number++));
this.pictureBox1.Image = img;
}

首先需要引入IronPython,可以通过NuGet搜索获得,基于4.5以上框架集
using System;
using IronPython.Hosting;
using Microsoft.Scripting.Hosting;
public partial class python : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
RunPythonShell();
}
/// <summary>
/// 调用Python
/// </summary>
private void RunPythonShell()
{
ScriptRuntime pyRuntime = Python.CreateRuntime();
//python文件绝对路径
string path = string.Format(@"{0}1.py", Server.MapPath("./"));
dynamic py = pyRuntime.UseFile(path);
//调用Python 的函数run()
Response.Write(py.show());
}
}
// 不规则形状通过碰撞边缘检测是否在有效区域内
let target = this.node;
let pos = target.convertToNodeSpaceAR(e.getLocation())
var polygonCollider = target.getComponent(cc.PolygonCollider);
//pos.x -= target.getContentSize().width / 2; // 原始示例中由减去宽度和高度的设定,实测不需要
//pos.y -= target.getContentSize().height / 2;
if (!cc.Intersection.pointInPolygon(pos, polygonCollider.points)) {
return;
}
以上是多边形按钮
var Global = require("Global");
cc.Class({
extends: cc.Component,
properties: {
touched: false,
},
// LIFE-CYCLE CALLBACKS:
onLoad() {
this.node.on(cc.Node.EventType.TOUCH_START, this.touchStart.bind(this));
this.node.on(cc.Node.EventType.TOUCH_END, this.touchEnd.bind(this));
this.node.on(cc.Node.EventType.TOUCH_MOVE, this.touchMove.bind(this));
this.node.on(cc.Node.EventType.TOUCH_CANCEL, this.touchEnd.bind(this));
},
onDestory() {
},
touchStart(e) {
// 不规则形状通过碰撞边缘检测是否在有效区域内
let target = this.node;
let pos = target.convertToNodeSpaceAR(e.getLocation())
var polygonCollider = target.getComponent(cc.PolygonCollider);
//pos.x -= target.getContentSize().width / 2; // 原始示例中由减去宽度和高度的设定,实测不需要
//pos.y -= target.getContentSize().height / 2;
if (!cc.Intersection.pointInPolygon(pos, polygonCollider.points)) {
return;
}
this.touched = true;
// 切换选中状态
if (Global.selectedBoard != undefined && this.node != Global.selectedBoard) {
Global.selectedBoard.opacity = 255;
}
Global.selectedBoard = this.node;
this.node.opacity = 180; // 选中状态半透明
this.node.zIndex = 1; // 最前
},
touchMove(e) {
if (this.touched) {
// 开始移动
let delta = e.getDelta();
this.node.x += delta.x;
this.node.y += delta.y;
}
},
touchEnd(e) {
this.touched = false;
this.node.zIndex = 0;
},
});
以上是不规则图形按住拖动