scarpet-graphics

模组

· 作者 replaceitem

用于 Scarpet 的 Carpet 扩展,提供无头图像处理功能(Processing 的封装)

0 本站下载 0 关注 更新于 7 个月前

需要前置:Carpet

最新 0.1.7 · 26.3 · Fabric

一键开服(送7天)

scarpet-graphics

一个用于 scarpet 的 Processing 封装库。

此工具也可与 Discarpet 配合使用,以便通过 Discord 发送生成的图像。

值(Values)

该扩展添加了以下新的 scarpet 值:

  • image: PImage 的封装
  • graphics: PGraphics 的封装,继承自 image 值(意味着它可以像 image 一样被使用)
  • font: PFont 的封装

颜色使用数字处理(十六进制格式为 0xRRGGBBAA),但也可以使用 color 函数从 RGB 和 HSB 构建。

函数

有关这些函数的更详细文档,请参阅 Processing 参考 大多数函数仅仅是内部 Processing 函数的封装。 有时它们可能与原始 Processing 函数的名称略有不同,因为该名称已被 scarpet 占用(例如 copy()),或者为了归类它们(所有以 draw_?() 开头的函数)。

图形和图像函数

load_image(location, shared?)

从指定的 location(字符串)加载图像。 可以是 URL,也可以是文件名(路径的工作方式类似于 read_file)。 如果 shared 为 true,则使用共享应用存储。 返回一个 image 值。

save_image(image, location, shared?)

将 image 保存到指定的 location(工作方式同 load_image)。

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 Primitives(二维基本图形) 部分。(scarpet 函数在 Processing 函数名前添加了 draw_ 前缀)

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, image, a, b, c, d)

draw_text(graphics, text, x, y)

模式函数

color_mode(graphics, mode)

modes: 'RGB', 'HSB'

image_mode(graphics, mode)

modes: 'CORNER', 'CORNERS', 'CENTER'

ellipse_mode(graphics, mode)

modes: 'CORNER', 'CORNERS', 'CENTER', 'RADIUS'

rect_mode(graphics, mode)

modes: '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

0.0
暂无评分
5 星
0
4 星
0
3 星
0
2 星
0
1 星
0
我的评分

登录后参与评分

还没有评论,来抢沙发吧

评论配图

相似资源