Пример #1
0
def squaredRainbow():
    ff = 255
    bitmap = IV122Graphics.BitMap("output/squaredRainbow.jpg", ff, ff)
    for i in range(ff):
        for j in range(ff):
            bitmap.putPixel(i, j, (i, j, ff))
    bitmap.close()
Пример #2
0
def generateWeirdStrips(name, size):
    bitmap = IV122Graphics.BitMap("output/effects/" + name + ".jpg", size,
                                  size)
    stripSize = 20

    radiusSize = 50
    for i_x in range(-size / 2, size / 2):
        for i_y in range(-size / 2, size / 2):
            distanceFromMiddle = ((i_x**2 + i_y**2)**0.5)
            isInsideSquare = abs(i_x) < squareSize / 2 and abs(
                i_y) < squareSize / 2

            if (isInsideSquare):
                colElement = 127 + Commons.cos(
                    (360 / radiusSize) *
                    (distanceFromMiddle % radiusSize)) * 127
            else:
                colElement = 127 - Commons.cos(
                    (360 / radiusSize) *
                    (distanceFromMiddle % radiusSize)) * 127

            color = (colElement, colElement, colElement)

            bitmap.putPixel(size / 2 + i_x, size / 2 + i_y, color)

    print "neco"
    bitmap.close()
Пример #3
0
def juliusSet():
    imgSize = 400
    depth = 20
    simpleHeuristic = 2

    bitmap = IV122Graphics.BitMap("output/julii.jpg", imgSize, imgSize)

    for x in range(-imgSize / 2, imgSize / 2):
        for y in range(-imgSize / 2, imgSize / 2):
            z = complex(x / 100.0, y / 100.0)
            c = complex(-0.13, 0.75)
            currDepth = 0
            while abs(z) < simpleHeuristic and currDepth < depth:
                z = nextMandelBrot(z, c)
                currDepth += 1

            if abs(z) < simpleHeuristic:
                distane = abs(z)
                color = ((255.0 * distane) / simpleHeuristic)
                bitmap.putPixel(x + imgSize / 2, y + imgSize / 2,
                                (color, 0, 0))
            else:
                color = ((255.0 * currDepth) / depth)
                bitmap.putPixel(x + imgSize / 2, y + imgSize / 2,
                                (0, color, 0))

    bitmap.close()
Пример #4
0
def generateWeirdCircles(name, size):
    bitmap = IV122Graphics.BitMap("output/effects/" + name + ".jpg", size,
                                  size)
    squareSize = 100
    black = (0, 0, 0)  #initially black, but swaps during execution
    white = (0xFF, 0xFF, 0xFF)

    radiusSize = 50
    for i_x in range(-size / 2, size / 2):
        for i_y in range(-size / 2, size / 2):
            distanceFromMiddle = ((i_x**2 + i_y**2)**0.5)
            isInsideSquare = abs(i_x) < squareSize / 2 and abs(
                i_y) < squareSize / 2

            if (isInsideSquare):
                colElement = 127 + Commons.cos(
                    (360 / radiusSize) *
                    (distanceFromMiddle % radiusSize)) * 127
            else:
                colElement = 127 - Commons.cos(
                    (360 / radiusSize) *
                    (distanceFromMiddle % radiusSize)) * 127

            color = (colElement, colElement, colElement)

            bitmap.putPixel(size / 2 + i_x, size / 2 + i_y, color)

    print "neco"
    bitmap.close()
Пример #5
0
def visualizeNsds():
    size = 400
    bitmapForSubstract = IV122Graphics.BitMap("output/substract.bmp", size,
                                              size)
    bitmapForModulo = IV122Graphics.BitMap("output/modulo.bmp", size, size)
    for i in range(1, size):
        for j in range(1, size):
            stepCountSubstract = nsdSubstract(i, j, True)
            stepCountMod = nsdMod(i, j, True)
            print((i, j, stepCountSubstract, stepCountMod))
            #colorSubstract = (255- stepCountSubstract%255,255-  (stepCountSubstract/255)%255,255-  ((stepCountSubstract/255)/255)%255)
            #colorMod = (255- stepCountMod%255,255-  (stepCountMod/255)%255,255-  ((stepCountMod/255)/255)%255)
            colorSubstract = (255 - stepCountSubstract, 0, 0)
            colorMod = (255 - stepCountMod, 0, 0)
            bitmapForSubstract.putPixel(i, size - j, colorSubstract)
            bitmapForModulo.putPixel(i, size - j, colorMod)
    bitmapForSubstract.close()
    bitmapForModulo.close()
Пример #6
0
def spiral(name, x, y, r, full=0):
    size = 500
    bitmap = IV122Graphics.BitMap("output/shapes/" + name + ".jpg", size, size)

    #todo zmenit 20 na parametrizovatleny rozestup
    for t in range(360 * 5):
        i_x = (t / 20) * math.sin(Commons.degToRad((t))) + x
        i_y = (t / 20) * math.cos(Commons.degToRad((t))) + y
        bitmap.putPixel(i_x, i_y, (100, 100, 100))

    bitmap.close()
Пример #7
0
def drawFilledPolygon(points, name, size):
    bitmap = IV122Graphics.BitMap("output/" + name + ".jpg", size, size)
    resultLineSegments = []
    for i in range(len(points)):
        resultLineSegments.append((points[i - 1], points[i]))
    print resultLineSegments
    for i_x in range(size):
        for i_y in range(size):
            intersetCount = countIntersect((i_x, i_y), resultLineSegments)
            if (intersetCount % 2 == 1):
                bitmap.putPixel(i_x, i_y, (100, 100, 100))

    bitmap.close()
Пример #8
0
def chaosgame(path, ngon, ratio):
    imgSize = 800
    jpeg = IV122Graphics.BitMap(path, imgSize, imgSize)
    outerPoints = generateNGonPoint(ngon, imgSize / ngon)

    stepCount = 10000

    point = getRandomPoint(imgSize)
    for i in range(stepCount):
        chosenOrigin = random.randint(0, ngon - 1)
        point = computeMidPoint(outerPoints[chosenOrigin], point, ratio)
        if (i > 100):
            jpeg.putPixel(point[0], point[1], (255, 0, 0))
    jpeg.close()
Пример #9
0
def mandelBrot(imgSize, cutX, cutY, cutSize, name="mandelbrot"):
    #imgsize resaclovat na ctverec -2, 2
    #cutX = -1
    #cutY = -1
    #cutSize = imgSize/4.0

    #multiply something by cutSize, add cutX to something, add cutY to something

    scaleFactor = imgSize / (4.0)
    scaleFactor2 = imgSize / cutSize
    #scaleFactorX = imgSize / (4.0 * (-2.0/cutX)) #
    #scaleFactorY = imgSize / (4.0 * (-2.0/cutY)) # bullshit

    # scaledX cutX
    #         -2   = 0
    #         -1   = +1
    #          0     +2
    #          1     +3
    #          2     +4

    depth = 20
    simpleHeuristic = 2

    bitmap = IV122Graphics.BitMap("output/" + name + ".jpg", imgSize, imgSize)

    for x in range(-imgSize / 2, imgSize / 2):
        for y in range(-imgSize / 2, imgSize / 2):
            z = complex(0, 0)
            scaledX = x / scaleFactor
            scaledY = y / scaleFactor
            c = complex((scaledX / scaleFactor2) + cutX - 2,
                        (scaledY / scaleFactor2) + cutY - 2)
            currDepth = 0
            while abs(z) < simpleHeuristic and currDepth < depth:
                z = nextMandelBrot(z, c)
                currDepth += 1

            if abs(z) < simpleHeuristic:
                distane = abs(z)
                color = ((255.0 * distane) / simpleHeuristic)
                bitmap.putPixel(x + imgSize / 2, y + imgSize / 2,
                                (color, 0, 0))
            else:
                color = ((255.0 * currDepth) / depth)
                bitmap.putPixel(x + imgSize / 2, y + imgSize / 2,
                                (0, color, 0))

    bitmap.close()
Пример #10
0
def circle(name, x, y, r, full=0):
    size = 500
    bitmap = IV122Graphics.BitMap("output/shapes/" + name + ".jpg", size, size)
    thickness = 300.0

    for i_x in range(size):
        for i_y in range(size):
            if (full == 0):
                if abs((float(i_x) - x)**2.0 +
                       (i_y - y)**2 - r**2) <= thickness:
                    bitmap.putPixel(i_x, i_y, (100, 100, 100))
            else:
                if abs((float(i_x) - x)**2.0 +
                       (i_y - y)**2) <= thickness + r * r:
                    bitmap.putPixel(i_x, i_y, (100, 100, 100))
    bitmap.close()
Пример #11
0
def colorEquilateralTriangle(name, size=500):
    bitmap = IV122Graphics.BitMap("output/shapes/" + name + ".jpg", size, size)

    bot = 10
    right = size - 10
    left = 10

    for i_x in range(size):
        for i_y in range(size):
            halfplane1 = i_y >= 0
            #halfplane2 = i_y <= -math.sqrt(3.0)/2 * i_x + math.sqrt(3.0)*size/2
            halfplane2 = i_y >= math.sqrt(3.0) * i_x
            halfplane3 = i_y >= -math.sqrt(3.0) * i_x + size
            #halfplane3 = i_y <= math.sqrt(3.0)/2 * i_x + -math.sqrt(3.0)*size/2

            if (halfplane1 and halfplane2 and halfplane3):
                bitmap.putPixel(i_x, i_y,
                                ((i_x / 2) % 255, (i_y / 3) % 255, 100))
    bitmap.close()
Пример #12
0
def generateWeirdChessboard(name, size):
    bitmap = IV122Graphics.BitMap("output/effects/" + name + ".jpg", size,
                                  size)
    squareSize = 20
    black = (0, 0, 0)  #initially black, but swaps during execution
    white = (0xFF, 0xFF, 0xFF)

    radiusSize = 50
    for i_x in range(-size / 2, size / 2):
        for i_y in range(-size / 2, size / 2):
            xParity = (i_x / 20) % 2
            yParity = (i_y / 20) % 2
            levelOfCircle = (
                (i_x**2 + i_y**2)**
                0.5) / radiusSize  #v kolikatem krouzku od prostred jsem
            #print int(levelOfCircle)

            if (int(levelOfCircle) % 2 == 0):
                color1, color2 = black, white
            else:
                color1, color2 = white, black

            if (xParity == 1):
                if (yParity == 1):
                    print "a", color1, color2
                    bitmap.putPixel(size / 2 + i_x, size / 2 + i_y, color2)
                else:
                    print "b", color1, color2
                    bitmap.putPixel(size / 2 + i_x, size / 2 + i_y, color1)
            else:
                if (yParity == 1):
                    print "c", color1, color2
                    bitmap.putPixel(size / 2 + i_x, size / 2 + i_y, color1)
                else:
                    print "d", color1, color2
                    bitmap.putPixel(size / 2 + i_x, size / 2 + i_y, color2)

    print "neco"
    bitmap.close()
Пример #13
0
def feingebaum(x_min, x_max, steps, name, size=100):
    jpeg = IV122Graphics.BitMap("output/" + name + ".jpg", size, size)

    dif = x_max - x_min
    step = (float(dif) / steps)

    myRange = []
    for x in range(
            steps
    ):  #containes "steps" number of values from 0 to 1, scaled according to specified zoom
        myRange.append(x * step * (1 / dif))

    print myRange
    for i in myRange:
        xt = 0.5
        for j in range(200):
            xt = getNextFeingenbaum(
                xt, i * dif + x_min)  #adding to i to scale according to zoom
            if (j > 100):
                jpeg.putPixel(
                    i * (size), size - (size * xt) - 1,
                    (0, 0, 0))  #odecitam od size,  aby to nebylo obracen

    jpeg.close()
Пример #14
0
def ellipses(name, size=500):
    bitmap = IV122Graphics.BitMap("output/shapes/" + name + ".jpg", size, size)

    bot = 10
    right = size - 10
    left = 10

    for i_x in range(-size / 2, size / 2):
        for i_y in range(-size / 2, size / 2):
            a = 100
            b = 200

            term1 = (
                (i_x * Commons.cos(30) + i_y * Commons.sin(30))**2) / (a * a)
            term2 = (
                (i_x * Commons.sin(30) - i_y * Commons.cos(30))**2) / (b * b)

            distance = (i_x * i_x + i_y * i_y)**0.5

            if (term1 + term2 <= 1):
                bitmap.putPixel(
                    size / 2 + i_x, size / 2 + i_y,
                    (255 - distance, 255 - distance, 255 - distance))
    bitmap.close()
Пример #15
0
        for y in range(-imgSize / 2, imgSize / 2):
            z = complex(x / 100.0, y / 100.0)
            c = complex(-0.13, 0.75)
            currDepth = 0
            while abs(z) < simpleHeuristic and currDepth < depth:
                z = nextMandelBrot(z, c)
                currDepth += 1

            if abs(z) < simpleHeuristic:
                distane = abs(z)
                color = ((255.0 * distane) / simpleHeuristic)
                bitmap.putPixel(x + imgSize / 2, y + imgSize / 2,
                                (color, 0, 0))
            else:
                color = ((255.0 * currDepth) / depth)
                bitmap.putPixel(x + imgSize / 2, y + imgSize / 2,
                                (0, color, 0))

    bitmap.close()


if __name__ == "__main__":
    imgSize = 1600
    mandelBrot(imgSize, -1, -1, 400, "mandelBrot_1_1")
    mandelBrot(imgSize, -1, 0, 400, "mandelBrot_10")
    mandelBrot(imgSize, 0, 1, 400, "mandelBrot01")
    juliusSet()

    bitmap = IV122Graphics.BitMap("output/test.jpg", 400, 400)
    bitmap.close()