mirror of
https://github.com/cortesi/scurve.git
synced 2025-06-18 16:55:33 -04:00
Add option to specify background colour to drawcurve.
This commit is contained in:
parent
552b91da30
commit
0e238f76a2
6
cube
6
cube
@ -26,9 +26,11 @@ camera {
|
|||||||
location <50, 50, -200>
|
location <50, 50, -200>
|
||||||
look_at <0, 0, 0>
|
look_at <0, 0, 0>
|
||||||
rotate z*270
|
rotate z*270
|
||||||
|
rotate x*25
|
||||||
|
rotate y*10
|
||||||
}
|
}
|
||||||
|
|
||||||
background { color red 1 green 1 blue 1 }
|
background { color red 0 green 0 blue 0 }
|
||||||
|
|
||||||
light_source {
|
light_source {
|
||||||
<50, 30, -200> color red 1 green 1 blue 1
|
<50, 30, -200> color red 1 green 1 blue 1
|
||||||
@ -50,7 +52,7 @@ blob {
|
|||||||
sphere {
|
sphere {
|
||||||
<@!lines[0][0][0]!@, @!lines[0][0][1]!@, @!lines[0][0][2]!@>,
|
<@!lines[0][0][0]!@, @!lines[0][0][1]!@, @!lines[0][0][2]!@>,
|
||||||
6, 1
|
6, 1
|
||||||
pigment { color red 0 green 1 blue 0 }
|
pigment { color red 0.5 green 0.5 blue 1 }
|
||||||
}
|
}
|
||||||
pigment { color red 0.5 green 0.5 blue 1 }
|
pigment { color red 0.5 green 0.5 blue 1 }
|
||||||
finish { ambient 0.2 diffuse 0.8 phong 1 }
|
finish { ambient 0.2 diffuse 0.8 phong 1 }
|
||||||
|
12
drawcurve
12
drawcurve
@ -10,6 +10,9 @@ def main():
|
|||||||
version="%prog 0.1",
|
version="%prog 0.1",
|
||||||
)
|
)
|
||||||
parser.add_option("-c", "--color", action="store", dest="color", default="0A2376")
|
parser.add_option("-c", "--color", action="store", dest="color", default="0A2376")
|
||||||
|
parser.add_option(
|
||||||
|
"-b", "--background", action="store", dest="background", default="FFFFFF"
|
||||||
|
)
|
||||||
parser.add_option(
|
parser.add_option(
|
||||||
"-s", "--size", action="store",
|
"-s", "--size", action="store",
|
||||||
type="int", dest="size", default=100
|
type="int", dest="size", default=100
|
||||||
@ -47,7 +50,14 @@ def main():
|
|||||||
else:
|
else:
|
||||||
parser.error("Must specify either points or order.")
|
parser.error("Must specify either points or order.")
|
||||||
|
|
||||||
d = draw.Demo(c, options.size, options.color, options.dotsize, *options.mark)
|
d = draw.Demo(
|
||||||
|
c,
|
||||||
|
options.size,
|
||||||
|
options.color,
|
||||||
|
options.background,
|
||||||
|
options.dotsize,
|
||||||
|
*options.mark
|
||||||
|
)
|
||||||
d.draw()
|
d.draw()
|
||||||
d.save(args[0])
|
d.save(args[0])
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ class Canvas:
|
|||||||
def ctx(self):
|
def ctx(self):
|
||||||
return cairo.Context(self.surface)
|
return cairo.Context(self.surface)
|
||||||
|
|
||||||
def background(self, r, g, b, a):
|
def background(self, r, g, b, a=1):
|
||||||
c = self.ctx()
|
c = self.ctx()
|
||||||
c.set_source_rgba(r, g, b, a)
|
c.set_source_rgba(r, g, b, a)
|
||||||
c.rectangle(0, 0, self.width, self.height)
|
c.rectangle(0, 0, self.width, self.height)
|
||||||
@ -38,11 +38,12 @@ class Demo:
|
|||||||
Draws a 2d curve within a specified square.
|
Draws a 2d curve within a specified square.
|
||||||
"""
|
"""
|
||||||
PAD = 5
|
PAD = 5
|
||||||
def __init__(self, curve, size, color, dotsize, *marks):
|
def __init__(self, curve, size, color, background, dotsize, *marks):
|
||||||
self.curve = curve
|
self.curve = curve
|
||||||
self.size, self.color, self.dotsize = size, color, dotsize
|
self.size, self.color, self.dotsize = size, color, dotsize
|
||||||
|
self.background = background
|
||||||
self.c = Canvas(size+self.PAD*2, size+self.PAD*2)
|
self.c = Canvas(size+self.PAD*2, size+self.PAD*2)
|
||||||
self.c.background(1, 1, 1, 1)
|
self.c.background(*parseColor(self.background))
|
||||||
self.ctx = self.c.ctx()
|
self.ctx = self.c.ctx()
|
||||||
self.ctx.set_line_width(1)
|
self.ctx.set_line_width(1)
|
||||||
# Assuming all dimension sizes are equal
|
# Assuming all dimension sizes are equal
|
||||||
|
Loading…
Reference in New Issue
Block a user