本文整理汇总了Python中svgwrite.rgb函数的典型用法代码示例。如果您正苦于以下问题:Python rgb函数的具体用法?Python rgb怎么用?Python rgb使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rgb函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: svg_shape
def svg_shape(self):
"""return the SVG shape that this object represents"""
r, g, b = my_colormap[self.label]
x, y, dx, dy = self.get_rect_data()
return svgwrite.shapes.Rect(
insert=(x, y), size=(dx, dy), stroke=svgwrite.rgb(r, g, b, "RGB"), fill=svgwrite.rgb(r, g, b, "RGB")
)
开发者ID:sbargoti,项目名称:pychetlabeller,代码行数:7,代码来源:labeller.py
示例2: run_script
def run_script(args):
matplotlib.interactive(False)
left = (args.left[0], args.left[1])
right = (args.right[0], args.right[1])
l1 = (150,110,110)
l2 = (110,150,110)
l3 = (110,110,150)
layers= [l1,l2]
# This is a hack to conserve colors
colourmap = { rgb(l1[0],l1[1],l1[2]): args.Rock0,
rgb(l2[0],l2[1],l2[2]): args.Rock1 }
if not isinstance(args.Rock2, str):
colourmap[rgb( l3[0],l3[1],l3[2])] = args.Rock2
layers.append( l3 )
model = mb.body( traces = args.ntraces,
pad = args.pad,
margin=args.margin,
left = left,
right = right,
layers = layers
)
return modelr_plot(model, colourmap, args)
开发者ID:agile-geoscience,项目名称:modelr,代码行数:31,代码来源:body_lab.py
示例3: printmatrixmonthly
def printmatrixmonthly(m,d): #matrix, drawing
x_pos = 0
y_pos = 0
yearnum = 0
for y in m: #for every year in the matrix
curmo = 1
weeknum = 0
x_pos = 0
#print(yearnum+startyear)
for w in y: #for every week in the year
#print(weeknum)
if(isnewmonth(yearnum+startyear,weeknum+1,curmo)):
x_pos = 0
curmo += 1
y_pos += shape_size + 2 #new month
#d.add(d.text(curmo, insert=(x_pos, y_pos), fill='red'))
#x_pos += 5
typecount = 0
for t in w: #for every square count in the week
n = 0 #count number of squares
while n < t:
#d.add(d.rect((x_pos, y_pos), (shape_size, shape_size), fill=svgwrite.rgb(worktypes[typecount][1], worktypes[typecount][2], worktypes[typecount][3]))) #print square
d.add(d.circle((x_pos, y_pos), shape_size/2, fill=svgwrite.rgb(worktypes[typecount][1], worktypes[typecount][2], worktypes[typecount][3]))) #print circle
x_pos += shape_size + 1
n += 1
typecount += 1
weeknum += 1
d.add(d.rect((0, y_pos+1), (6, 4), fill=svgwrite.rgb(0,0,0))) #new year marker
y_pos += 6 #new year
yearnum += 1
d.save()
开发者ID:hailmika,项目名称:CV-Generator,代码行数:31,代码来源:portfolume.py
示例4: get_reflectivity
def get_reflectivity(data,
colourmap,
theta=0,
reflectivity_method=reflection.zoeppritz
):
'''
Create reflectivities from an image of an earth model and a
mapping of colours to rock properties. Will find each interface
and use the specified reflectivity method to calculate the Vp
reflection coefficient.
:param data: The image data of the earth model. A 3D array indexed
as [samples, traces, colour].
:param colourmap: A lookup table (dict) that maps colour values to
rock property structures.
:keyword theta: Angle of incidence to use reflectivity. Can be a
float or an array of angles [deg].
:keyword reflectivity_method: The reflectivity algorithm to use.
See bruges.reflection for methods.
:returns: The vp reflectivity coefficients corresponding to the
earth model. Data will be indexed as
[sample, trace, theta]
'''
# Check if we only have one trace of data, and reform the array
if(data.ndim == 2):
reflect_data = np.zeros((data.size, 1, np.size(theta)))
data = np.reshape(data, (data.shape[0], 1, 3))
else:
reflect_data = np.zeros((data.shape[0], data.shape[1],
np.size(theta)))
# Make an array that only has the boundaries in it
boundaries = get_boundaries(data)
for i in boundaries:
# These are the indices in data
j = i.copy()
j[0] += 1
# Get the colourmap dictionary keys
c1 = rgb(data[i[0], i[1], 0], data[i[0], i[1], 1],
data[i[0], i[1], 2])
c2 = rgb(data[j[0], j[1], 0], data[j[0], j[1], 1],
data[j[0], j[1], 2])
# Don't calculate if not in the cmap. If the model was
# build properly this shouldn't happen.
if((c1 not in colourmap) or (c2 not in colourmap)):
continue
# Get the reflectivity
reflect_data[i[0], i[1], :] = rock_reflectivity(
colourmap[c1], colourmap[c2], theta=theta,
method=reflectivity_method)
return reflect_data
开发者ID:agile-geoscience,项目名称:modelr,代码行数:60,代码来源:reflectivity.py
示例5: graphic_output
def graphic_output(self):
cell_size = 100
canvas_width = self.grid_width * cell_size
canvas_height = self.grid_height * cell_size
fname = "graph i=" + str(self.number_of_iterations_yet) + " width=" + str(canvas_width) + " height=" +str(canvas_height) + ".svg"
dwg = svgwrite.Drawing(filename = fname, size = (canvas_width, canvas_height), debug = True)
# Draw horizontal grid lines
#for x in range(0, self.grid_width):
# dwg.add( dwg.line((x*cell_size, 0), (x*cell_size, canvas_height), stroke=svgwrite.rgb(0, 0, 0, "%")) )
#for y in range(0, self.grid_height):
# dwg.add( dwg.line((0, y*cell_size), (canvas_width, y*cell_size), stroke=svgwrite.rgb(0, 0, 0, "%")) )
for row in self.grid:
for square in row:
shapes = dwg.add(dwg.g(id='shapes', fill='red'))
color_numerator = float(square.get_utility()) if type(square.get_utility()) is IntType else 0
color_denominator = 2
fill_color = svgwrite.rgb(255, 255, 255)
if color_numerator > 0:
fill_color = svgwrite.rgb(255-250*(color_numerator/color_denominator), 220, 255-200*(color_denominator/color_denominator))
elif color_numerator < 0:
fill_color = svgwrite.rgb(220, 255-250*(abs(color_numerator)/color_denominator), 255-250*(abs(color_numerator)/color_denominator) )
shapes.add( dwg.rect(insert=(square.x*cell_size, square.y*cell_size), size=(cell_size, cell_size), fill=fill_color) )
paragraph = dwg.add(dwg.g(font_size=16))
paragraph.add(dwg.text(square.get_utility(), ( (square.x + 0.5) * cell_size, (square.y + 0.5) * cell_size)))
dwg.save()
print "grid.graphic_output() successful"
return 0
开发者ID:Kristofir,项目名称:MarkovDecisionProcess,代码行数:35,代码来源:MDP.py
示例6: visualize_graph
def visualize_graph(graph, graph_parameters, output_file = None):
if not graph_parameters.is_correct:
raise Exception() #!!!!!
graph_utilities = GraphUtilities(graph_parameters)
drawing = svgwrite.Drawing()
for node in graph_utilities.nodes(graph):
node_view_points = \
[(node_vertex.real * 1, - node_vertex.imag * 1) for node_vertex \
in graph_utilities.compute_node_vertices(node)]
node_view = \
svgwrite.shapes.Polygon(
node_view_points,
fill = svgwrite.rgb(0, 0, 0),
fill_opacity = 1.0,
stroke = svgwrite.rgb(0, 0, 0),
stroke_width = 0.1,
stroke_opacity = 1.0
)
drawing.add(node_view)
if output_file is not None:
drawing.write(output_file)
else:
return drawing
开发者ID:PushkinTyt,项目名称:GisAndOpenCV,代码行数:30,代码来源:visualization.py
示例7: run_script
def run_script(args):
matplotlib.interactive(False)
"""if args.transparent == 'False' or args.transparent == 'No':
transparent = False
else:
transparent = True"""
args.ntraces = 300
args.pad = 150
args.reflectivity_method = zoeppritz
args.title = "Channel - angle gather (AVA)"
args.theta = (0, 50, 0.5)
args.wavelet = ricker
args.wiggle_skips = 10
args.aspect_ratio = 1
args.thickness = 50
args.margin = 1
args.slice = "angle"
transparent = False
# This is a hack to conserve colors
l1 = (150, 110, 110)
l2 = (110, 150, 110)
l3 = (110, 110, 150)
layers = [l1, l2]
colourmap = {rgb(150, 110, 110): args.Rock0, rgb(110, 150, 110): args.Rock1}
if not isinstance(args.Rock2, str):
colourmap[rgb(110, 110, 150)] = args.Rock2
layers.append(l3)
# Get the physical model (an array of rocks)
model = mb.channel(pad=args.pad, thickness=args.thickness, traces=args.ntraces, layers=layers)
return modelr_plot(model, colourmap, args)
开发者ID:agile-geoscience,项目名称:modelr,代码行数:35,代码来源:channel_angle.py
示例8: writeShape
def writeShape(shape, params):
if isinstance(shape, list):
for i in shape:
writeShape(i, params)
elif isinstance(shape, tuple):
if len(shape) == 2:
x, y = shape
c = 0
elif len(shape) == 3:
x, y, c = shape
else:
raise Exception('Invalid point {}'.format(shape))
x = (x * params['scale']) + (params['size'] / 2)
y = (-y * params['scale']) + (params['size'] / 2)
c = (c - params['colour_min']) / params['colour_range']
if 0 < x < params['size'] and 0 < y < params['size']:
r, g, b = colorsys.hsv_to_rgb(c, 1, 1)
params['svg'].add(params['svg'].circle(center = (x, y), r = 1, stroke = svgwrite.rgb(r * 255, g * 255, b * 255)))
elif isinstance(shape, data.Line):
for (x1, y1), (x2, y2) in zip(shape.points[:-1], shape.points[1:]):
x1 = (x1 * params['scale']) + (params['size'] / 2)
y1 = (-y1 * params['scale']) + (params['size'] / 2)
x2 = (x2 * params['scale']) + (params['size'] / 2)
y2 = (-y2 * params['scale']) + (params['size'] / 2)
if 0 < x1 < params['size'] and 0 < y1 < params['size'] and 0 < x2 < params['size'] and 0 < y2 < params['size']:
params['svg'].add(params['svg'].line((x1, y1), (x2, y2), stroke = svgwrite.rgb(255, 0, 0)))
else:
print('Cannot plot type', type(shape))
开发者ID:DXsmiley,项目名称:Plot,代码行数:28,代码来源:output.py
示例9: getline
def getline(startcoord):
startcoord = startcoord
endcoord = calculateEndCoord(startcoord)
dwg.add(dwg.circle(startcoord, 2.5, stroke=svgwrite.rgb(10, 10, 16, '%'), fill='white'))
for i in range(50):
dwg.add(dwg.line(startcoord, endcoord, stroke=svgwrite.rgb(10, 10, 16, '%')))
startcoord = endcoord
endcoord = calculateEndCoord(startcoord)
dwg.add(dwg.circle(startcoord, 2.5, stroke=svgwrite.rgb(10, 10, 16, '%'),fill='white'))
开发者ID:iamanewbie,项目名称:navigation,代码行数:9,代码来源:writesvg.py
示例10: draw_grid
def draw_grid(self):
for i, n in enumerate(range(self.offset, self.width + 1, self.square_size)):
self._draw_square(i, i, self.nodes[i - 1], fill='gray')
self.dwg.add(self.dwg.line((self.offset, n),
(self.width, n),
stroke_width=self.line_width,
stroke=svgwrite.rgb(10, 10, 16, '%')))
self.dwg.add(self.dwg.line((n, self.offset),
(n, self.height),
stroke_width=self.line_width,
stroke=svgwrite.rgb(10, 10, 16, '%')))
开发者ID:Ignas,项目名称:dsm_maker,代码行数:11,代码来源:svg_drawer.py
示例11: plotfaces
def plotfaces():
for i in range(-N,N):
for j in range(-N,N):
if(i+j+1 <= N and i+j >= -N):
stroke=svgwrite.rgb(10, 10, 16, '%')
dwg.add(dwg.polygon(points=[coords(i+1,j),coords(i,j+1),coords(i,j)],fill='blue'))
for i in range(-N,N):
for j in range(-N,N):
if(i+j+2 <= N and i+j+1 >= -N):
stroke=svgwrite.rgb(10, 10, 16, '%')
dwg.add(dwg.polygon(points=[coords(i+1,j),coords(i,j+1),coords(i+1,j+1)],fill='red'))
开发者ID:philzook58,项目名称:parabola,代码行数:12,代码来源:parabola.py
示例12: zadani3_B_c
def zadani3_B_c():
polomer = 100
krok = 9
dwg = svgwrite.Drawing("results/kulata_mriz.svg")
offset = polomer
for i in range(krok/2, polomer+1, krok):
x = i
y = (polomer**2 - x ** 2) ** 0.5
dwg.add(dwg.line((x + offset, y + offset), (x + offset, -y + offset), stroke=svgwrite.rgb(10, 10, 16, '%')))
dwg.add(dwg.line((-x + offset, y + offset), (-x + offset, -y + offset), stroke=svgwrite.rgb(10, 10, 16, '%')))
dwg.add(dwg.line((-y + offset, x + offset), (y + offset, x + offset), stroke=svgwrite.rgb(10, 10, 16, '%')))
dwg.add(dwg.line((-y + offset, -x + offset), (y + offset, -x + offset), stroke=svgwrite.rgb(10, 10, 16, '%')))
dwg.save()
开发者ID:alacham,项目名称:matematicke_programovani,代码行数:13,代码来源:scraps.py
示例13: channel_svg
def channel_svg(pad, thickness, traces, layers):
"""
Makes a rounded channel.
Give it pad, thickness, traces, and an iterable of layers.
Returns an SVG file.
:param pad: The number (n) of points on top of the channel.
:param: thickness: The radius of the channel (npoints).
:param traces: The number of traces in the channel model.
:param layers: An 3X3 array or tuple of RGB values corresponding
to each rock layer. ((R,G,B),(R,G,B),(R,G,B)).
Indexed as (top, channel, bottom ).
:returns: a tempfile object pointed to the model svg file.
"""
outfile = tempfile.NamedTemporaryFile(suffix='.svg', delete=True )
top_colour = rgb( layers[0][0],layers[0][1], layers[0][2] )
body_colour = rgb( layers[1][0],layers[1][1], layers[1][2] )
bottom_colour = rgb( layers[2][0],layers[2][1], layers[2][2] )
width = traces
height = 2.5*pad + thickness
dwg = svgwrite.Drawing(outfile.name, size=(width,height),
profile='tiny')
# Draw the bottom layer
bottom_layer = \
svgwrite.shapes.Rect(insert=(0,0),
size=(width,height)).fill(bottom_colour)
dwg.add(bottom_layer)
# Draw the body
body = \
svgwrite.shapes.Ellipse(center=(width/2,pad/2),
r=(0.3*width,pad+thickness)).fill(body_colour)
dwg.add(body)
# Draw the top layer
top_layer = \
svgwrite.shapes.Rect(insert=(0,0),
size=(width,pad)).fill(top_colour)
dwg.add(top_layer)
# Do this for a file
dwg.save()
return outfile
开发者ID:agile-geoscience,项目名称:modelr,代码行数:51,代码来源:modelbuilder.py
示例14: recur_triangle
def recur_triangle():
verts = ngram_vertexes(3, 400)
triang = Polygon(verts)
dwg = svgwrite.Drawing('triang.svg')
offset = 0
dwg.add(dwg.circle((verts[0][0] + offset, verts[0][1] + offset), r=1, stroke=svgwrite.rgb(255, 0, 0, '%')))
dwg.add(dwg.circle((verts[1][0] + offset, verts[1][1] + offset), r=1, stroke=svgwrite.rgb(255, 0, 0, '%')))
dwg.add(dwg.circle((verts[2][0] + offset, verts[2][1] + offset), r=1, stroke=svgwrite.rgb(255, 0, 0, '%')))
recurse_transformations(triang, dwg, 7, 100)
dwg.save()
开发者ID:alacham,项目名称:matematicke_programovani,代码行数:14,代码来源:transformace.py
示例15: displaySVGPaths
def displaySVGPaths(pathList,*colors): #creates and saves an svf file displaying the input paths
show_closed_discont=True
import svgwrite
from svgpathtools import Path, Line, CubicBezier
# from time import strftime
# from re import sub
# dwg = svgwrite.Drawing('temporary_displaySVGPaths%s.svg'%time_date, size= ("%spx"%(int(xmax-xmin+1)), "%spx"%(int(ymax-ymin+1))))
# dwg = svgwrite.Drawing('temporary_displaySVGPaths%s.svg'%time_date)
dwg = svgwrite.Drawing('temporary_displaySVGPaths.svg')
dwg.add(dwg.rect(insert=(0, 0), size=('100%', '100%'), rx=None, ry=None, fill='white')) #add white background
dc = 100/len(pathList)
for i,p in enumerate(pathList):
if isinstance(p,Path):
startpt = p[0].start
ps = path2str(p)
elif isinstance(p,Line) or isinstance(p,CubicBezier):
startpt = p.start
ps = path2str(p)
else:
startpt = parse_path(p)[0].start
ps = p
if colors !=tuple():
dwg.add(dwg.path(ps, stroke=colors[0][i], fill='none'))
else:
dwg.add(dwg.path(ps, stroke=svgwrite.rgb(0+dc, 0+dc, 16, '%'), fill='none'))
if show_closed_discont and isApproxClosedPath(p):
startpt = (startpt.real,startpt.imag)
dwg.add(dwg.circle(startpt,1, stroke='gray', fill='gray'))
dwg.save()
开发者ID:mathandy,项目名称:svgtree,代码行数:29,代码来源:misc4rings.py
示例16: use
def use(name):
# Shows how to use the 'use' element.
#
w, h = '100%', '100%'
dwg = svgwrite.Drawing(filename=name, size=(w, h), debug=True)
dwg.add(dwg.rect(insert=(0,0), size=(w, h), fill='lightgray', stroke='black'))
# add a group of graphic elements to the defs section of the main drawing
g = dwg.defs.add(dwg.g(id='g001'))
unit=40
g.add(dwg.rect((0,0), (unit, unit)))
for y in range(10):
for x in range(5):
x1 = 2*unit+2*unit*x
y1 = 2*unit+2*unit*y
cx = x1 + unit/2
cy = y1 + unit/2
cval = (y*5 + x)*2
# reference the group by the 'use' element, you can overwrite
# graphical properties, ...
u = dwg.use(g, insert=(x1, y1), fill=rgb(cval, cval, cval))
# ... and you can also transform the the whole reference object.
u.rotate(y*5+x, center=(cx, cy))
dwg.add(u)
dwg.save()
开发者ID:MindPass,项目名称:Code,代码行数:27,代码来源:use.py
示例17: mandala
def mandala(filename='poirot.svg'):
'''
Draw a mandala, inspired by Danna's.
'''
d = svgwrite.Drawing(filename)
d.add(d.line((0, 0), (10, 0), stroke=svgwrite.rgb(10, 10, 16, '%')))
d.save()
开发者ID:fritzo,项目名称:art,代码行数:7,代码来源:poirot.py
示例18: convert
def convert(input,output,width,height,scale):
d = xml.etree.ElementTree.parse(input)
r = d.getroot()
scale = int(scale)
width = int(width)
height = int(height)
canvas = svg.Drawing(output, size=(str(width*scale), str(height*scale)))
canvas.add(canvas.rect(insert=(0, 0), size=('100%', '100%'), rx=None, ry=None, fill='rgb(0,0,0)'))
for poly in r.find('Polygons'):
red = int(poly.find('Brush').find('Red').text)
blue = int(poly.find('Brush').find('Blue').text)
green = int(poly.find('Brush').find('Green').text)
alpha = float(poly.find('Brush').find('Alpha').text)
alpha = alpha/255
color = svg.rgb(red,green,blue)
pts = []
for point in poly.find('Points'):
x = int(point.find('X').text)*scale
y = int(point.find('Y').text)*scale
pts.append((x,y))
canvas.add(svg.shapes.Polygon(points=pts, fill=color, opacity=alpha))
canvas.save()
开发者ID:dannyperson,项目名称:evolisa-tools,代码行数:25,代码来源:xml2svg.py
示例19: renderSegments
def renderSegments(svg, segments, offset, scale):
for segment in segments:
svg.add(svg.line( mult(add(segment[0], offset), scale),
mult(add(segment[1], offset), scale),
stroke=svgwrite.rgb(0, 0, 0, '%'),
stroke_width=2,
stroke_linecap="square"))
开发者ID:hunminkoh,项目名称:6807-Project,代码行数:7,代码来源:make_cuts.py
示例20: print_path
def print_path(path):
print(path)
wall=50
for l in range(1, len(path)+1):
dwg = svgwrite.Drawing('color_maze_solution' + str(l)+ '.svg', profile='full')
dwg.add(dwg.line((0, 0), (0, size_X * wall), stroke=svgwrite.rgb(0, 0, 0, '%')))
dwg.add(dwg.line((0, 0), (size_X * wall, 0), stroke=svgwrite.rgb(0, 0, 0, '%')))
dwg.add(dwg.line((size_X * wall, size_X * wall), (size_X * wall, 0), stroke=svgwrite.rgb(0, 0, 0, '%')))
dwg.add(dwg.line((size_X * wall, size_X * wall), (0, size_X * wall), stroke=svgwrite.rgb(0, 0, 0, '%')))
for x in range(l):
i=path[x][0]
j=path[x][1]
dwg.add(dwg.rect((j * 50, i * 50), (50, 50), fill=dict[maze[i][j]]))
dwg.add(dwg.text("start",(10,(size_X-1)*50+25)))
dwg.save()
开发者ID:vojtadavid,项目名称:IV122,代码行数:16,代码来源:colormaze.py
注:本文中的svgwrite.rgb函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论