Questions tagged [graphics]

11761 questions
1

votes
2

answer
89

Views

OpenGL: Quads seemingly not culled properly

I have built a simple scene like the following: The problem is, the blue shape is lower than the red one but somehow bleeds through. It looks proper when I rotate it like the following: From what I searched this could be related to the order of vertices being sent, and here is my definition for thos...
SenselessCoder
1

votes
1

answer
244

Views

`UIBezierPath.fill()` does not fill inside of `draw()`

I'm cutting a rectangle out of a semi-transparent UIView. When I use UIRectFill() it works as expected. However when I create a UIBezierPath with rounded corners, fill() does not seem to do anything. Oddly, calling stroke() on that same path works fine. WORKS: override func draw(_ rect: CGRect) { s...
rob
1

votes
2

answer
241

Views

Place xticks and yticks in the pixel center on imshow plot

I am working with matplotlib to plot a heat map with some information and I want to move the xticks and the yticks to the center. I have searched in stackoverflow for previous questions but I couldn't reach one suitable for the problem. I attach my code and the image that I get: import matplotlib.p...
A.Piquer
1

votes
1

answer
468

Views

Assembly - How to set graphics mode in UEFI (No VGA, No BIOS, Nothing deprecated)

Tools I'm using: nasm, qemu-system-x86_64. Operating System I'm on: Windows 10. So I checked out the 'Real Mode OS Warning' at https://wiki.osdev.org/Real_Mode_OS_Warning What the article seems to imply is that everything can be done without using BIOS interrupts whatsoever. I know how to load Long...
Eagterrian Knight
1

votes
1

answer
28

Views

Problem when resizing and saving a turtle screen

So I could save a big drawing and see its full size in an image visualizer, I resized my turtle window bigger then my monitor size. But the saved image is not being resized, so the drawing is being truncated: from turtle import Screen, Turtle import random screen = Screen() screen.setup(width=1200,...
Vitor Oliveira
1

votes
1

answer
46

Views

Processing: persistence in transparent 3D object

Previously defined shape (triangle) appears but does not persist in 3D object (sphere) but does outside. The triangle appears in the transparent sphere but vanishes at the next rendering. For transparency, I used enabled DEPTH_SORT. // Aim of program: draw a stack of triangles that goes through a tr...
Alchemille
0

votes
0

answer
12

Views

How do I construct a matrix of vertices from 2 vectors?

I'm writing a game engine in C++ that interacts with Vulkan. In order for me to be able to draw anything on the screen, I need to write vertices. The game engine offers a slightly higher level interface to Vulkan, and it needs to be able to construct the vertices from a position Vector3 and a size V...
jdp_
0

votes
0

answer
4

Views

Creating screenshots on macOS Mojave without missing regions

I have some code to create screenshots. On High Sierra it worked without issues. However, it does not work anymore properly since I run it on Mojave. Some parts are cut out. I use this API call: CGImageRef screenshot = CGWindowListCreateImage (CGRectInfinite, kCGWindowListOptionOnScreenOnly, kCGNull...
tr4px
1

votes
1

answer
348

Views

In OpenGL, is there a way to blend based on a separate channel's value in the shader?

In OpenGL (not ES), is there a universal way to blend based a texture while drawing based on another texture or variable's value? On OpenGLES, I know that I can do custom blending on some platforms via extensions like GL_EXT_shader_framebuffer_fetch. The reason I ask, is that I have a special textur...
David
1

votes
2

answer
2.2k

Views

Generate pixel matrices from characters in string [duplicate]

This question already has an answer here: How to convert from alphabets to pixels 2 answers I'm in the process of writing a library that will print scrolling text across an LED matrix hooked up to a Raspberry Pi. I would like a function that takes a character, height and width and produces a matrix...
Alex
2

votes
0

answer
13

Views

Looking to add an AI player in Python Pong using Turtle

I can't seem to get my AI pong paddle to work in Python 3.7.1. I'll admit that I'm new to this so the fix may be easier than I'm making it. I've tried various forms of adjusting the loops but i think i'm missing something small that plays a big role in the code's processing. import turtle # build wi...
jnerdwell
5

votes
4

answer
108

Views

Is there a way to shorten my code so that I don't have to write “turtle.” every time I use functions from the turtle module?

I am trying to draw squares using turtle in python, and every time I want to command it to do something I must write turtle. import turtle turtle.forward(100) turtle.right(90) turtle.forward(100) turtle.right(90) turtle.forward(100) turtle.right(90) turtle.forward(100) turtle.right(90) turtle.back(1...
Braa najjar
1

votes
3

answer
39

Views

C# Rotated DrawString from Right Corner

I am trying to draw text on an image from top right corner towards the bottom left corner. My code mess up the positioning of drawstring. so far this code drawing like this but I need help to draw text between these red lines. string img_src = 'F:\\blank_imge.jpg'; System.Drawing.Image selected_img...
Arbaz Abid
1

votes
1

answer
48

Views

What does vk::DeviceQueueCreateFlags() actually do?

The C like way to initialize this structure is: VkDeviceQueueCreateInfo queueCreateInfo = {}; queueCreateInfo.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO; queueCreateInfo.queueFamilyIndex = queueFamily; queueCreateInfo.queueCount = 1; queueCreateInfo.pQueuePriorities = &queuePriority; The C++...
Makogan
1

votes
1

answer
36

Views

Linear interpolation for vertices to achieve faceted appearance in Metal

I was trying to make an artistic look with Metal. The effect to achieve is to render a faceted teapot based on triangle primitives, instead of a smooth and mellow teapot. I am not sure how I can do this. I know I should tell Metal to calculate pixels inside a triangle as if the triangle is planar, i...
jackxujh
1

votes
2

answer
1.8k

Views

How to add shadow to image programmatically in Android? [duplicate]

This question already has an answer here: Drawing an outer shadow when drawing an image 4 answers I have a number of various predefined shapes (geometric, animals, plants, signs, etc.), like the one attached, but without a shadow. Images, containing these shapes, can be saved either as assets or re...
Asahi
1

votes
0

answer
81

Views

R: capture a raster matrix of a plot, grid::grid.cap function not working

I'm trying to reproduce some grid package examples, specifically those which involve the grid.cap function, to 'capture' the current plot raster matrix. Examples here (Paul Murrell's article, Spanish flag example) and here. But grid.cap will simply not work for me as is, unless I open a new window w...
Giora Simchoni
1

votes
0

answer
33

Views

Why my second adapter does not show up?

Being bogged with the fact that few of the games and graphics applications run in my GPU (AMD Radeon 6600M) choosing instead the Intel HD3000, I wrote this small code to start investigating. #include #include #include int enumGraphicsAdapters( void* pFactory ) { int rc = ERROR_SUCCESS; HRESULT rc...
daniel.franzini
1

votes
1

answer
587

Views

How to set my screen boundaries on a turtle drawing

I have a set code here that I use to generate a unique image each time the code is run; how do I set it to only draw within the boundaries of my tkinter screen? Here is the code: import random import turtle maker=turtle.Turtle() maker.getscreen().delay(0) maker.getscreen().tracer(0) n=random.randin...
fantascey
1

votes
1

answer
138

Views

CAShapeLayer flipped coordinate while using with iOS11 vision

I'm playing with iOS 11vision framework to detect facial features like nose, eyes, lips etc. Vision frame work gives very accurate normalize points for all facial features. Now I'm trying to draw a red line over right eye with help of bezier path and below is the code I'm using to draw same. 1) addF...
Jay Savsani
1

votes
0

answer
33

Views

CGEventKeyboardSetUnicodeString() only processing up to 20 characters

This function is called with very long strings: void postBytes( UniChar *buf, UniCharCount len ) { CGEventSourceRef evtSrc = CGEventSourceCreate( kCGEventSourceStatePrivate ); CGEventRef keyEvtDown = CGEventCreateKeyboardEvent( evtSrc, 0, true ); CGEventKeyboardSetUnicodeString( keyEventDown, len, b...
C. Ocoa
1

votes
0

answer
25

Views

Drawing on CGContext with semi-tranparent color vs opaque color and setting alpha

This may be a simple question, but I couldn't figure it out from docs. Is there differnece between those two approaches? let context = makeContext() let color = CGColor(red: 1, green: 0, blue: 0, alpha: 0.5) context.setFillColor(color) and let context = makeContext() let color = CGColor(red: 1, gree...
Alfred Zien
1

votes
0

answer
16

Views

Is this the correct application of model transformation in computer graphics?

Suppose I want to perform translate in the following order: Scale by S Rotate by matrix R1 Rotate by matrix R2 Translate by T. When I apply the matrix, should the overall transformation matrix be: M = T x R1^-1 x R2^-1 x S or M = T x R2^-1 x R1^-1 x S I always thought the transformations should be...
oldselflearner1959
1

votes
0

answer
41

Views

Moving images on GUI

I'm currently doing a Connect Four game and I would appreciate any help with adding and moving the Game pieces. So I made the game piece into an image and want to add it to the game board which is a JLabel picture and then move the game piece on Y-axis. here's my code: import javax.swing.*; import...
Forrest Y
1

votes
0

answer
126

Views

What is the BSDF of the glass?

I am writing a path tracer. And I am ready to add more materials.I added a mirror like this : ` Spectrum MirrorBSDF::f(const Vector3D& wo, const Vector3D& wi) { return reflectance * (1.0 / abs_cos_theta(wo)); } ` But I do not know how to evaluate the BSDF of the glass material.Someone know? Thanks...
bin guo
1

votes
0

answer
64

Views

3D Graphics, Cube seems illogical

I designed a simple java program viewing 3D Cube, but i do not why i guess there is something illogically in that. the length of rib = 350 the front square depth (z axis) is 0 the back square depth (z axis) is equal to the length of rib, but the result was very tall cube !!: I designed a simple jav...
1

votes
1

answer
48

Views

Python Turtles , what am i doing wrong here?

So... i'm pretty much a beginner in the turtle module and i want to move all the turtles at the same time, but probably because they never stop moving, i can't move more than two, what can i do to improve that? Here's the code: (i do plan to make more 'colors' after the problem is solved) from turtl...
Matheus1102
1

votes
0

answer
93

Views

Start Path of RoundRect with DashPathEffect from center

I'm trying to draw a progress path using a DashPathEffect and path with a round rect. Every time a I get a progress update I update the path using the phase. private void updatePath(float phase) { path.reset(); RectF rect = new RectF(0, 0, getWidth(), getHeight()); rect.inset(progressInset, progres...
user3390695
1

votes
1

answer
44

Views

Where is the camera in OpenGL perspective projection?

I'm playing around with openGL and encounter a strange problem. Code that defines my frustum: glFrustum(0.0, 50.0, 0.0, 50.0, 5.0, 35.0); Code that generates the polygon and the curve glBegin(GL_POLYGON); // a rectangle glVertex3f(20.0, 20.0, -6.0); glVertex3f(20.0, 20.0, -10.0); glVertex3f(20.0,...
Manh Nguyen Huu
1

votes
2

answer
475

Views

CGPoint: Cannot call value of non-function type `[Float]`

I am developing an app, which should draw points when is touch, in the location of touch and when I have got 2 or more points, it should connect these points and fill up the new object. override func touchesBegan(_ touches: Set, with event: UIEvent?) { if(draw == true){ for touch in touches { let l...
Josef
1

votes
0

answer
213

Views

Rasterize plot when using PDF output device

Hello everybody out there using R, When putting multiple plots with thousands of data points into a single PDF file, this file can get huge and take a long time to open. The following post describes exactly the same problem in Matplotlib, as well as a nice fix for it: Matplotlib: multipage PDF with...
NicolasBourbaki
1

votes
0

answer
399

Views

Drawing an Archimedean spiral with lines and tightness parameters using Java

This uses a library called StdDraw to draw a line. I'm trying to make a spiral drawing method that takes in the center coordinates, the number of line segments to use, the maximum radius and the 'tightness' of the spiral (spinRate). Here is my code so far: public void spiral(double x0, double y0, d...
weztex
2

votes
2

answer
26

Views

Is there a way to shortening my code as I have to write “turtle.” every time I use functions

I am trying to draw squares using turtle in python, and every time I want to command it to do something I must write turtle. import turtle turtle.forward(100) turtle.right(90) turtle.forward(100) turtle.right(90) turtle.forward(100) turtle.right(90) turtle.forward(100) turtle.right(90) turtle.back(1...
Braa najjar
1

votes
0

answer
63

Views

Loading a BufferedImage from a png and preserving transparency

I'm essentially stacking multiple JPanels on top of each other on a JFrame to simulate how layers would work in an image editing program. Each has a BufferedImage of a png file that has transparency. As far as I understand, in order to make the BufferedImage have the same transparent areas as the pn...
Moribus
1

votes
0

answer
88

Views

DrawString and TextBox same rendering

Inside OnPaint of a form I am rendering some text on top of an image. For that I call Graphics.DrawString with word wrapping enabled. In order to be able to edit the text I occasionally show (and hide again after editing) an additional TextBox occupying the same rectangle as my hand drawn text and a...
oliver
1

votes
0

answer
24

Views

Write text in the middle of the rectangle in line graph android

I am trying to print 'off' in a rectangle in the range where there is no data in the line chart. I draw a rectangle between the end point of the data in the graph and the first point where the data is re-rendered. But I can not write 'off' in the middle of the whole rectangle on each phone. On some...
user9318253
1

votes
0

answer
119

Views

Unstable line thickness using System.Drawing.Graphics

I'm trying to draw straight vertical lines with pen width of 1. The following method draws vertical grid lines of a line chart. public override void DrawGridLines(GDIGraphics graphics, Rectangle plotArea) { using (Pen pen = new Pen(gridLineColor, gridLineThickness)) { float x = plotArea.Right - 1; f...
Pavieł Kraskoŭski
1

votes
0

answer
37

Views

Imagick doesn't resize vector GIFs correctly PHP

I'm using imagick for image uploads and resizing. when I try to resize GIF image with vector graphics it won't resize as original. but normal animated giphys are woring. please advice https://giphy.com/explore/vector-design these giphs are not resizing with correct animation. below is my code. $ima...
1

votes
0

answer
97

Views

Quality issue while printing with a thermal line printer from files

I've got a thermal line printer, an Epson T88V, and I'm having problems while I try to print from files. I'm developing a C# module that is going to form/draw image files in a cloud, then send them to a driver installed on a remote computer through net, and then this driver(also developed by me) wil...
Alvaro Tauroni
1

votes
1

answer
32

Views

Closing a graphics window whenever the user wants it to

I have this program that makes dots move from the top to the bottom: import graphics import random window = graphics.GraphWin('Snow!', 400, 400) window.setBackground('skyblue') flakes = [] for i in range(500):#generates snow x = random.randint(0, 400) y = random.randint(0, 400) p = graphics.Point(x,...
Aleks. S.

View additional questions