apexify.js 5.0.3 → 5.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +352 -137
- package/README.md +440 -19
- package/dist/cjs/Canvas/ApexPainter.d.ts +272 -0
- package/dist/cjs/Canvas/ApexPainter.d.ts.map +1 -1
- package/dist/cjs/Canvas/ApexPainter.js +2275 -125
- package/dist/cjs/Canvas/ApexPainter.js.map +1 -1
- package/dist/cjs/Canvas/utils/Custom/advancedLines.d.ts +4 -4
- package/dist/cjs/Canvas/utils/Custom/advancedLines.d.ts.map +1 -1
- package/dist/cjs/Canvas/utils/Custom/advancedLines.js +63 -21
- package/dist/cjs/Canvas/utils/Custom/advancedLines.js.map +1 -1
- package/dist/cjs/Canvas/utils/Custom/customLines.d.ts.map +1 -1
- package/dist/cjs/Canvas/utils/Custom/customLines.js +3 -0
- package/dist/cjs/Canvas/utils/Custom/customLines.js.map +1 -1
- package/dist/cjs/Canvas/utils/types.d.ts +5 -1
- package/dist/cjs/Canvas/utils/types.d.ts.map +1 -1
- package/dist/cjs/Canvas/utils/types.js.map +1 -1
- package/dist/esm/Canvas/ApexPainter.d.ts +272 -0
- package/dist/esm/Canvas/ApexPainter.d.ts.map +1 -1
- package/dist/esm/Canvas/ApexPainter.js +2275 -125
- package/dist/esm/Canvas/ApexPainter.js.map +1 -1
- package/dist/esm/Canvas/utils/Custom/advancedLines.d.ts +4 -4
- package/dist/esm/Canvas/utils/Custom/advancedLines.d.ts.map +1 -1
- package/dist/esm/Canvas/utils/Custom/advancedLines.js +63 -21
- package/dist/esm/Canvas/utils/Custom/advancedLines.js.map +1 -1
- package/dist/esm/Canvas/utils/Custom/customLines.d.ts.map +1 -1
- package/dist/esm/Canvas/utils/Custom/customLines.js +3 -0
- package/dist/esm/Canvas/utils/Custom/customLines.js.map +1 -1
- package/dist/esm/Canvas/utils/types.d.ts +5 -1
- package/dist/esm/Canvas/utils/types.d.ts.map +1 -1
- package/dist/esm/Canvas/utils/types.js.map +1 -1
- package/lib/Canvas/ApexPainter.ts +2973 -136
- package/lib/Canvas/utils/Custom/advancedLines.ts +77 -25
- package/lib/Canvas/utils/Custom/customLines.ts +4 -0
- package/lib/Canvas/utils/types.ts +6 -2
- package/package.json +1 -3
package/README.md
CHANGED
|
@@ -4,18 +4,153 @@
|
|
|
4
4
|
|
|
5
5
|

|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
**🚀 One Library. Infinite Possibilities. Professional Results.**
|
|
8
8
|
|
|
9
9
|
[](https://badge.fury.io/js/apexify.js)
|
|
10
10
|
[](https://www.npmjs.com/package/apexify.js)
|
|
11
11
|
[](https://www.typescriptlang.org/)
|
|
12
12
|
[](https://nodejs.org/)
|
|
13
|
+
[](https://nextjs.org/)
|
|
14
|
+
[](https://discord.com/)
|
|
13
15
|
[](LICENSE)
|
|
14
16
|
|
|
15
|
-
|
|
17
|
+
**The most powerful, versatile canvas rendering library for Node.js, Next.js, Discord bots, and beyond.**
|
|
18
|
+
|
|
19
|
+
*Create stunning visuals, generate images on-the-fly, build design tools, and power your applications with professional-grade canvas rendering and image processing.*
|
|
16
20
|
|
|
17
21
|
</div>
|
|
18
22
|
|
|
23
|
+
## 🌟 Why ApexPainter?
|
|
24
|
+
|
|
25
|
+
**ApexPainter is not just another canvas library** - it's a complete visual creation toolkit that works everywhere:
|
|
26
|
+
|
|
27
|
+
- ✅ **Next.js** - Perfect for both frontend and backend image generation
|
|
28
|
+
- ✅ **Discord Bots** - Create dynamic images, welcome cards, level-up cards, and more
|
|
29
|
+
- ✅ **Server-Side Rendering** - Generate images in API routes, server actions, and edge functions
|
|
30
|
+
- ✅ **Design Tools** - Build Photoshop-like applications with code export capabilities
|
|
31
|
+
- ✅ **Web Applications** - Power your websites with dynamic image generation
|
|
32
|
+
- ✅ **Automation** - Batch process images, create thumbnails, generate social media assets
|
|
33
|
+
- ✅ **E-commerce** - Generate product images, banners, and marketing materials
|
|
34
|
+
- ✅ **Social Media** - Create profile pictures, cover images, and post graphics
|
|
35
|
+
- ✅ **Gaming** - Generate game assets, UI elements, and character cards
|
|
36
|
+
- ✅ **Business** - Create business cards, certificates, and professional documents
|
|
37
|
+
|
|
38
|
+
**One library. Every use case. Zero compromises.**
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## 🎯 Perfect For
|
|
43
|
+
|
|
44
|
+
### 🚀 **Next.js Applications**
|
|
45
|
+
Generate images in your Next.js app - both client and server-side. Perfect for:
|
|
46
|
+
- **API Routes**: Generate images on-demand via API endpoints
|
|
47
|
+
- **Server Actions**: Create images in server-side functions
|
|
48
|
+
- **Static Generation**: Pre-generate images at build time
|
|
49
|
+
- **Edge Functions**: Lightweight image generation at the edge
|
|
50
|
+
- **ISR (Incremental Static Regeneration)**: Update images dynamically
|
|
51
|
+
|
|
52
|
+
```typescript
|
|
53
|
+
// Next.js API Route Example
|
|
54
|
+
// app/api/generate-image/route.ts
|
|
55
|
+
import { ApexPainter } from 'apexify.js';
|
|
56
|
+
import { NextResponse } from 'next/server';
|
|
57
|
+
|
|
58
|
+
export async function GET() {
|
|
59
|
+
const painter = new ApexPainter();
|
|
60
|
+
const canvas = await painter.createCanvas({
|
|
61
|
+
width: 1200,
|
|
62
|
+
height: 630,
|
|
63
|
+
gradientBg: {
|
|
64
|
+
type: 'linear',
|
|
65
|
+
colors: [
|
|
66
|
+
{ stop: 0, color: '#667EEA' },
|
|
67
|
+
{ stop: 1, color: '#764BA2' }
|
|
68
|
+
]
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
return new NextResponse(canvas.buffer, {
|
|
72
|
+
headers: { 'Content-Type': 'image/png' }
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### 🤖 **Discord Bots**
|
|
78
|
+
Create stunning visuals for your Discord bot:
|
|
79
|
+
- **Welcome Cards**: Personalized welcome images for new members
|
|
80
|
+
- **Level-Up Cards**: Celebrate user achievements with custom graphics
|
|
81
|
+
- **Profile Cards**: Generate user profile images with stats
|
|
82
|
+
- **Leaderboards**: Visual leaderboard images
|
|
83
|
+
- **Custom Commands**: Generate images on-demand via slash commands
|
|
84
|
+
- **Event Graphics**: Create event banners and announcements
|
|
85
|
+
|
|
86
|
+
```typescript
|
|
87
|
+
// Discord Bot Example (discord.js)
|
|
88
|
+
import { ApexPainter } from 'apexify.js';
|
|
89
|
+
import { AttachmentBuilder } from 'discord.js';
|
|
90
|
+
|
|
91
|
+
const painter = new ApexPainter();
|
|
92
|
+
const canvas = await painter.createCanvas({
|
|
93
|
+
width: 800,
|
|
94
|
+
height: 400,
|
|
95
|
+
customBg: { source: userAvatar },
|
|
96
|
+
// Add welcome text, decorations, etc.
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
const attachment = new AttachmentBuilder(canvas.buffer, { name: 'welcome.png' });
|
|
100
|
+
await channel.send({ files: [attachment] });
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### 🎨 **Design Tools & Photoshop-Like Apps**
|
|
104
|
+
Build powerful design applications:
|
|
105
|
+
- **Visual Design Editors**: Create drag-and-drop design tools
|
|
106
|
+
- **Code Export**: Convert visual designs into ApexPainter code
|
|
107
|
+
- **Template Systems**: Pre-built templates for common designs
|
|
108
|
+
- **Layer Management**: Complex compositions with multiple layers
|
|
109
|
+
- **Export Options**: Multiple formats (PNG, JPEG, WebP, AVIF)
|
|
110
|
+
- **Batch Processing**: Process multiple designs at once
|
|
111
|
+
|
|
112
|
+
```typescript
|
|
113
|
+
// Design Tool with Code Export
|
|
114
|
+
const design = {
|
|
115
|
+
canvas: { width: 1920, height: 1080, colorBg: '#ffffff' },
|
|
116
|
+
elements: [
|
|
117
|
+
{ type: 'shape', source: 'rectangle', x: 100, y: 100, /* ... */ },
|
|
118
|
+
{ type: 'text', text: 'Hello World', x: 200, y: 200, /* ... */ }
|
|
119
|
+
]
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
// Generate code from design
|
|
123
|
+
const code = generateApexPainterCode(design);
|
|
124
|
+
// Export as: await painter.createCanvas(...)
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### 🌐 **Web Applications**
|
|
128
|
+
Power your websites with dynamic image generation:
|
|
129
|
+
- **OG Images**: Generate Open Graph images for social sharing
|
|
130
|
+
- **Thumbnails**: Auto-generate thumbnails for content
|
|
131
|
+
- **Banners**: Create dynamic banners and headers
|
|
132
|
+
- **User Avatars**: Generate custom avatars with initials
|
|
133
|
+
- **Charts & Graphs**: Visualize data with beautiful charts
|
|
134
|
+
- **QR Codes**: Generate QR codes with custom styling
|
|
135
|
+
|
|
136
|
+
### 📱 **Social Media & Marketing**
|
|
137
|
+
Create professional marketing materials:
|
|
138
|
+
- **Social Media Posts**: Generate posts for Instagram, Twitter, Facebook
|
|
139
|
+
- **Story Graphics**: Create engaging story images
|
|
140
|
+
- **Banner Ads**: Design eye-catching banner advertisements
|
|
141
|
+
- **Email Graphics**: Generate images for email campaigns
|
|
142
|
+
- **Product Images**: Create product showcases and catalogs
|
|
143
|
+
|
|
144
|
+
### 🎮 **Gaming Applications**
|
|
145
|
+
Generate game assets and UI elements:
|
|
146
|
+
- **Character Cards**: Create character profile cards
|
|
147
|
+
- **Achievement Badges**: Design achievement and trophy graphics
|
|
148
|
+
- **Game UI**: Generate UI elements and HUD components
|
|
149
|
+
- **Loading Screens**: Create dynamic loading screen graphics
|
|
150
|
+
- **Leaderboards**: Visual leaderboard displays
|
|
151
|
+
|
|
152
|
+
---
|
|
153
|
+
|
|
19
154
|
## ✨ Features Overview
|
|
20
155
|
|
|
21
156
|
### 🖼️ **Advanced Image Processing**
|
|
@@ -67,6 +202,35 @@
|
|
|
67
202
|
- **Chain Operations**: Chain operations sequentially for complex workflows
|
|
68
203
|
- **Advanced File Saving**: Save buffers to local files with smart naming, format conversion, and batch support
|
|
69
204
|
|
|
205
|
+
### 🎬 **Comprehensive Video Processing** (v5.2.0+)
|
|
206
|
+
- **Frame Extraction**: Extract single frames, multiple frames, or all frames from videos
|
|
207
|
+
- **Video Information**: Get video metadata (duration, resolution, FPS, bitrate, codec)
|
|
208
|
+
- **Thumbnail Generation**: Create grid thumbnails with multiple frames
|
|
209
|
+
- **Format Conversion**: Convert videos between MP4, WebM, AVI, MOV, MKV
|
|
210
|
+
- **Video Trimming**: Cut and trim video segments
|
|
211
|
+
- **Audio Extraction**: Extract audio tracks (MP3, WAV, AAC, OGG)
|
|
212
|
+
- **Watermarking**: Add image watermarks to videos with position and opacity control
|
|
213
|
+
- **Speed Control**: Change video playback speed (slow motion, fast forward)
|
|
214
|
+
- **Preview Generation**: Generate preview frames for video browsing
|
|
215
|
+
- **Video Effects**: Apply filters (blur, brightness, contrast, saturation, grayscale, sepia, invert, sharpen, noise)
|
|
216
|
+
- **Video Merging**: Concatenate videos sequentially, side-by-side, or in grids
|
|
217
|
+
- **Rotation & Flipping**: Rotate videos (90°, 180°, 270°) and flip horizontally/vertically
|
|
218
|
+
- **Video Cropping**: Crop videos to specific regions
|
|
219
|
+
- **Compression**: Optimize video file sizes with quality presets
|
|
220
|
+
- **Text Overlays**: Add text/subtitles to videos with positioning and timing
|
|
221
|
+
- **Fade Effects**: Add fade in/out transitions
|
|
222
|
+
- **Reverse Playback**: Reverse video and audio playback
|
|
223
|
+
- **Video Loops**: Create seamless video loops
|
|
224
|
+
- **Batch Processing**: Process multiple videos with different operations
|
|
225
|
+
- **Scene Detection**: Automatically detect scene changes
|
|
226
|
+
- **Video Stabilization**: Reduce camera shake and stabilize shaky footage
|
|
227
|
+
- **Color Correction**: Professional color grading (brightness, contrast, saturation, hue, temperature)
|
|
228
|
+
- **Picture-in-Picture**: Add overlay videos with position, size, and opacity control
|
|
229
|
+
- **Split Screen**: Create side-by-side, top-bottom, or grid layouts with multiple videos
|
|
230
|
+
- **Time-lapse Creation**: Speed up videos to create time-lapse effects
|
|
231
|
+
- **Audio Control**: Mute videos or adjust audio volume
|
|
232
|
+
- **Format Detection**: Analyze video codec, container, and properties
|
|
233
|
+
|
|
70
234
|
---
|
|
71
235
|
|
|
72
236
|
## 🚀 Quick Start
|
|
@@ -74,9 +238,35 @@
|
|
|
74
238
|
### Installation
|
|
75
239
|
|
|
76
240
|
```bash
|
|
77
|
-
npm
|
|
241
|
+
# npm
|
|
242
|
+
npm install apexify.js
|
|
243
|
+
|
|
244
|
+
# yarn
|
|
245
|
+
yarn add apexify.js
|
|
246
|
+
|
|
247
|
+
# pnpm
|
|
248
|
+
pnpm add apexify.js
|
|
78
249
|
```
|
|
79
250
|
|
|
251
|
+
### Platform Support
|
|
252
|
+
|
|
253
|
+
✅ **Node.js** - Full support (v16+)
|
|
254
|
+
✅ **Next.js** - Frontend & Backend (App Router & Pages Router)
|
|
255
|
+
✅ **Discord.js** - Perfect for Discord bots
|
|
256
|
+
✅ **Express.js** - API endpoints and server-side rendering
|
|
257
|
+
✅ **Serverless** - AWS Lambda, Vercel, Netlify Functions
|
|
258
|
+
✅ **Docker** - Containerized applications
|
|
259
|
+
✅ **Edge Runtime** - Vercel Edge, Cloudflare Workers (with limitations)
|
|
260
|
+
|
|
261
|
+
### Works Everywhere
|
|
262
|
+
|
|
263
|
+
- 🖥️ **Server-Side**: Full feature support
|
|
264
|
+
- 🌐 **API Routes**: Generate images on-demand
|
|
265
|
+
- ⚡ **Edge Functions**: Lightweight image generation
|
|
266
|
+
- 🤖 **Discord Bots**: Dynamic image creation
|
|
267
|
+
- 🎨 **Design Tools**: Build visual editors
|
|
268
|
+
- 📱 **Web Apps**: Client and server-side rendering
|
|
269
|
+
|
|
80
270
|
### Basic Usage
|
|
81
271
|
|
|
82
272
|
```typescript
|
|
@@ -630,19 +820,6 @@ const buttonText = await painter.createText({
|
|
|
630
820
|
|
|
631
821
|
## 📚 API Reference
|
|
632
822
|
|
|
633
|
-
### Core Methods
|
|
634
|
-
|
|
635
|
-
| Method | Description | Parameters |
|
|
636
|
-
|--------|-------------|------------|
|
|
637
|
-
| `createCanvas()` | Create a new canvas with background | `CanvasConfig` |
|
|
638
|
-
| `createImage()` | Add shapes/images to canvas | `ImageProperties \| ImageProperties[]` |
|
|
639
|
-
| `createText()` | Add text to canvas | `TextProperties \| TextProperties[]` |
|
|
640
|
-
| `createChart()` | Generate charts | `ChartConfig` |
|
|
641
|
-
| `createGIF()` | Create animated GIFs | `GIFConfig` |
|
|
642
|
-
| `save()` | Save buffer to local file with advanced options | `Buffer, SaveOptions?` |
|
|
643
|
-
| `saveMultiple()` | Save multiple buffers in batch | `Buffer[], SaveOptions?` |
|
|
644
|
-
| `resetSaveCounter()` | Reset the save counter for naming | `void` |
|
|
645
|
-
|
|
646
823
|
### 🔄 **Flexible Parameters**
|
|
647
824
|
|
|
648
825
|
Both `createImage()` and `createText()` methods accept:
|
|
@@ -680,9 +857,37 @@ This allows you to add multiple elements in one call for better performance and
|
|
|
680
857
|
|
|
681
858
|
---
|
|
682
859
|
|
|
683
|
-
## 🆕 What's New
|
|
684
|
-
|
|
685
|
-
###
|
|
860
|
+
## 🆕 What's New
|
|
861
|
+
|
|
862
|
+
### 🎬 v5.2.0 - Comprehensive Video Processing Suite
|
|
863
|
+
|
|
864
|
+
#### 18 New Video Features
|
|
865
|
+
- 🎥 **Video Effects & Filters**: Apply professional filters (blur, brightness, contrast, saturation, grayscale, sepia, invert, sharpen, noise)
|
|
866
|
+
- 🔗 **Video Merging**: Concatenate videos sequentially, side-by-side, or in grid layouts
|
|
867
|
+
- 🔄 **Rotation & Flipping**: Rotate videos (90°, 180°, 270°) and flip horizontally/vertically
|
|
868
|
+
- ✂️ **Video Cropping**: Crop videos to specific regions with precise control
|
|
869
|
+
- 📦 **Video Compression**: Optimize video file sizes with quality presets and custom bitrate
|
|
870
|
+
- 📝 **Text Overlays**: Add text/subtitles to videos with 7 position options and time-based visibility
|
|
871
|
+
- 🌅 **Fade Effects**: Add fade in/out transitions at video start/end
|
|
872
|
+
- ⏪ **Reverse Playback**: Reverse video and audio playback
|
|
873
|
+
- 🔁 **Video Loops**: Create seamless video loops
|
|
874
|
+
- ⚡ **Batch Processing**: Process multiple videos with different operations
|
|
875
|
+
- 🎬 **Scene Detection**: Automatically detect scene changes with configurable threshold
|
|
876
|
+
- 📹 **Video Stabilization**: Reduce camera shake and stabilize shaky footage
|
|
877
|
+
- 🎨 **Color Correction**: Professional color grading (brightness, contrast, saturation, hue, temperature)
|
|
878
|
+
- 📺 **Picture-in-Picture**: Add overlay videos with position, size, and opacity control
|
|
879
|
+
- 🖼️ **Split Screen**: Create side-by-side, top-bottom, or grid layouts with multiple videos
|
|
880
|
+
- ⏱️ **Time-lapse Creation**: Speed up videos to create time-lapse effects
|
|
881
|
+
- 🔇 **Audio Control**: Mute videos or adjust audio volume
|
|
882
|
+
- 🔍 **Format Detection**: Analyze video codec, container, and properties
|
|
883
|
+
|
|
884
|
+
#### Enhanced Video Methods
|
|
885
|
+
- ✅ **Smart Audio Detection**: Automatically detects if videos have audio streams
|
|
886
|
+
- ✅ **Unified API**: All video features accessible through single `createVideo()` method
|
|
887
|
+
- ✅ **Better Error Handling**: Clear error messages with FFmpeg installation guides
|
|
888
|
+
- ✅ **Resource Management**: Automatic cleanup of temporary files
|
|
889
|
+
|
|
890
|
+
### 🎉 v5.0.0 - Major Feature Release
|
|
686
891
|
|
|
687
892
|
#### Background Enhancements
|
|
688
893
|
- ✨ **Video Backgrounds**: Use video frames as dynamic backgrounds
|
|
@@ -717,6 +922,222 @@ See [CHANGELOG.md](CHANGELOG.md) for complete details.
|
|
|
717
922
|
|
|
718
923
|
---
|
|
719
924
|
|
|
925
|
+
## 💼 Real-World Use Cases
|
|
926
|
+
|
|
927
|
+
### 🎯 **Next.js Image Generation API**
|
|
928
|
+
|
|
929
|
+
```typescript
|
|
930
|
+
// app/api/og-image/route.ts
|
|
931
|
+
import { ApexPainter } from 'apexify.js';
|
|
932
|
+
import { NextRequest, NextResponse } from 'next/server';
|
|
933
|
+
|
|
934
|
+
export async function GET(request: NextRequest) {
|
|
935
|
+
const searchParams = request.nextUrl.searchParams;
|
|
936
|
+
const title = searchParams.get('title') || 'Default Title';
|
|
937
|
+
|
|
938
|
+
const painter = new ApexPainter();
|
|
939
|
+
const canvas = await painter.createCanvas({
|
|
940
|
+
width: 1200,
|
|
941
|
+
height: 630,
|
|
942
|
+
gradientBg: {
|
|
943
|
+
type: 'linear',
|
|
944
|
+
colors: [
|
|
945
|
+
{ stop: 0, color: '#667EEA' },
|
|
946
|
+
{ stop: 1, color: '#764BA2' }
|
|
947
|
+
]
|
|
948
|
+
}
|
|
949
|
+
});
|
|
950
|
+
|
|
951
|
+
const image = await painter.createText({
|
|
952
|
+
text: title,
|
|
953
|
+
x: 600,
|
|
954
|
+
y: 315,
|
|
955
|
+
fontSize: 72,
|
|
956
|
+
bold: true,
|
|
957
|
+
color: '#FFFFFF',
|
|
958
|
+
textAlign: 'center'
|
|
959
|
+
}, canvas);
|
|
960
|
+
|
|
961
|
+
return new NextResponse(image, {
|
|
962
|
+
headers: { 'Content-Type': 'image/png' }
|
|
963
|
+
});
|
|
964
|
+
}
|
|
965
|
+
```
|
|
966
|
+
|
|
967
|
+
### 🤖 **Discord Bot Welcome Card**
|
|
968
|
+
|
|
969
|
+
```typescript
|
|
970
|
+
// discord-bot.ts
|
|
971
|
+
import { ApexPainter } from 'apexify.js';
|
|
972
|
+
import { Client, GatewayIntentBits, AttachmentBuilder } from 'discord.js';
|
|
973
|
+
|
|
974
|
+
const client = new Client({ intents: [GatewayIntentBits.GuildMembers] });
|
|
975
|
+
const painter = new ApexPainter();
|
|
976
|
+
|
|
977
|
+
client.on('guildMemberAdd', async (member) => {
|
|
978
|
+
// Create welcome card
|
|
979
|
+
const canvas = await painter.createCanvas({
|
|
980
|
+
width: 1024,
|
|
981
|
+
height: 500,
|
|
982
|
+
customBg: { source: './assets/welcome-bg.jpg' }
|
|
983
|
+
});
|
|
984
|
+
|
|
985
|
+
const image = await painter.createText([
|
|
986
|
+
{
|
|
987
|
+
text: `Welcome ${member.user.username}!`,
|
|
988
|
+
x: 512,
|
|
989
|
+
y: 200,
|
|
990
|
+
fontSize: 48,
|
|
991
|
+
bold: true,
|
|
992
|
+
color: '#FFFFFF',
|
|
993
|
+
textAlign: 'center'
|
|
994
|
+
},
|
|
995
|
+
{
|
|
996
|
+
text: `You are member #${member.guild.memberCount}`,
|
|
997
|
+
x: 512,
|
|
998
|
+
y: 280,
|
|
999
|
+
fontSize: 32,
|
|
1000
|
+
color: '#CCCCCC',
|
|
1001
|
+
textAlign: 'center'
|
|
1002
|
+
}
|
|
1003
|
+
], canvas);
|
|
1004
|
+
|
|
1005
|
+
const attachment = new AttachmentBuilder(image, { name: 'welcome.png' });
|
|
1006
|
+
await member.guild.systemChannel?.send({ files: [attachment] });
|
|
1007
|
+
});
|
|
1008
|
+
```
|
|
1009
|
+
|
|
1010
|
+
### 🎨 **Design Tool with Code Export**
|
|
1011
|
+
|
|
1012
|
+
```typescript
|
|
1013
|
+
// design-editor.ts
|
|
1014
|
+
import { ApexPainter } from 'apexify.js';
|
|
1015
|
+
|
|
1016
|
+
class DesignEditor {
|
|
1017
|
+
private painter = new ApexPainter();
|
|
1018
|
+
private design: any = { elements: [] };
|
|
1019
|
+
|
|
1020
|
+
// Add element to design
|
|
1021
|
+
addElement(element: any) {
|
|
1022
|
+
this.design.elements.push(element);
|
|
1023
|
+
}
|
|
1024
|
+
|
|
1025
|
+
// Render design
|
|
1026
|
+
async render() {
|
|
1027
|
+
const canvas = await this.painter.createCanvas(this.design.canvas);
|
|
1028
|
+
let buffer = canvas.buffer;
|
|
1029
|
+
|
|
1030
|
+
for (const element of this.design.elements) {
|
|
1031
|
+
if (element.type === 'shape') {
|
|
1032
|
+
buffer = await this.painter.createImage(element, buffer);
|
|
1033
|
+
} else if (element.type === 'text') {
|
|
1034
|
+
buffer = await this.painter.createText(element, buffer);
|
|
1035
|
+
}
|
|
1036
|
+
}
|
|
1037
|
+
|
|
1038
|
+
return buffer;
|
|
1039
|
+
}
|
|
1040
|
+
|
|
1041
|
+
// Export as ApexPainter code
|
|
1042
|
+
exportCode() {
|
|
1043
|
+
return `
|
|
1044
|
+
import { ApexPainter } from 'apexify.js';
|
|
1045
|
+
|
|
1046
|
+
const painter = new ApexPainter();
|
|
1047
|
+
const canvas = await painter.createCanvas(${JSON.stringify(this.design.canvas, null, 2)});
|
|
1048
|
+
${this.design.elements.map((el: any, i: number) =>
|
|
1049
|
+
`const step${i} = await painter.${el.type === 'shape' ? 'createImage' : 'createText'}(${JSON.stringify(el, null, 2)}, ${i === 0 ? 'canvas' : `step${i-1}`});`
|
|
1050
|
+
).join('\n')}
|
|
1051
|
+
`.trim();
|
|
1052
|
+
}
|
|
1053
|
+
}
|
|
1054
|
+
```
|
|
1055
|
+
|
|
1056
|
+
### 📊 **Dynamic Chart Generation**
|
|
1057
|
+
|
|
1058
|
+
```typescript
|
|
1059
|
+
// analytics-dashboard.ts
|
|
1060
|
+
import { ApexPainter } from 'apexify.js';
|
|
1061
|
+
|
|
1062
|
+
async function generateAnalyticsChart(data: number[]) {
|
|
1063
|
+
const painter = new ApexPainter();
|
|
1064
|
+
|
|
1065
|
+
const chart = await painter.createChart({
|
|
1066
|
+
chartType: 'bar',
|
|
1067
|
+
chartNumber: 1,
|
|
1068
|
+
data: {
|
|
1069
|
+
chartData: { width: 800, height: 400 },
|
|
1070
|
+
xLabels: data.map((_, i) => i),
|
|
1071
|
+
yLabels: [0, 25, 50, 75, 100],
|
|
1072
|
+
data: {
|
|
1073
|
+
xAxis: data.map((value, i) => ({
|
|
1074
|
+
label: `Day ${i + 1}`,
|
|
1075
|
+
value,
|
|
1076
|
+
position: { startsXLabel: i * 80, endsXLabel: (i + 1) * 80 }
|
|
1077
|
+
})),
|
|
1078
|
+
yAxis: data
|
|
1079
|
+
}
|
|
1080
|
+
}
|
|
1081
|
+
});
|
|
1082
|
+
|
|
1083
|
+
return chart;
|
|
1084
|
+
}
|
|
1085
|
+
```
|
|
1086
|
+
|
|
1087
|
+
### 🖼️ **Batch Image Processing**
|
|
1088
|
+
|
|
1089
|
+
```typescript
|
|
1090
|
+
// image-processor.ts
|
|
1091
|
+
import { ApexPainter } from 'apexify.js';
|
|
1092
|
+
|
|
1093
|
+
async function processUserUploads(images: string[]) {
|
|
1094
|
+
const painter = new ApexPainter();
|
|
1095
|
+
|
|
1096
|
+
// Process all images in parallel
|
|
1097
|
+
const results = await painter.batch(
|
|
1098
|
+
images.map(image => ({
|
|
1099
|
+
type: 'image' as const,
|
|
1100
|
+
config: {
|
|
1101
|
+
source: image,
|
|
1102
|
+
x: 0,
|
|
1103
|
+
y: 0,
|
|
1104
|
+
filters: [{ type: 'gaussianBlur', radius: 5 }],
|
|
1105
|
+
borderRadius: 20
|
|
1106
|
+
}
|
|
1107
|
+
}))
|
|
1108
|
+
);
|
|
1109
|
+
|
|
1110
|
+
// Save all processed images
|
|
1111
|
+
await painter.saveMultiple(results, {
|
|
1112
|
+
directory: './processed',
|
|
1113
|
+
prefix: 'processed-',
|
|
1114
|
+
naming: 'counter'
|
|
1115
|
+
});
|
|
1116
|
+
|
|
1117
|
+
return results;
|
|
1118
|
+
}
|
|
1119
|
+
```
|
|
1120
|
+
|
|
1121
|
+
---
|
|
1122
|
+
|
|
1123
|
+
## 🎓 Learning Resources
|
|
1124
|
+
|
|
1125
|
+
### 📺 **Video Tutorials**
|
|
1126
|
+
Comprehensive video series covering:
|
|
1127
|
+
- Getting started with ApexPainter
|
|
1128
|
+
- Next.js integration
|
|
1129
|
+
- Discord bot development
|
|
1130
|
+
- Building design tools
|
|
1131
|
+
- Advanced features and techniques
|
|
1132
|
+
|
|
1133
|
+
### 📚 **Documentation**
|
|
1134
|
+
- [Full API Reference](http://apexifyjs.jedi-studio.com)
|
|
1135
|
+
- [Examples Gallery](#examples)
|
|
1136
|
+
- [TypeScript Types](#typescript-support)
|
|
1137
|
+
- [Performance Guide](#performance)
|
|
1138
|
+
|
|
1139
|
+
---
|
|
1140
|
+
|
|
720
1141
|
## 🤝 Contributing
|
|
721
1142
|
|
|
722
1143
|
We welcome contributions! Here's how you can help:
|