Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize the related Operation of computer Graphics based on python win32setpixel api

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article introduces the relevant knowledge of "how to realize the operation of computer graphics based on python win32setpixel api". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Scan line filling process

Clipping process (the polygon is cropped in real time according to the mouse position, and the blue on the right is the cropped figure)

Why did you choose win32 api to draw?

The reason for choosing win32 is that I want to do something different. I prefer to draw an image directly on the monitor and look more geek than using D3 or Echarts as a webGL implementation. This also led to the screencap software can not capture, can only use the mobile phone to record?

Why choose python instead of C++?

Mainly python can do a management of memory, C++ directly adjust this underlying interface will damage the memory, causing the computer to become particularly stuck. If you don't believe it, you can compile and run this code on your computer for 2 minutes and try it. If your computer doesn't explode, you have money.

# include / / Gmail + a.cpp-o a.exe-lgdi32 & & a.exevoid bresenham (int x0 abs int x1) {int dx = abs (x1-x0); int dy = abs (y1-y0) Int sx = x0room300: continue ionome0 while (Maps [LX + I] [YBN 1] = 0): if (Maps [LX + I] [YBN 1] = = 1): stack.append ((lx+i) 1) break iTunes 1 ionome0 while (Maps [RX-I] [YBN 1] = 0): if (Maps [RX-I Must1] [YBY 1] = = 1): stack.append ((rx-i) 1) break iPerform1 if ymurf 1-dy: err-= dy x0 + = sx if e2 < dx: err + = dx y0 + = sydef draw_rectangle (x0, y0, x1, y1): bresenham (x0, y0, x1, y0pr 0xffff) bresenham (x1, y0, x1, y1, Y1mem0xffff) bresenham (x1, y1, x0, y1m0xffffff) bresenham (x0, y1, x0 Y0re0xffffff) def draw_polygon (points): for i in range (len (points)): X0 = points [I] [0] y0 = points [I] [1] x1 = points [(I + 1)% len (points)] [0] y1 = points [(I + 1)% len (points)] [1] bresenham (x0, y0, x1) Y1points 0x00ff00) def draw_polygon_black (points): for i in range (len (points)): X0 = points [I] [0] y0 = points [I] [1] x1 = points [(I + 1)% len (points)] [0] y1 = points [(I + 1)% len (points)] [1] bresenham (x0, y0, x1, y1line 0x000000) # whether line segments intersect def IsRectCross (p1x, p1y, p2x, p2y, Q1x Q1Y, Q2x, Q2Y): return min (p1x dint p2x)

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report