Scarpet图形 (scarpet-graphics)
这是一个scarpet的扩展插件,用于在没有图形界面的情况下进行图像处理,它是Processing的包装器。同时,它还可以与Discarpet一起使用,将创建的图像通过Discord发送。
值
这个扩展添加了以下新的scarpet值:
* `image`: [PImage](
* `graphics`: [PGraphics](
* `font`: [PFont](
颜色使用编号(十六进制的0xRRGGBBAA)来处理,但可以使用`color`函数从RGB和HSB构建。
函数
**更详细的文档请参阅[Processing参考](
大多数函数只是内部processing函数的包装函数。有时,它们可能与原始Processing函数的名称略有不同,这是因为该名称已被scarpet使用(例如`copy()`)或者为了对它们进行分组(所有`draw_?()`函数)。
### 图形和图像函数
#### `load_image(location)`
从指定的`location`(字符串)加载图像。可以是URL或文件路径(绝对路径,不像scarpet的`read_file`那样工作)。返回一个`image`值。
#### `save_image(image, location)`
将`image`保存在指定的`location`(也是绝对路径)。
#### `create_graphics(width, height)`
创建具有指定尺寸的新`graphics`对象。
#### `copy_image(source, desination, sourceX, sourceY, sourceW, sourceH, destinationX, destinationY, destinationW, destinationH)`
从一个图像/图形复制像素到另一个。
#### `get_pixel(image, x, y)`
返回特定像素的颜色。
#### `set_pixel(image, x, y, color)`
将图像上的像素设置为指定的颜色。
#### `begin_draw(graphics)`
准备图形对象以在其上进行绘制操作。
#### `end_draw(graphics)`
绘制完成后调用。
### 绘图函数
参见Processing参考中的[2D基元](
#### `draw_background(graphics, color)`
#### `draw_rect(graphics, a, b, c, d)`
#### `draw_ellipse(graphics, a, b, c, d)`
#### `draw_line(graphics, x1, y1, x2, y2)`
#### `draw_image(graphics, a, b, c, d)`
#### `draw_text(graphics, text, x, y)`
### 模式函数
#### `color_mode(graphics, mode)`
`mode`:`'RGB'`,`'HSB'`
#### `image_mode(graphics, mode)`
`mode`:`'CORNER'`,`'CORNERS'`,`'CENTER'`
#### `ellipse_mode(graphics, mode)`
`mode`:`'CORNER'`,`'CORNERS'`,`'CENTER'`,`'RADIUS'`
#### `rect_mode(graphics, mode)`
`mode`:`'CORNER'`,`'CORNERS'`,`'CENTER'`,`'RADIUS'`
### 工具函数
#### `color(graphics, v1, v2, v3, alpha)`
根据设置的`color_mode()`,v1,v2,v3是r,g,b或h,s,b值
#### `fill(graphics, color)`
#### `no_fill(graphics)`
#### `stroken(graphics, color)`
#### `no_stroke(graphics)`
#### `stroke_weight(graphics, weight)`
#### `smooth(graphics)`
#### `no_smooth(graphics)`
#### `font_list()` (等同于processing中的PFont.list())
#### `text_font(graphics, font)`
#### `text_size(graphics, size)`
#### `create_font(graphics, name, size, smooth?)`
#### `text_align(graphics, alignX, alignY)`
截图:
0.1.6
0.1.5
0.1.4
收录