HSP sun HSP Programming Guide

HSP Guide [3]

Draw image

The "picload" instruction is used to display the image in the window of HSP. The corresponding image file (image format) is four (bmp (bit map) and gif, jpg, and ico (icon)). It makes in the delimitation of passing of the file and yen two signs "\" are made "\\". It is not recognized as passing if it doesn't write in the script of HSP like this. (Refer previous guide)

	pos 100,100
	picload "C:\\Program Files\\HSP30a\\docs\\hsp3ttl.jpg",1

	stop

When there is no picture file in the place specified on. It must be unquestionable for any environment usually if it makes it to the way below if it is a folder that exists in the lower layer of the script editor.

	pos 100,100
	picload "docs\\hsp3ttl.jpg",1

	stop

"pos" The instruction is specified for a display position for the upper part of the left of the image. By the way, the character of the "mes" instruction can be displayed as it is in the image. It is possible to draw in the figure.

	pos 100,100
	picload "docs\\hsp3ttl.jpg",1

	pos 150,150
	color $FF
	mes "Message on Image"

Draw image in part of

It is time when it does only for a necessary part to copy the image though the image simply specified was displayed on. Drawing between windows is cut out and the copied "gcopy" instruction is used. The HSP window in the operation destination is switched by using the instruction at this time "gsel".

	screen 1
//	buffer 1

	picload "docs\\hsp3ttl.jpg"

//	change window id 0 destination to draw
	gsel 0

//	copy image from window id 1
	gcopy 1,50,50,100,100

	stop

The buffer window is displayed in window ID1 by the "buffer" instruction. It is non-display not seen eyes displayed on the other side if it says easily. (Make it to "screen" instruction.)

A necessary image is read beforehand, and if necessary parts are brought at that time, it does by being the efficacy lead. The under pushes the mouse and is a sample put. "pos" It is a position in which the instruction is copied.

//	Label specification when mouse's button is pushed
	onclick *click

//	visible buffer window 
	buffer 1

	picload "docs\\hsp3ttl.jpg"

//	change window id 0 to draw
	gsel 0

	stop

*click
//	mousex and mousey is cursor position
	pos mousex,mousey

	gcopy 1,50,50,100,100

Another copy

"gcoy" It is, that is, "gzoom" instruction that expansion/reduces size in HSP besides instruction and copies it.

//	Label specification when mouse's button is pushed
	onclick *click

	screen 1

	picload "sample\\demo\\onibtn.gif"

	gsel 0

	stop

*click
	pos mousex,mousey

;	left-click, it is the twice size.
	if wparam = 1{
		gzoom 136*2,50*2,1,0,0,136,50
	}

;	right-clicking, it is 1/2 sizes.
	if wparam = 2{
		gzoom 136/2,50/2,1,0,0,136,50
	}

< Prev | Next >

About

Welcome to HSP sun. Here is a site to introduces HSP, a free script language system.

Menu

Copyright(c) HSP sun [HSP]

inserted by FC2 system