Crates.io | genesis2000 |
lib.rs | genesis2000 |
version | 0.2.0 |
source | src |
created_at | 2024-04-18 14:33:00.557805 |
updated_at | 2024-04-20 01:57:36.391627 |
description | Genesis2000 script development interface |
homepage | |
repository | https://github.com/guobbs/genesis2000.git |
max_upload_size | |
id | 1212606 |
size | 25,538 |
Use cargo to create a new script project, for example, the project name is demo
cargo new --bin demo
Enter the demo project directory from the command line terminal.
cd demo
Add the genesis2000 dependency crate to the demo project, run the following Cargo command in your project directory:
cargo add genesis2000
Open the src/main.rs file with an editor and write code in the following way:
use std::collections::HashMap;
use genesis2000::{Genesis, InfoParamType};
fn main() {
// Create a structure instance object of Genesis.
let mut f = Genesis::new();
// Demonstrate how to use the COM interface.
f.COM("units,type=mm");
// print results of COM
println!("status: {}\ncomans: {}", f.STATUS, f.COMANS);
f.COM("get_affect_layer");
println!("status: {}\ncomans: {}", f.STATUS, f.COMANS);
// Demonstrate how to get the coordinates of the point clicked by the mouse in the main graphic area.
f.MOUSE("p Select a point on the screen");
// f.MOUSEANS is a coordinate point
println!("status: {}\nmouse: {}", f.STATUS, f.MOUSEANS);
// Demonstrate how to get the coordinates of two diagonal points of a rectangular area selected by the mouse in the main graphic area.
f.MOUSE("r Select an rectangle area on the screen");
// f.MOUSEANS is two coordinate points
println!("status: {}\nmouse: {}", f.STATUS, f.MOUSEANS);
let params: HashMap<InfoParamType, String> = HashMap::<InfoParamType, String>::from([
(InfoParamType::EntityType, String::from("matrix")),
(InfoParamType::EntityPath, String::from("000/matrix")),
]);
// Info is essentially a COM command. It is a powerful and complex command interface, so a separate encapsulation has been made. Here is a demonstration of how to use info.
f.INFO(¶ms);
// The results of info are divided into two categories, here we view all single-value results.
f.print_doinfo_single_values();
// The results of info are divided into two categories, here we view all array results.
f.print_doinfo_array_values();
}
The public functions are:
VON, VOF, SU_ON, SU_OFF, PAUSE, MOUSE, COM, AUX, and INFO
For other script development assistance, please refer to the official Genesis2000 help document: 0204.pdf.