Ejemplo n.º 1
0
    def __init__(self, plus, scene, main_light, resolution, parameters):

        self.layers = []
        for layer_params in parameters["layers"]:
            self.layers.append(CloudsLayer(plus, scene, layer_params))

        self.name = parameters["name"]
        self.t = 0
        self.cam_pos = None
        self.bitmap_clouds = hg.Picture()
        self.bitmap_clouds_file = parameters["bitmap_clouds_file"]
        hg.LoadPicture(self.bitmap_clouds, self.bitmap_clouds_file)
        self.map_size = hg.IntVector2(self.bitmap_clouds.GetWidth(),
                                      self.bitmap_clouds.GetHeight())
        self.map_scale = list_to_vec2(parameters["map_scale"])
        self.map_position = list_to_vec2(parameters["map_position"])
        self.sun_light = main_light
        self.ambient_color = scene.GetEnvironment().GetAmbientColor(
        ) * scene.GetEnvironment().GetAmbientIntensity()
        self.v_wind = hg.Vector2(60, 60)
        if "v_wind" in parameters:
            self.v_wind = list_to_vec2(parameters["v_wind"])

        self.update_layers_cloud_map()
        self.update_layers_environment()
        self.update_particles()
Ejemplo n.º 2
0
    def create_tex_and_render_target():
        tex = renderer.NewTexture()
        pic = hg.Picture(size, size, hg.PictureRGBAF)
        renderer.CreateTexture(
            tex, pic, hg.TextureIsRenderTarget | hg.TextureIsShaderResource)

        render_target = renderer.NewRenderTarget()
        renderer.CreateRenderTarget(render_target)
        renderer.SetRenderTargetColorTexture(render_target, tex)

        return tex, render_target
Ejemplo n.º 3
0
renderer = hg.CreateRenderer()
renderer.Open()

# open a new window
win = hg.NewWindow(480, 240)

# create a new output surface for the newly opened window
surface = renderer.NewOutputSurface(win)
renderer.SetOutputSurface(surface)

# initialize the render system, which is used to draw through the renderer
render_system = hg.RenderSystem()
render_system.Initialize(renderer)

# create a gpu texture
pic = hg.Picture(512, 512, hg.PictureRGBA8)
tex = renderer.NewTexture("clock_tex")
if not renderer.CreateTexture(tex, pic):
	print("Could not create clock texture")


def draw_clock():
	""" Function to draw a clock in a picture """
	# Get the current time
	import datetime
	date = datetime.datetime.now()

	# clear the picture
	pic.ClearRGBA(31/255, 106/255, 149/255)

	# draw a clock in the picture
Ejemplo n.º 4
0
# Blit from a picture to another picture

import os
import harfang as hg

hg.LoadPlugins()

# mount the system file driver
hg.MountFileDriver(hg.StdFileDriver())

# load pictures
owl = hg.Picture()
hg.LoadPicture(owl, "_data/owl.jpg")
blink = hg.Picture()
hg.LoadPicture(blink, "_data/blink.jpg")

# blit the center portion of the blinking owl to the lower right corner of the owl picture
owl.Blit(blink, hg.IntRect(128, 128, 384, 384), hg.IntVector2(256, 256))

# blit and stretch the complete blinking owl to the lower left corner of the owl picture
owl.Blit(blink, hg.IntRect(0, 0, 512, 512), hg.IntRect(0, 256, 256, 512),
         hg.FilterBlackman36)

owl.Convert(hg.PictureRGB8)
hg.SavePicture(owl, "blit_picture.jpg", "IJG", "q:100")
Ejemplo n.º 5
0
# Load a picture and save it as JPEG

import os
import harfang as hg

hg.LoadPlugins()

# mount the system file driver
hg.MountFileDriver(hg.StdFileDriver())

# load picture
pic = hg.Picture()
ok = hg.LoadPicture(pic, "_data/owl.jpg")

# IJG codec can only save RGB8
pic.Convert(hg.PictureRGB8)

# save as JPEG in the same folder (quality set to 20%)
hg.SavePicture(pic, "save.jpg", "IJG", "q:20")
Ejemplo n.º 6
0
# Create a picture, allocate and print its dimensions

import harfang as hg

# load picture, allocate and display informations
pic = hg.Picture(128, 512, hg.PictureRGBA8)

print("Picture dimensions: %dx%d" % (pic.GetWidth(), pic.GetHeight()))