我有一个用 numpy 绘制径向渐变的代码。到目前为止它看起来像这样:
import numpy as np
import matplotlib.pyplot as plt
arr = np.zeros((256,256,3), dtype=np.uint8)
imgsize = arr.shape[:2]
innerColor = (0, 0, 0)
outerColor = (255, 255, 255)
for y in range(imgsize[1]):
for x in range(imgsize[0]):
#Find the distance to the center
distanceToCenter = np.sqrt((x - imgsize[0]//2) ** 2 + (y - imgsize[1]//2) ** 2)
#Make it on a scale from 0 to 1innerColor
distanceToCenter = distanceToCenter / (np.sqrt(2) * imgsize[0]/2)
#Calculate r, g, and b values
r = outerColor[0] …Run Code Online (Sandbox Code Playgroud) 我刚刚使用https://github.com/bunkahle/Transcrypt-Examples/blob/master/alerts/alerts2.py 中的简单程序在 Python 3.7 Win7 上尝试了最新的 transcrypt,但出现编译错误:
C:\Python37\Programme\Transcrypt>transcrypt alerts2.py
Transcrypt (TM) Python to JavaScript Small Sane Subset Transpiler Version 3.7.16
Copyright (C) Geatec Engineering. License: Apache 2.0
Saving target code in: C:/Python37/Programme/Transcrypt/__target__/org.transcrypt.__runtime__.js
Saving minified target code in: C:/Python37/Programme/Transcrypt/__target__/org.transcrypt.__runtime__.js
Error while compiling (offending file last):
File 'org.transcrypt.__runtime__', line 0, namely:
[WinError 2] The system cannot find the specified file
Aborted
Run Code Online (Sandbox Code Playgroud)
知道出了什么问题吗?我只是得到一个名为的目录__target__
,其中包含一个被调用的文件,org.transcrypt.__runtime__.pretty.js但没有任何 alerts2.js。顺便说一句,您为什么__javascript__将编译目录的名称从 transcrypt 3.6 更改为__target__in transcrypt 3.7?