示例#1
0
def list_settings():

    # Create a brush, load from disk
    brush = MyPaint.Brush()
    brush_def = open("brushes/classic/brush.myb").read()
    brush.from_string(brush_def)

    # List all settings
    # TODO: Is there a better way to list all enums with GI?
    settings = [
        str(getattr(MyPaint.BrushSetting, attr))
        for attr in dir(MyPaint.BrushSetting) if attr.startswith("SETTING_")
    ]
    print("Available settings: %s\n" % "\n".join(settings))

    # Get info about a given setting
    setting = MyPaint.BrushSetting.SETTING_RADIUS_LOGARITHMIC
    info = MyPaint.brush_setting_info(setting)

    # TODO: rename "def_" to "default"
    print("Setting: %s\n\t Max: %f \n\t Default: %f \n\t Min: %f" %
          (info.cname, info.max, info.def_, info.min))
    # Use the getters so that i18n works
    print("\t Name: %s\n\t Tooltip: '%s'\n" %
          (info.get_name(), info.get_tooltip()))

    # TODO: should be MyPaint.BrushSetting.from_cname
    # Same with MyPaint.Brush.input_from_cname
    assert (MyPaint.Brush.setting_from_cname(info.cname) == setting)

    # Get/Set current base value for the given setting
    print("Base value is: %f" % brush.get_base_value(setting))
    brush.set_base_value(setting, 2.0)
    assert brush.get_base_value(setting) == 2.0

    # Get dynamics for given setting
    inputs = [
        getattr(MyPaint.BrushInput, a) for a in dir(MyPaint.BrushInput)
        if a.startswith('INPUT_')
    ]
    if not brush.is_constant(setting):
        for input in inputs:
            mapping_points = brush.get_mapping_n(setting, input)
            if mapping_points > 1:  # If 0, no dynamics for this input
                points = [
                    brush.get_mapping_point(setting, input, i)
                    for i in range(mapping_points)
                ]
                print("Has dynamics for input %s:\n%s" % (input, str(points)))
示例#2
0
文件: gegl.py 项目: Griatch/dopey
def something():

    #MyPaint.init()

    # Create a brush, load from disk
    brush = MyPaint.Brush()
    brush_def = open("brushes/classic/brush.myb").read()
    brush.from_string(brush_def)

    # List all settings
    # TODO: Is there a better way to list all enums with GI?
    settings = [getattr(MyPaint.BrushSetting, attr) for attr in dir(MyPaint.BrushSetting) if attr.startswith("SETTING_")]
    print "Available settings: %s\n" % str(settings)

    # Get info about a given setting
    setting = MyPaint.BrushSetting.SETTING_RADIUS_LOGARITHMIC
    info = MyPaint.brush_setting_info(setting)

    # TODO: rename "def_" to "default"
    print "Setting: %s\n\t Max: %f \n\t Default: %f \n\t Min: %f" % (info.cname, info.max, info.def_, info.min)
    print "\t Name: %s\n\t Tooltip: '%s'\n" % (info.get_name(), info.get_tooltip()) # Use the getters so that i18n works

    # TODO: should be MyPaint.BrushSetting.from_cname
    # Same with MyPaint.Brush.input_from_cname
    assert (MyPaint.Brush.setting_from_cname(info.cname) == setting)

    # Get/Set current base value for the given setting
    print "Base value is: %f" % brush.get_base_value(setting)
    brush.set_base_value(setting, 2.0)
    assert brush.get_base_value(setting) ==  2.0

    # Get dynamics for given setting
    inputs = [getattr(MyPaint.BrushInput, a) for a in dir(MyPaint.BrushInput) if a.startswith('INPUT_')]
    if not brush.is_constant(setting):
        for input in inputs:
            mapping_points = brush.get_mapping_n(setting, input)
            if mapping_points > 1: # If 0, no dynamics for this input
                points = [brush.get_mapping_point(setting, input, i) for i in range(mapping_points)]
                print "Has dynamics for input %s:\n%s" % (input, str(points))


    # Create a surface to paint on
    Gegl.init(0, "")
    surface = MyPaintGegl.TiledSurface()
    s = surface.interface()

    print surface.get_buffer()

    for x, y in [(0.0, 0.0), (100.0, 100.0), (100.0, 200.0)]:
        dtime = 0.1 # XXX: Important to set correctly for speed calculations
        s.begin_atomic()
        brush.stroke_to(s, x, y, pressure=1.0, xtilt=0.0, ytilt=0.0, dtime=dtime)
        rect = s.end_atomic()
        print rect.x, rect.y, rect.width, rect.height

    Gegl.exit()
示例#3
0
    def __init__(self):

        self.brush = MyPaint.Brush()
        self.brush.from_defaults()
        self.gegl_surface = MyPaintGegl.TiledSurface()
        self.surface = self.gegl_surface.interface()

        self.graph = Gegl.Node()

        self.button_pressed = False
        self.last_event = (0.0, 0.0, 0.0)  # (x, y, time)

        self.init_ui()
示例#4
0
    def __init__(self):

        self.brush = MyPaint.Brush()
        self.gegl_surface = MyPaintGegl.TiledSurface()
        self.surface = self.gegl_surface.interface()

        self.graph = Gegl.Node()
        self.display_node = self.graph.create_child("gegl:buffer-source")

        # FIXME: does not seem to have any effect
        print self.gegl_surface.get_buffer()
        #self.display_node.set_property("buffer", self.gegl_surface.get_buffer())

        self.button_pressed = False
        self.last_event = (0.0, 0.0, 0.0)  # (x, y, time)

        self.init_ui()
示例#5
0
def list_settings():

    # Create a brush, load from disk
    brush = MyPaint.Brush()
    brush_def = open("brushes/classic/brush.myb").read()
    brush.from_string(brush_def)

    # List all settings
    # TODO: Is there a better way to list all enums with GI?
    settings = [str(getattr(MyPaint.BrushSetting, attr)) for attr in dir(MyPaint.BrushSetting) if attr.startswith("SETTING_")]
    print("Available settings: %s\n" % "\n".join(settings))

    # Get info about a given setting
    setting = MyPaint.BrushSetting.SETTING_RADIUS_LOGARITHMIC
    info = MyPaint.brush_setting_info(setting)

    # TODO: rename "def_" to "default"
    print("Setting: %s\n\t Max: %f \n\t Default: %f \n\t Min: %f" % (
        info.cname, info.max, info.def_, info.min))
    # Use the getters so that i18n works
    print("\t Name: %s\n\t Tooltip: '%s'\n" % (info.get_name(),
                                               info.get_tooltip()))

    # TODO: should be MyPaint.BrushSetting.from_cname
    # Same with MyPaint.Brush.input_from_cname
    assert (MyPaint.Brush.setting_from_cname(info.cname) == setting)

    # Get/Set current base value for the given setting
    print("Base value is: %f" % brush.get_base_value(setting))
    brush.set_base_value(setting, 2.0)
    assert brush.get_base_value(setting) == 2.0

    # Get dynamics for given setting
    inputs = [getattr(MyPaint.BrushInput, a) for a in dir(MyPaint.BrushInput) if a.startswith('INPUT_')]
    if not brush.is_constant(setting):
        for input in inputs:
            mapping_points = brush.get_mapping_n(setting, input)
            if mapping_points > 1:  # If 0, no dynamics for this input
                points = [brush.get_mapping_point(setting, input, i) for i in range(mapping_points)]
                print("Has dynamics for input %s:\n%s" % (input, str(points)))
示例#6
0
    # Create a brush, load from disk
    brush = MyPaint.Brush()
    brush_def = open("brushes/classic/brush.myb").read()
    brush.from_string(brush_def)

    # List all settings
    # TODO: Is there a better way to list all enums with GI?
    settings = [
        getattr(MyPaint.BrushSetting, attr) for attr in dir(MyPaint.BrushSetting) if attr.startswith("SETTING_")
    ]
    print "Available settings: %s\n" % str(settings)

    # Get info about a given setting
    setting = MyPaint.BrushSetting.SETTING_RADIUS_LOGARITHMIC
    info = MyPaint.brush_setting_info(setting)

    # TODO: rename "def_" to "default"
    print "Setting: %s\n\t Max: %f \n\t Default: %f \n\t Min: %f" % (info.cname, info.max, info.def_, info.min)
    print "\t Name: %s\n\t Tooltip: '%s'\n" % (
        info.get_name(),
        info.get_tooltip(),
    )  # Use the getters so that i18n works

    # TODO: should be MyPaint.BrushSetting.from_cname
    # Same with MyPaint.Brush.input_from_cname
    assert MyPaint.Brush.setting_from_cname(info.cname) == setting

    # Get/Set current base value for the given setting
    print "Base value is: %f" % brush.get_base_value(setting)
    brush.set_base_value(setting, 2.0)
示例#7
0
def something():

    #MyPaint.init()

    # Create a brush, load from disk
    brush = MyPaint.Brush()
    brush_def = open("brushes/classic/brush.myb").read()
    brush.from_string(brush_def)

    # List all settings
    # TODO: Is there a better way to list all enums with GI?
    settings = [
        getattr(MyPaint.BrushSetting, attr)
        for attr in dir(MyPaint.BrushSetting) if attr.startswith("SETTING_")
    ]
    print "Available settings: %s\n" % str(settings)

    # Get info about a given setting
    setting = MyPaint.BrushSetting.SETTING_RADIUS_LOGARITHMIC
    info = MyPaint.brush_setting_info(setting)

    # TODO: rename "def_" to "default"
    print "Setting: %s\n\t Max: %f \n\t Default: %f \n\t Min: %f" % (
        info.cname, info.max, info.def_, info.min)
    print "\t Name: %s\n\t Tooltip: '%s'\n" % (
        info.get_name(), info.get_tooltip()
    )  # Use the getters so that i18n works

    # TODO: should be MyPaint.BrushSetting.from_cname
    # Same with MyPaint.Brush.input_from_cname
    assert (MyPaint.Brush.setting_from_cname(info.cname) == setting)

    # Get/Set current base value for the given setting
    print "Base value is: %f" % brush.get_base_value(setting)
    brush.set_base_value(setting, 2.0)
    assert brush.get_base_value(setting) == 2.0

    # Get dynamics for given setting
    inputs = [
        getattr(MyPaint.BrushInput, a) for a in dir(MyPaint.BrushInput)
        if a.startswith('INPUT_')
    ]
    if not brush.is_constant(setting):
        for input in inputs:
            mapping_points = brush.get_mapping_n(setting, input)
            if mapping_points > 1:  # If 0, no dynamics for this input
                points = [
                    brush.get_mapping_point(setting, input, i)
                    for i in range(mapping_points)
                ]
                print "Has dynamics for input %s:\n%s" % (input, str(points))

    # Create a surface to paint on
    Gegl.init(0, "")
    surface = MyPaintGegl.TiledSurface()
    s = surface.interface()

    print surface.get_buffer()

    for x, y in [(0.0, 0.0), (100.0, 100.0), (100.0, 200.0)]:
        dtime = 0.1  # XXX: Important to set correctly for speed calculations
        s.begin_atomic()
        brush.stroke_to(s,
                        x,
                        y,
                        pressure=1.0,
                        xtilt=0.0,
                        ytilt=0.0,
                        dtime=dtime)
        rect = s.end_atomic()
        print rect.x, rect.y, rect.width, rect.height

    Gegl.exit()