processing python模式添加图片_processing学习整理---Image
1、Load and Display(加载与显示)
Images can be loaded and displayed to the screen at their actual size or any other size.
图像可以按照其实际尺寸或任何其他尺寸加载并显示到屏幕。
PImage img; //Declare variable "a" of type PImage
voidsetup() {
size(640, 360);//The image file must be in the data folder of the current sketch//图片文件必须在当前草稿文件的同一文件夹才能加载成功。//to load successfully
img = loadImage("moonwalk.jpg"); //Load the image into the program
}voiddraw() {//Displays the image at its actual size at point (0,0)
image(img, 0, 0);//Displays the image at point (0, height/2) at half of its size
image(img, 0, height/2, img.width/2, img.height/2);
}
View Code
2、Background Image. (背景图片)
This example presents the fastest way to load a background image into Processing. To load an image as the background, it must be the same width and height as the program.
此示例介绍将加载背景图像的最快方法转换到Processing。 要加载图像作为背景,它必须与程序的宽度和高度相同。
PImage bg;inty;voidsetup() {
size(640, 360);//The background image must be the same size as the parameters//into the size() method. In this program, the size of the image//is 640 x 360 pixels.
bg = loadImage("moonwalk.jpg");
}voiddraw() {
background(bg);
stroke(226, 204, 0);
line(0, y, width, y);
y++;if (y >height) {
y= 0;
}
}
View Code
3、透明度。
向左移动,指针对面的形象改变立场。本方案通过用色调()函数修改图像的α值覆盖在另一个图象。
PImage img;float offset = 0;float easing = 0.05;voidsetup() {
size(640, 360);
img= loadImage("moonwalk.jpg"); //Load an image into the program
}voiddraw() {
image(img,0, 0); //Display at full opacity
float dx = (mouseX-img.width/2) -offset;
offset+= dx *easing;
tint(255, 127); //Display at half opacity
image(img, offset, 0);
}
View Code
4、遮罩
为图像加载“遮罩”以指定图像不同部分的透明度。 使用Image的mask()方法将两个图像混合在一起。
PImage img;
PImage imgMask;voidsetup() {
size(640, 360);
img= loadImage("moonwalk.jpg");
imgMask= loadImage("mask.jpg");
img.mask(imgMask);
imageMode(CENTER);
}voiddraw() {
background(0, 102, 153);
image(img, width/2, height/2);
image(img, mouseX, mouseY);
}
View Code
5、创建图像。
createImage()函数提供了一个新的像素的缓冲区。 此示例创建图像渐变。
PImage img;voidsetup() {
size(640, 360);
img= createImage(230, 230, ARGB);for(int i = 0; i < img.pixels.length; i++) {float a = map(i, 0, img.pixels.length, 255, 0);
img.pixels[i]= color(0, 153, 204, a);
}
}voiddraw() {
background(0);
image(img,90, 80);
image(img, mouseX-img.width/2, mouseY-img.height/2);
}
View Code
6、点画
鼠标水平位置控制点的大小。 使用根据图像中的像素着色的椭圆创建简单的点画效果。
PImage img;intsmallPoint, largePoint;voidsetup() {
size(640, 360);
img= loadImage("moonwalk.jpg");
smallPoint= 4;
largePoint= 40;
imageMode(CENTER);
noStroke();
background(255);
}voiddraw() {float pointillize = map(mouseX, 0, width, smallPoint, largePoint);int x = int(random(img.width));int y = int(random(img.height));
color pix=img.get(x, y);
fill(pix,128);
ellipse(x, y, pointillize, pointillize);
}
View Code
7、请求图像由Ira Greenberg(从为Flash开发人员处理)。
展示如何使用requestImage()函数与preloader动画。 requestImage()函数在单独的线程上加载图像,以使草图在加载时不会冻结。 当你加载大图片时,它非常有用。这些图像是小的快速下载,但尝试应该大的图像,以获得完整的效果。
int imgCount = 12;
PImage[] imgs= newPImage[imgCount];floatimgW;//Keeps track of loaded images (true or false)
boolean[] loadStates = new boolean[imgCount];//For loading animation
floatloaderX, loaderY, theta;voidsetup() {
size(640, 360);
imgW= width/imgCount;//Load images asynchronously
for (int i = 0; i < imgCount; i++){
imgs[i]= requestImage("PT_anim"+nf(i, 4)+".gif");
}
}voiddraw(){
background(0);//Start loading animation
runLoaderAni();for (int i = 0; i < imgs.length; i++){//Check if individual images are fully loaded
if ((imgs[i].width != 0) && (imgs[i].width != -1)){//As images are loaded set true in boolean array
loadStates[i] = true;
}
}//When all images are loaded draw them to the screen
if(checkLoadStates()){
drawImages();
}
}voiddrawImages() {int y = (height - imgs[0].height) / 2;for (int i = 0; i < imgs.length; i++){
image(imgs[i], width/imgs.length*i, y, imgs[i].height, imgs[i].height);
}
}//Loading animation
voidrunLoaderAni(){//Only run when images are loading
if (!checkLoadStates()){
ellipse(loaderX, loaderY,10, 10);
loaderX+= 2;
loaderY= height/2 + sin(theta) * (height/8);
theta+= PI/22;//Reposition ellipse if it goes off the screen
if (loaderX > width + 5){
loaderX= -5;
}
}
}//Return true when all images are loaded - no false values left in array
booleancheckLoadStates(){for (int i = 0; i < imgs.length; i++){if (loadStates[i] == false){return false;
}
}return true;
}
View Code
processing python模式添加图片_processing学习整理---Image相关推荐
- processing python模式_python学习Processing
标签: # -*- coding: utf-8 -*- __author__ = 'Administrator' import bisect #排序说明:http://en.wikipedia.org ...
- processing python模式下载_爱上processing PDF 高清版
给大家带来的一篇关于processing相关的电子书资源,介绍了关于processing方面的内容,本书是由人民邮电出版社出版,格式为PDF,资源大小51.9 MB,Casey Reas编写,目前豆瓣 ...
- python用户界面导入图片_python学习笔记之11:图像用户界面
这里会介绍如何创建python程序的图像用户界面(GUI),也就是那些带有按钮和文本框的窗口等.目前支持python的所谓"GUI工具包"的有很多,本文简要介绍最成熟的跨平台pyt ...
- processing python模式_详解python之多进程和进程池(Processing库)
环境:win7+python2.7 一直想学习多进程或多线程,但之前只是单纯看一点基础知识还有简单的介绍,无法理解怎么去应用,直到前段时间看了github的一个爬虫项目涉及到多进程,多线程相关内容,一 ...
- Python批量添加图片水印
一.前言 现在盗图是非常常见的事情,许多人在使用图片时都不会标注图片的出处或者提及作者,这个时候水印就是个很好的东西了.我们可以给图片添加水印后再分享出去,这样就可以让其它人知道图片作者相关的信息.今 ...
- python怎么加图片_python怎么实现添加图片
python怎么实现添加图片,文件,图片,方法,资源,前缀 python怎么实现添加图片 易采站长站,站长之家为您整理了python怎么实现添加图片的相关内容. 一.导入图片资源 方法1:直接从源图片 ...
- Python图片相册批处理器的设计与实现批量添加图片水印、批量命名等功能
课题研究使用Python语言开发一个包含批量添加图片水印.批量命名等功能的图片批处理程序,功能模块大概包含以下模块: (1)首页模块:首页是整个软件的初始页面,包含用户登录.注册.关于本软件等功能,用 ...
- python代码图片-python实现图片上添加图片
在介绍完给图上添加文字后,我们再介绍给图片上添加图片,也就是图片的叠加. 需要使用的Python的图像库:PIL.更加详细的知识点如下: Imaga模块:用来创建,打开,保存图片文件 new(path ...
- 2019.7.29学习整理python
2019.7.29学习整理python 1.变量 1.1什么是变量? 是变化的量.描述变化的世间万物的状态 1.2变量的组成 变量名:变量名用来引用变量值,但凡需要用变量值,都需要通过变量名. 赋值符 ...
最新文章
- Linux环境变量说明与配置
- springboot特点
- atitit. groupby linq的实现(1)-----linq框架选型 java .net php
- cocos2d-x坐标系
- Dojo 之 面向对象
- 问题记录——sqlserver视图重命名的陷阱
- 软件工程导论 09章面向对象方法学
- mysql case默认_MySQL数据库架构和同步复制流程
- 这8款Android桌面插件,这款 Android 应用,帮你优雅地管理桌面小部件
- c语言中指数常量注意什么意思,C语言入门知识:常量
- 动态规划之《高楼扔鸡蛋》问题详解 LeetCode 887.鸡蛋掉落
- Android butterknife黄油刀使用大全
- 数据库中锁机制的学习
- java 地图模式_MapL 实现了百度地图定位以及感应方向和各种模式切换的 Demo Java Develop 238万源代码下载- www.pudn.com...
- 声纳---水下机器人前视声呐多目标跟踪技术研究--16年,哈工程,马珊,博士毕业论文
- canvas画小黄人
- 最经典的黑客技术入门知识大全
- HTML5定稿了,终于有一种编程语言开发的程序可以在Android和IOS两种设备上运行了
- 批量发运确认API wsh_deliveries_pub.delivery_action
- 字符串的复制,将一串字符串复制到另一串字符串中 c语言简单易懂
热门文章
- div中插入图片_Web前端开发基础知识,设置网页背景图,如何在网页中插入图片...
- 启明云端分享|SSD202D核心板使用NFS
- 计算机网络访问控制列表,南昌大学计算机网络实验-访问控制列表ACL
- 诸神战纪2java_诸神战纪2死神归来
- php cros跨域处理,php_CORS 跨域
- centos redis验证_centos7下安装redis-4.0.2
- redis使用sysc超时_基于redis的分布式锁实现
- ReactNative ES6简介 及基本语法第一篇
- $.extend 的相关用法
- 一次高烧期间的感悟……