crayon brush effect in processing - html

I was trying to implement a crayon brush for drawing in processing canvas. This tutorial did the thing using HTML5 canvas. So far, the logic seems to be loading a transparent crayon texture over a particular color. How to achieve this effect in processing?

You could do something like it by creating an image of what you want the crayon to be like, a .PNG whit transparent background, the color and texture of the crayon, all in a circle shape.
Then you just have to draw that image on the method onMousePressed().
Regards

Related

Animated Mesh Gradient with CSS

I want to make a background animated gradient like this ones protoyped on Figma.
Picture of Animated Gradient
I saw some solutions of animated gradients in CSS like the one of this page, but it only generates a common linear-gradient and changes the background position.
What i'm looking for is a mesh gradient like the Figma examples (is builted with shapes, a blur layer and some noise) and animate it like the Figma prototype.
It can be done with pure CSS? or what could be a nice solution?
You'd definitely need something alongside CSS to animate it like you desire, JS would be a good bet. This is really a project in itself, but take a look at What a Mesh. It does what you're looking for, I don't think it's actually available for public/commercial use, but you might get some inspiration for how to approach it.
https://whatamesh.vercel.app/

Pygame collision detection, transparent border

For my pygame project, I must detect collision betweeen various .png image that move on the screen.
I have put the image inside sprite, and the sprite inside group, then I use this :
pygame.sprite.spritecollide(perso, zombie_group, False)
However, sometime, my image don't touch, but pygame detect a collision...
This is due to the fact that my images are png with transparent borders.
The transparent border collide, and pygame detect this :(
Any idea to stop the transparent border from colliding ?
Ok the sprite will take the image he can't detect if it was on a trasnparent BG or a color bg, he basically is just seeing a rectangle right now.
If you are using irregular shapes and a rectangle approximation is not enough I would recommend using collide_mask also check masks it is probably what you want
update
Regarding performance from the tutorial :
There are other ways to do this, with ANDing sprite masks and so on,
but any way you do it in pygame, it’s probably going to be too slow.
For most games, it’s probably better just to do ‘sub-rect collision’ –
create a rect for each sprite that’s a little smaller than the actual
image, and use that for collisions instead. It will be much faster,
and in most cases the player won’t notice the inprecision.

How do I create collision detection with an object and part of a background?

I am just starting to attempt to make my own game using java and libgdx, and the extent of my success so far has been showing the background image on screen, and spawning a little square the user controls with WASD. The background is just a solid color, with a vertical rectangle that is red inside and has black edges. I want to make it so the tiny square (player) can move anywhere within the red rectangle, but not be able to cross over the black edges (out of the rectangle). How would I go about doing this?
Since I am a complete beginner to this stuff I must ask these related questions...
Should the player be just a texture? Should the background be a texture? or a sprite?
I'm not sure the difference between the two yet.
I recommand you to read tutorials about libGDX and Box2D like this one : http://www.gamefromscratch.com/post/2014/08/27/LibGDX-Tutorial-13-Physics-with-Box2D-Part-1-A-Basic-Physics-Simulations.aspx
to answer you're questions, in short :
a texture is an image in memory
a sprite is a part of a texture (or the whole texture) transformed (translation, scale, rotation) to be drawn on screen.
so basically, in the view model, your player is represented by a sprite, your background is a sprite as well.
Player 1 and 2 are 2 different sprites but may reffer to the same texture (bitmap).
with box2D, in the physics model, your player will be represented as a dynamic body and your background as a static body.

Difficulty Converting .png to CSS Sprite

I am attempting to convert this Star Wars image file to Sprite so that I can use several of the individual drawings. However, it seems that I can only use Sprite if the background is not completely white, but rather a checkered white-grey pattern (not sure why this is?). Is there a way to convert the file into a Sprite image? I attempted ZeroSprites.com, but it still gave me the white background; I'd like to be able to render each of the drawings without the white background so that the characters' outlines blend in smoothly into my main background.
Thanks!
It's best if you have the images as vector and export it as .png
Removing white background is possible but it won't be as good as the original.
You can follow this video tutorial: https://www.youtube.com/watch?v=SV38L4c4JKY
Here's the same image as png:
http://cubeupload.com/im/cSEdTC.png

Circle shaped texture libGdx

I've been searching for answer for about 2 hours now and I haven't found my desired answer. My question is, Is it possible, and how, to draw a circle-shaped texture, so that outside the circle, texture would be transparent, is it even possible?
Thanks in advance! This site has been a great help so far!
The easiest way is to open a program like Photoshop and make an image with an alpha-channel. That means: Start with a completely transparent image and draw a circle on it. Then save it as .png
You can then just load it in your game and render it using a SpriteBatch. It (or better your graphics card) knows how to handle the alphachannel and will keep everything but the circle completely invisible.
This way you do not have to manipulate any pixmaps at runtime and you are not limited to simple shapes like circles.
If the portion of the texture you want to see in the circle is not meant to change during execution, the easiest way is to open Photoshop, make what you want, export it as an image and then load it in a Texture or a Sprite object in your code.
But this can also be done at runtime, via OpenGL using a Stencil test. This is the only solution if the portion displayed in the circle will have to be alterable during execution.
pixmap use this link if u are using other than .png format for your images
Apart form it if you are using png images then just draw the cirlce. Outside the circle will remain transparent.