
Research
/Security News
9 Malicious NuGet Packages Deliver Time-Delayed Destructive Payloads
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.
@onemorestudio/dragdrop-texture
Advanced tools
A creative module for drag and drop media handling with texture capabilities for HTML5 canvas and creative coding
A creative module for drag and drop media handling with texture capabilities for HTML5 canvas and creative coding applications.
npm install @onemorestudio/dragdrop-texture
import { DragDropTexture } from "@onemorestudio/dragdrop-texture";
// Basic usage
const dragDrop = new DragDropTexture({
dropZone: document.body,
onDrop: (file, media) => {
console.log("Media loaded:", file.name);
},
onTextureUpdate: (textureCanvas) => {
// Access texture data
const imageData = textureCanvas.getImageData();
console.log("Texture updated:", imageData);
},
});
Main class that handles drag and drop functionality with texture processing.
const options = {
dropZone: HTMLElement, // Drop zone element (default: document.body)
acceptedTypes: string[], // Accepted MIME types (default: ['image/*', 'video/*'])
autoPlay: boolean, // Auto-play videos (default: true)
muted: boolean, // Mute videos (default: true)
loop: boolean, // Loop videos (default: true)
onDrop: function, // Callback when media is dropped
onTextureUpdate: function, // Callback when texture updates
onError: function // Error callback
};
// Load media programmatically
await dragDrop.loadMedia(file);
// Get texture data
const imageData = dragDrop.getTextureData();
const dataURL = dragDrop.getTextureDataURL("image/png", 1.0);
// Get pixel information
const pixel = dragDrop.getPixelAt(100, 100);
console.log(pixel); // { r: 255, g: 0, b: 0, a: 255, rgba: "rgba(255, 0, 0, 1)" }
// Access canvas and media elements
const canvas = dragDrop.getCanvas();
const media = dragDrop.getMedia();
// Fullscreen controls
dragDrop.showFullscreen();
dragDrop.hideFullscreen();
dragDrop.toggleFullscreen();
// Cleanup
dragDrop.destroy();
Handles canvas operations for texture processing.
import { TextureCanvas } from "@onemorestudio/dragdrop-texture";
const textureCanvas = new TextureCanvas();
await textureCanvas.setMedia(mediaElement);
// Get texture information
const dimensions = textureCanvas.getDimensions();
const averageColor = textureCanvas.getAverageColor();
// Apply filters
textureCanvas.applyFilter("blur(5px)");
textureCanvas.applyFilter("brightness(150%)");
Handles loading and processing of media files.
import { MediaHandler } from "@onemorestudio/dragdrop-texture";
const mediaHandler = new MediaHandler();
const mediaElement = await mediaHandler.loadFile(file);
// Get media information
const info = mediaHandler.getMediaInfo(mediaElement);
// Video controls
await mediaHandler.playVideo(videoElement);
mediaHandler.pauseVideo(videoElement);
mediaHandler.setVideoTime(videoElement, 10); // Seek to 10 seconds
import { DragDropTexture } from "@onemorestudio/dragdrop-texture";
class CreativeSketch extends DragDropTexture {
constructor() {
super({
onTextureUpdate: (textureCanvas) => {
this.processTexture(textureCanvas);
},
});
this.setupCanvas();
}
setupCanvas() {
this.displayCanvas = document.createElement("canvas");
this.displayCtx = this.displayCanvas.getContext("2d");
document.body.appendChild(this.displayCanvas);
}
processTexture(textureCanvas) {
const imageData = textureCanvas.getImageData();
if (!imageData) return;
// Process pixels for creative effects
const data = imageData.data;
for (let i = 0; i < data.length; i += 4) {
// Apply creative transformations
data[i] = 255 - data[i]; // Invert red
data[i + 1] = 255 - data[i + 1]; // Invert green
data[i + 2] = 255 - data[i + 2]; // Invert blue
}
// Draw processed texture
this.displayCtx.putImageData(imageData, 0, 0);
}
}
const sketch = new CreativeSketch();
import { DragDropTexture } from "@onemorestudio/dragdrop-texture";
class WebGLTexture extends DragDropTexture {
constructor(gl) {
super({
onTextureUpdate: (textureCanvas) => {
this.updateWebGLTexture(textureCanvas.canvas);
},
});
this.gl = gl;
this.texture = gl.createTexture();
}
updateWebGLTexture(canvas) {
const gl = this.gl;
gl.bindTexture(gl.TEXTURE_2D, this.texture);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, canvas);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
}
}
import { DragDropTexture } from "@onemorestudio/dragdrop-texture";
const analyzer = new DragDropTexture({
onDrop: (file, media) => {
// Analyze dominant colors
setTimeout(() => {
const averageColor = analyzer.textureCanvas.getAverageColor();
console.log("Average color:", averageColor.rgba);
// Sample pixels across the image
const canvas = analyzer.getCanvas();
const samples = [];
for (let x = 0; x < canvas.width; x += 50) {
for (let y = 0; y < canvas.height; y += 50) {
const pixel = analyzer.getPixelAt(x, y);
if (pixel) samples.push(pixel);
}
}
console.log("Color samples:", samples);
}, 100);
},
});
The module adds CSS classes that you can style:
/* Style the drag highlight effect */
.dragdrop-highlight {
border: 2px dashed #007bff;
background-color: rgba(0, 123, 255, 0.1);
}
/* Customize the fullscreen overlay */
.dragdrop-fullscreen-overlay {
background: rgba(0, 0, 0, 0.95) !important;
}
FAQs
A creative module for drag and drop media handling with texture capabilities for HTML5 canvas and creative coding
The npm package @onemorestudio/dragdrop-texture receives a total of 6 weekly downloads. As such, @onemorestudio/dragdrop-texture popularity was classified as not popular.
We found that @onemorestudio/dragdrop-texture demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
/Security News
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.

Security News
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.