Friday, April 30, 2021

Edward Lance Lorilla

Edward Lance Lorilla


【VISUAL VB.NET】Add and Remove Programs

Posted: 30 Apr 2021 02:54 AM PDT

 Public Class Form1

Dim fileArgs As String Dim path As String = "C:\Windows\System32\" Dim cmdProcess As Process = New Process() Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click fileArgs = "shell32.dll,Control_RunDLL appwiz.cpl,,0" cmdProcess.StartInfo.Arguments = fileArgs cmdProcess.StartInfo.WorkingDirectory = path cmdProcess.StartInfo.FileName = "RunDll32.exe" cmdProcess.Start() cmdProcess.WaitForExit() Me.Show() End SubEnd Class

【JAVASCRIPT】 native component math operations component

Posted: 29 Apr 2021 08:37 PM PDT

【PYTHON OPENCV】Understanding cv2.dnn.blobFromImages() and cv2.dnn.imagesFromBlob() in OpenCV with cropping

Posted: 29 Apr 2021 08:50 AM PDT

 """

Understanding cv2.dnn.blobFromImages() and cv2.dnn.imagesFromBlob() in OpenCV with cropping """ # Import required packages:import cv2import numpy as npfrom matplotlib import pyplot as plt def get_cropped_img(img): """Returns the cropped image""" # Create a copy of the image: img_copy = img.copy() # calculate size of resulting image: size = min(img_copy.shape[1], img_copy.shape[0]) # calculate x1, and y1 x1 = int(0.5 * (img_copy.shape[1] - size)) y1 = int(0.5 * (img_copy.shape[0] - size)) # crop and return the image return img_copy[y1:(y1 + size), x1:(x1 + size)] def show_img_with_matplotlib(color_img, title, pos): """Shows an image using matplotlib capabilities""" img_RGB = color_img[:, :, ::-1] ax = plt.subplot(2, 2, pos) plt.imshow(img_RGB) plt.title(title) plt.axis('off') def get_images_from_blob(blob_imgs, scalefactor, dim, mean, swap_rb, mean_added): """Returns images from blob""" images_from_blob = cv2.dnn.imagesFromBlob(blob_imgs) imgs = [] for image_blob in images_from_blob: image_from_blob = np.reshape(image_blob, dim) / scalefactor image_from_blob_mean = np.uint8(image_from_blob) image_from_blob = image_from_blob_mean + np.uint8(mean) if mean_added is True: if swap_rb: image_from_blob = image_from_blob[:, :, ::-1] imgs.append(image_from_blob) else: if swap_rb: image_from_blob_mean = image_from_blob_mean[:, :, ::-1] imgs.append(image_from_blob_mean) return imgs # Load images and get the list of images:image = cv2.imread("face_test.png")image2 = cv2.imread("face_test2.jpg")images = [image, image2] # To see how cropping works, we are going to perform the cropping formulation that# both blobFromImage() and blobFromImages() perform applying it to one of the input images:cropped_img = get_cropped_img(image)# cv2.imwrite("cropped_img.jpg", cropped_img) # Call cv2.dnn.blobFromImages():blob_images = cv2.dnn.blobFromImages(images, 1.0, (300, 300), [104., 117., 123.], False, False)blob_blob_images_cropped = cv2.dnn.blobFromImages(images, 1.0, (300, 300), [104., 117., 123.], False, True) # Get different images from the blob:imgs_from_blob = get_images_from_blob(blob_images, 1.0, (300, 300, 3), [104., 117., 123.], False, True)imgs_from_blob_cropped = get_images_from_blob(blob_blob_images_cropped, 1.0, (300, 300, 3), [104., 117., 123.], False,True) # Create the dimensions of the figure and set title:fig = plt.figure(figsize=(10, 8))plt.suptitle("cv2.dnn.blobFromImages() visualization with cropping", fontsize=14, fontweight='bold')fig.patch.set_facecolor('silver') # Show the input imagesshow_img_with_matplotlib(imgs_from_blob[0], "img 1 from blob " + str(imgs_from_blob[0].shape), 1)show_img_with_matplotlib(imgs_from_blob[1], "img 2 from blob " + str(imgs_from_blob[1].shape), 2)show_img_with_matplotlib(imgs_from_blob_cropped[0], "img 1 from blob cropped " + str(imgs_from_blob[1].shape), 3)show_img_with_matplotlib(imgs_from_blob_cropped[1], "img 2 from blob cropped " + str(imgs_from_blob[1].shape), 4) # Show the Figure:plt.show()

【GAMEMAKER】boomerang

Posted: 29 Apr 2021 08:48 AM PDT

  Information about object: objPlayer


Sprite: sprPlayer

Solid: false

Visible: true

Depth: 0

Persistent: false

Parent:

Children:

Mask:

No Physics Object

Create Event:

execute code:


Facing_Direction=0;

Step Event:

execute code:


if keyboard_check(vk_space) && instance_number(objBoomerang)=0 {

  instance_create(x,y,objBoomerang);

}

hspeed=0;

vspeed=0;

if keyboard_check(vk_left) then {hspeed=-4; Facing_Direction=180;}

if keyboard_check(vk_right) then {hspeed=4; Facing_Direction=0;}

if keyboard_check(vk_up) then vspeed=-4;

if keyboard_check(vk_down) then vspeed=4;


Information about object: objBoomerang

Sprite: sprBoomerang

Solid: false

Visible: true

Depth: 

0

Persistent: false

Parent: 

Children: 

Mask: 


No Physics Object


Create Event:

execute code:


Catch=false;

if objPlayer.Facing_Direction=0 {

  hspeed=5;

  vspeed=5;

} else {

  hspeed=-5;

  vspeed=-5;

}


Step Event:

execute code:


if place_meeting(x,y,objPlayer)=false and Catch=false then Catch=true;


if (direction>=point_direction(x,y,objPlayer.x,objPlayer.y)-4 && direction<=point_direction(x,y,objPlayer.x,objPlayer.y)+4) {

  direction=point_direction(x,y,objPlayer.x,objPlayer.y);

} else {

  direction+=4;

}


if direction>360 then direction=4;


Collision Event with object objPlayer:

execute code:


if Catch=true then instance_destroy();


Other Event: Intersect Boundary:

bounce not precisely against solid objects


Information about object: objMonster

Sprite: sprMonster

Solid: false

Visible: true

Depth: 

0

Persistent: false

Parent: 

Children: 

Mask: 


No Physics Object


Collision Event with object objBoomerang:

execute code:


instance_destroy();

【GAMEMAKER】Saving

Posted: 29 Apr 2021 08:44 AM PDT

Information about object: obj_splash

Sprite:
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent:
Children:
Mask:
No Physics Object

Create Event:
execute code:

///set up stats
//Load Data From Save
ini_open("save.ini");
global.stats[1,1]="Magic";
global.stats[1,2]=ini_read_real("Stats", "Magic", 4);

global.stats[2,1]="Kindness";
global.stats[2,2]=ini_read_real("Stats", "Kindness", 4);

global.stats[3,1]="Evilness";
global.stats[3,2]=ini_read_real("Stats", "Evilness",2)

global.stats[4,1]="Strength";
global.stats[4,2]=ini_read_real("Stats", "Strength", 4);

global.stats[5,1]="Wisdom";
global.stats[5,2]=ini_read_real("Stats", "Wisdom", 0);

global.stats[5,1]="Charisma";
global.stats[5,2]=ini_read_real("Stats", "Charisma", 1);

global.upgrades=ini_read_real("Stats", "Upgrades", 8);

global.quest1=ini_read_real("Quest", "1", true);

global.pirate1_x=ini_read_real("Pirates", "1x", 350);
global.pirate1_y=ini_read_real("Pirates", "1y", 640);

global.gold=ini_read_real("Stats", "Gold", 200);


ini_close();
//goto main room
room_goto(room_saving);

Information about object: obj_button
Sprite: spr_button
Solid: false
Visible: true
Depth:
0
Persistent: false
Parent:
Children:
Mask:

No Physics Object

Create Event:
execute code:

//set up
image_speed=0;
image_index=0;
Step Event:
execute code:

///mouse button
if mouse_check_button_pressed(mb_left) && position_meeting(mouse_x, mouse_y, id)
{
if global.upgrades>0 && global.stats[my_id,2]<10
{
//upgrade
global.upgrades--;
global.stats[my_id,2]++;
}
}
Draw Event:
execute code:

//draw button
draw_self();
//set text drawing
draw_set_halign(fa_center);
draw_set_valign(fa_middle);
//draw the text
draw_set_halign(fa_left);
draw_text(50,my_id*100,global.stats[my_id,1]);

//draw red sprite - not the quickest approach, but easy to understange
for (var loop=1; loop < 11; loop += 1)
{
draw_sprite(spr_info,1,150+loop*40,my_id*100)
}

//draw yellow sprite
for (var loop=1; loop <= global.stats[my_id,2]; loop += 1)
{
draw_sprite(spr_info,0,150+loop*40,my_id*100)
}

//draw button text
draw_set_halign(fa_center);
if global.stats[my_id,2]<10 && global.upgrades>0
{
image_index=0;
draw_text(x,y,"Available");
}
else if global.stats[my_id,2]==10
{
image_index=1;
draw_text(x,y,"Maxed Out");
}
else
{
image_index=1;
draw_text(x,y,"Not Available");
}



Information about object: obj_setup_buttons_and_hud
Sprite:
Solid: false
Visible: true
Depth:
0
Persistent: false
Parent:
Children:
Mask:

No Physics Object

Create Event:
execute code:

///create buttons
for (var loop = 1; loop < 6; loop += 1)
{
button=instance_create(700,100*loop,obj_button);
button.my_id=loop
}
Step Event:
execute code:

///for testing
if keyboard_check_pressed(ord('R'))
{
show_message("Saved - Restaring");
game_restart();
}

if keyboard_check_pressed(ord('S'))
{
scr_save_data();
show_message("All Data Saved");
}

if keyboard_check_pressed(ord('Q'))
{
global.quest1=!global.quest1;
}

if keyboard_check_pressed (ord('G'))
{
global.gold+=100;
}
if keyboard_check_pressed (ord('X'))
{
global.upgrades+=5;
}
Draw Event:
execute code:

///for testing
draw_set_halign(fa_left);

draw_text(100,50,"You Have "+string(global.upgrades)+" Upgrade Points - Press R To Restart Example#Arrow Keys To Move Character#S To Save Data - A D move pirate - Q Toggle Quest -#G For More Gold X For More Upgrade Points");

if global.quest1 draw_text(400,700,"Quest Completed");
else
draw_text(400,700,"Quest Is Not Completed");

draw_text(400,720,"Gold "+string(global.gold));

Information about object: obj_pirate
Sprite: spr_pirate
Solid: false
Visible: true
Depth:
0
Persistent: false
Parent:
Children:
Mask:

No Physics Object

Create Event:
execute code:

x=global.pirate1_x;
y=global.pirate1_y;
Step Event:
execute code:

if keyboard_check(ord('A'))
{
x--;
}
if keyboard_check(ord('D'))
{
x++;
}

if x<64 x=64;
if x>room_width-64 x=room_width-64;

No comments:

Post a Comment