graphics

[翻译]PyCairo指南--形状和填充

ⅰ亾dé卋堺 提交于 2020-05-08 03:53:36
PyCairo中的形状和填充 PyCairo指南的这个部分,我们将创建一些基本的和更高级的形状。我们将使用单一颜色,patterns和渐变来填充他们。渐变将在另一章中讨论。 基本形状 PyCairo有一些基本的方法可以用来画简单的形状。 def on_draw(self, wid, cr): cr.set_source_rgb(0.6, 0.6, 0.6) cr.rectangle(20, 20, 120, 80) cr.rectangle(180, 20, 80, 80) cr.fill() cr.arc(330, 60, 40, 0, 2 * math.pi) cr.fill() cr.arc(90, 160, 40,math.pi/4, math.pi) cr.fill() cr.translate(220, 180) cr.scale(1, 0.7) cr.arc(0, 0, 50, 0, 2 * math.pi) cr.fill() 在这个例子中,我们将创建一个矩形,一个方形,一个圆形,一个弧形,和一个椭圆形。 cr.rectangle(20, 20, 120, 80) cr.rectangle(180, 20, 80, 80) rectangle()方法用于创建方形和矩形。一个方形就仅仅是一个特殊的矩形。 cr.arc(330, 60, 40, 0, 2 * math

[翻译]PyCairo指南--图片

 ̄綄美尐妖づ 提交于 2020-05-08 03:53:18
PyCairo中的图片 PyCairo指南的这个部分,我们将讨论图片。我们将演示如何在GTK窗口中显示一幅PNG或JPEG图片。我们也将在图片上画一些文字。 显示一幅PNG图片 第一个例子中,我们将显示一幅PNG图片。 #!/usr/bin/python ''' ZetCode PyCairo tutorial This program shows how to draw an image on a GTK window in PyCairo. author: Jan Bodnar website: zetcode.com last edited: August 2012 ''' import gtk import cairo class MainWindow(gtk.Window): def __init__(self): super(self.__class__, self).__init__() self.init_ui() self.load_image() def init_ui(self): self.darea = gtk.DrawingArea() self.darea.connect("expose_event", self.expose) self.add(self.darea) self.set_title("Image") self.resize(300,

[翻译]PyCairo指南--渐变

喜你入骨 提交于 2020-05-08 03:52:58
PyCairo渐变 PyCairo指南的这个部分,我们将讨论渐变。我们将提到线性的和径向的渐变。 在计算机图形学中,渐变是深浅的平滑的调配,由亮到暗,或者由一种颜色到另一种颜色。在2D制图程序和绘画程序中,渐变被用于创建五彩缤纷的背景和特殊的效果,也用于模拟灯光和阴影。 线性渐变 线性渐变是颜色的调配(两种不同的颜色)或颜色的深浅(一种颜色,R,G,B各色彩成分占比相同,但亮度不一样)变化都沿着一条直线。在PyCairo中,它们由一个 cairo.LinearGradient 来表示。 #!/usr/bin/python ''' ZetCode PyCairo tutorial This program works with linear gradients in PyCairo author: Jan Bodnar website: zetcode.com last edited: August 2012 ''' import cairo import gtk class MainWindow(gtk.Window): def __init__(self): super(self.__class__, self).__init__() self.init_ui() def init_ui(self): darea = gtk.DrawingArea() darea.connect

[翻译]PyCairo指南--透明度

一个人想着一个人 提交于 2020-05-08 03:33:25
透明度 在这份PyCairo指南的这个部分,我们将讨论透明度。我们将提供一些基本的定义和三个有趣的透明度的例子。 透明度是指透过一种材料能够看到事物的品质。理解透明度最简单的方法就是想象一块玻璃或这水。技术上来说,光线可以穿透玻璃,从而我们可以看到玻璃后面的物体。 在计算机图形学中,我们可以用alpha通道来实现透明度效果。 Alpha通道 就是一个组合一幅图片和一个背景来创建部分透明的外观的过程。组合过程使用一个 alpha通道 。在图像文件格式中,alpha通道是一个8-bit的layer,它被用于表达半透明(透明度)。每像素额外的8 bits被用作一个mask和代表256级的半透明度。 透明的矩形 在第一个例子中,我们将绘制10个具有不同的半透明度的矩形。 def on_draw(self, wdith, cr): for i in range(1, 11): cr.set_source_rgba(0, 0, 1, i * 0.1) cr.rectangle(50 * i, 20, 40, 40) cr.fill() set_source_rgba() 方法有一个alpha参数来提供透明度。 for i in range(1, 11): cr.set_source_rgba(0, 0, 1, i * 0.1) cr.rectangle(50 * i, 20, 40, 40)

Error due to #include<graphics.h>

筅森魡賤 提交于 2020-05-06 16:51:47
问题 I am trying to compile a program which includes the graphics.h header file for C. I have added the graphics.h and winbgim.h header files in the include folder and also libbgi.a to lib folder. Just for testing, I made a simple hello world program and included the graphics.h header file. But on compiling I got the following error: In file included from firstc.c:2:0: c:\mingw\bin../lib/gcc/mingw32/4.7.1/../../../../include/graphics.h:30:59: fatal error: sstream: No such file or directory

Taking cube from camera space to clip space, error in my math?

五迷三道 提交于 2020-04-30 05:42:49
问题 watching Ken Joy's Computer Graphics lectures on youtube. One thing I'm confused about is after he gets the cube from the camera space to clip space, from my calculations the cube doesn't look like that. I expected the cube to look like that pink parallelogram in my picture, if we assume the Z of the front-face of the cube to be -4/3 and the back-face to be -2 then the Ws come out to be 4/3 and 2 respectively. So can someone explain how after multiplying by the viewing matrix, the cube comes

Python cv2 & numpy - combining two images

烈酒焚心 提交于 2020-04-30 04:32:07
问题 I have an image of a boat and I need to fulfill with colour individual zones according to the value of the sensor. Up to this moment I have created two separated zones in .png format and I want to show them at the same time, putting them on a basic boat image. My code: import cv2 import numpy as np from PIL import Image import time bg = cv2.imread("boat.png") #RGB = np.zeros((2178, 2904, 3), dtype=np.uint8) #zone11 zone11 = cv2.imread(r'C:\Users\Lenovo\Anaconda3\Programy\Obszary\11.png')

How to Render Cross Section without Slicing the Mesh Geometry?

 ̄綄美尐妖づ 提交于 2020-04-21 09:22:12
问题 Given a slice plane in the world, I want triangles to be seen if they were on the positive side of the plane, and those who intersect with the plane are split and the part on positive plane can be seen too. If I slice the triangles meshes every time when plane is changed, it may be very slow when there are tons of triangles, and texture coordinate will be re-generated too. If I set the camera(view) and projection carefully, it may generate similar result, but this result is view dependent. So

How do I implement two translations and a scale operation in GLSL?

人盡茶涼 提交于 2020-04-17 22:41:06
问题 I am trying to implement the following transformation. My original world-space coordinates are (2D) x=1586266800 and y=11812 I want: the bottom left corner of the OpenGL image to represent coordinates (1586266800, 11800) the top right corner of the OpenGL image to represent coordinates (1586267400, 11900) In order to do that I plan to join three transformation matrices: Translate to the origin of coordinates x=1586266800 and y=11800 Scale to have a width of 600 and a height of 100 Translate

How do I implement two translations and a scale operation in GLSL?

…衆ロ難τιáo~ 提交于 2020-04-17 22:39:30
问题 I am trying to implement the following transformation. My original world-space coordinates are (2D) x=1586266800 and y=11812 I want: the bottom left corner of the OpenGL image to represent coordinates (1586266800, 11800) the top right corner of the OpenGL image to represent coordinates (1586267400, 11900) In order to do that I plan to join three transformation matrices: Translate to the origin of coordinates x=1586266800 and y=11800 Scale to have a width of 600 and a height of 100 Translate