Beispiel #1
0
        line_buf.append((x2, y2))
    else:
        flush_line()
        line_buf = [(x, y), (x2, y2)]


def flush_line():
    global line_buf
    if len(line_buf) > 0:
        tools.choose(tools.PEN)
        tools.mouse(line_buf)
    line_buf = []


DEG_TO_RAD = math.pi / 180
ANGLE = abs(dialog.input_value("Angle (< 90)", 45))
if ANGLE >= 90:
    dialog.show_message("Invalid angle")
DEFAULT_SIZE_Y = 7 * 8 / 2 * 2 * (1.14 + math.cos(ANGLE * DEG_TO_RAD)) / 2.14
MULTIPLIER = image.get_height() / DEFAULT_SIZE_Y

ZOOM = dialog.input_value("Vertical size (%)", 95)
MULTIPLIER = MULTIPLIER * ZOOM / 100


def drawTree(x1, y1, angle, depth):
    if (depth > 0):
        x2 = x1 + (math.cos(angle * DEG_TO_RAD) * depth * MULTIPLIER)
        y2 = y1 + (math.sin(angle * DEG_TO_RAD) * depth * MULTIPLIER)
        line(x1, y1, x2, y2)
        drawTree(x2, y2, angle - ANGLE, depth - 2)
    if len(line_buf) > 0 and line_buf[-1] == (x, y):
        line_buf.append((x2, y2))
    else:
        flush_line()
        line_buf = [(x, y), (x2, y2)]


def flush_line():
    global line_buf
    if len(line_buf) > 0:
        tools.choose(tools.PEN)
        tools.mouse(line_buf)
    line_buf = []


MULTIPLIER = dialog.input_value("Zoom", 10)
DEG_TO_RAD = math.pi / 180


def drawTree(x1, y1, angle, depth):
    if (depth > 0):
        x2 = x1 + (math.cos(angle * DEG_TO_RAD) * depth * MULTIPLIER)
        y2 = y1 + (math.sin(angle * DEG_TO_RAD) * depth * MULTIPLIER)
        line(x1, y1, x2, y2)
        drawTree(x2, y2, angle - random.randint(15, 50), depth - 1.44)
        drawTree(x2, y2, angle + random.randint(10, 25), depth - 0.72)
        drawTree(x2, y2, angle - random.randint(10, 25), depth - 3)
        drawTree(x2, y2, angle + random.randint(15, 50), depth - 4)


image.do_begin()
from lazpaint import image, layer, dialog, colors, view

view.set_zoom(1)
width = 256
height = 256
image.new(width, height)
red = dialog.input_value("Red value (0..255)", 0)
image = []
for y in range(height):
    scanline = [colors.RGB(red, x, y) for x in range(width)]
    image.append(scanline)

layer.put_image(0, 0, image, layer.DM_SET)
if layer.get_pixel(192, 64).green != 192:
    dialog.show_message("The value of the pixel is not correct.")
else:
    dialog.show_message("Test successful.")

view.zoom_fit()
view.set_zoom(10)
view.set_grid_visible(True)
Beispiel #4
0
  global line_buf
  if len(line_buf) > 0 and line_buf[-1] == (x, y):
    line_buf.append( (x2, y2) )
  else:
    flush_line()
    line_buf = [(x, y), (x2, y2)]

def flush_line():
  global line_buf
  if len(line_buf) > 0:
    tools.choose(tools.PEN)
    tools.mouse(line_buf)
  line_buf = []

DEG_TO_RAD = math.pi / 180
ANGLE = abs(dialog.input_value(dialog.translate_text("Angle") + " (< 90)", 45))
if ANGLE >= 90:
  dialog.show_message(translation["Invalid angle"])
  exit()
DEFAULT_SIZE_Y = 7*8/2*2 * (1.14+math.cos(ANGLE * DEG_TO_RAD))/2.14
MULTIPLIER = image.get_height() / DEFAULT_SIZE_Y

ZOOM = dialog.input_value(translation["Vertical size"] + " (%)", 95)
MULTIPLIER = MULTIPLIER * ZOOM/100


def drawTree(x1, y1, angle, depth):
    if (depth > 0):
        x2 = x1 + (math.cos(angle * DEG_TO_RAD) * depth * MULTIPLIER)
        y2 = y1 + (math.sin(angle * DEG_TO_RAD) * depth * MULTIPLIER)
        line(x1, y1, x2, y2)
Beispiel #5
0
from lazpaint import tools, image, layer, dialog


def line(x, y, x2, y2):
    tools.choose(tools.PEN)
    tools.mouse([(x, y), (x2, y2)])


ZOOM = dialog.input_value(
    "Zoom (Between 0.1 and 0.4 it creates a 3d room, more than 0.5 to 0.9 it creates a cross with a rectangle)",
    0.25)

image.do_begin()
layer.new()
w = image.get_width()
h = image.get_height()

#top left
line(0, 0, w * ZOOM, h * ZOOM)
#bottom left
line(0, h, w * ZOOM, h - (h * ZOOM))
#top right
line(w, 0, w - (w * ZOOM), h * ZOOM)
#bottom right
line(w, h, w - (w * ZOOM), h - (h * ZOOM))
#top
line(w * ZOOM, h * ZOOM, w - (w * ZOOM), h * ZOOM)
#bottom
line(w * ZOOM, h - (h * ZOOM), w - (w * ZOOM), h - (h * ZOOM))
#left
line(w * ZOOM, h * ZOOM, w * ZOOM, h - (h * ZOOM))