GoPiGo 小汽車︰格點圖像算術《彩色世界》【顏色ABC】二

Mark Kness 先生寫作『顏色派』

ColorPy

Physical color calculations in Python.

More documentation is currently at http://markkness.net/colorpy/ColorPy.html.


A taste of the plots that ColorPy can create: RGB values for the pure spectral lines.

Version 0.1.1. Changes from 0.1.0: Various things I did on my local machine. A better shark fin plot, for example. Now on GitHub!

Version 0.1.0. I had this hosted at http://markkness.net (and still do) but GitHub is a better place for it now.

 

這時仍喜派生二 Python2 。簡單準備環境後︰

sudo pip install scipy
sudo pip3 install scipy

sudo pip install numpy
sudo pip3 install numpy

sudo apt-get install python-matplotlib python3-matplotlib
sudo apt-get install python-zmq python3-zmq

sudo apt-get install ipython ipython3

 

sudo pip install colorpy 可安裝也。不過作者偏好派生三 Python3 ,嚐試閱讀程式碼,欣聞新版開始支援派生三

git clone https://github.com/markkness/ColorPy.git

 

依理驗證派生二與三︰

Download ColorPy

Binary distribution for Windows (32-bit):    ColorPy-0.1.0.win32.exe

Source distribution for Windows:    ColorPy-0.1.0 zip

Source distribution for Linux:    ColorPy-0.1.0 tarball

Installation:

If you are installing from the Windows binary distribution, all you need to do is double-click the executable, and follow the installation prompts.  Otherwise, you must first unpack the distribution, and then install.

Unpacking the source distributions:

Windows –
Unzip the .zip distribution. Recent versions of Windows (XP or later), will unpack the directory automatically, you can simply enter the directory in Windows Explorer. You will probably need to copy the uncompressed files into another directory.

Linux –
The distribution is a compressed tar archive, uncompress it as follows:

gunzip -c colorpy-0.1.0.tar.gz | tar xf -
cd colorpy-0.1.0

Installing from the source distribution:

From the directory in which the files are unpacked, run:

python setup.py install

It is possible that you may need to supply a path to the Python executable.  You will probably need administrator privileges to do this.  This should complete the installation.

After downloading and installing, I recommend that you run the test cases, and then create the sample figures.  These will provide a check that the module is working correctly.

import colorpy.test
colorpy.test.test()

This will run all the test cases.

import colorpy.figures
colorpy.figures.figures()

This will generate the sample figures (typically .png files), including all those in this documentation, as well as several others.

 

無奈二、三『套件庫』結構不同調,還是二行、三不行?欲改一時不知下手處!左瞧右看夢昧求,忽爾靈感來?莫睡且試誤︰

pi@raspberrypi:~ more /usr/local/lib/python3.4/dist-packages/colorpy/__init__.py  ''' __init__.py  ColorPy is a Python package to convert physical descriptions of light:     spectra of light intensity vs. wavelength - into RGB colors that can     be drawn on a computer screen.     It provides a nice set of attractive plots that you can make of such     spectra, and some other color related functions as well.  License:  Copyright (C) 2008 Mark Kness  Author - Mark Kness - mkness@alumni.utexas.net  This file is part of ColorPy.  ColorPy is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.  ColorPy is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.  You should have received a copy of the GNU Lesser General Public License along with ColorPy.  If not, see <http://www.gnu.org/licenses/>. '''  # This file only needs to exist to indicate that this is a package.  # 添加兩行。 import sys sys.path.append('/usr/local/lib/python3.4/dist-packages/colorpy/') pi@raspberrypi:~ 

 

曙光突現前!

pi@raspberrypi:~ $ ipython3 --pylab
Python 3.4.2 (default, Oct 19 2014, 13:31:11) 
Type "copyright", "credits" or "license" for more information.

IPython 2.3.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.
Using matplotlib backend: TkAgg

In [1]: import colorpy.plots

In [2]: colorpy.plots.visible_spectrum_plot ()
Saving plot VisibleSpectrum

In [3]: colorpy.plots.cie_matching_functions_plot()
Saving plot CIEXYZ_Matching

In [4]: 鯊魚翅 = colorpy.plots.shark_fin_plot ()
Saving plot ChromaticityDiagram

In [5]:

 

 

 

 

恍惚神明助☆